Skip to main content

A modular Python package for downloading and uploading TikTok videos

Project description

TikTok Reup - Python Package

Python Version License Package Version

A modular Python package for downloading and uploading TikTok videos with enhanced organization and maintainability.

๐ŸŒŸ Features

  • ๐Ÿ“ Modular Architecture: Clean separation of concerns with organized modules
  • โฌ‡๏ธ Download TikTok Videos: Download videos from any TikTok user profile
  • ๐ŸŽฏ Single Video Download: Download individual videos by URL
  • โฌ†๏ธ Automated Upload: Upload downloaded videos back to TikTok with captions
  • ๐Ÿ”„ Bulk Operations: Handle multiple videos efficiently
  • ๐Ÿ”— Multiple Download Methods: API scraping and Selenium fallback
  • ๐Ÿ“ Caption Management: Automatic caption extraction and upload
  • ๐Ÿ“Š Progress Tracking: Visual progress bars and status updates

๐Ÿ“ฆ Installation

Option 1: Install from Source (Development)

# Clone the repository
git clone https://github.com/xuancuong2006/tiktok-reup.git
cd tiktok-reup

# Install in development mode
pip install -e .

Option 2: Install as Package

# Install from local directory
pip install .

Option 3: Install Dependencies Only

pip install -r requirements.txt

๐Ÿš€ Quick Start

As a Python Package

from tiktok_reup import TikTokDownloader, TikTokUploader, SeleniumHandler

# Initialize downloader
downloader = TikTokDownloader("downloads")

# Download videos from a user
downloader.download_user_videos("username", max_videos=10)

# Download single video
downloader.download_single_video("https://www.tiktok.com/@user/video/123456789")

# Initialize uploader
selenium_handler = SeleniumHandler()
uploader = TikTokUploader(selenium_handler)

# Upload videos
uploader.bulk_upload_videos("downloads/username", upload_limit=5)

As a Command Line Tool

# Run the CLI interface
tiktok-reup

# Or run the module directly
python -m tiktok_reup.cli

๐Ÿ“ Package Structure

tiktok_reup/
โ”œโ”€โ”€ ๐Ÿ“ api/                    # TikTok API handling
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ tiktok_api.py
โ”œโ”€โ”€ ๐Ÿ“ config/                 # Configuration settings
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ settings.py
โ”œโ”€โ”€ ๐Ÿ“ core/                   # Core downloader functionality
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ downloader.py
โ”œโ”€โ”€ ๐Ÿ“ selenium_handler/       # Browser automation
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ browser.py
โ”œโ”€โ”€ ๐Ÿ“ upload/                 # Upload functionality
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ uploader.py
โ”œโ”€โ”€ ๐Ÿ“ utils/                  # Utility functions
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ helpers.py
โ”œโ”€โ”€ __init__.py               # Package initialization
โ””โ”€โ”€ cli.py                    # Command line interface

๐ŸŽฎ Usage Examples

Download Examples

from tiktok_reup import TikTokDownloader

# Create downloader instance
downloader = TikTokDownloader("my_downloads")

# Download all videos from a user
downloader.download_user_videos("cooluser123")

# Download limited number of videos
downloader.download_user_videos("cooluser123", max_videos=5)

# Download single video with custom filename
downloader.download_single_video(
    "https://www.tiktok.com/@user/video/123456789",
    custom_filename="my_video"
)

Upload Examples

from tiktok_reup import TikTokUploader, SeleniumHandler

# Initialize selenium handler and uploader
selenium_handler = SeleniumHandler()
uploader = TikTokUploader(selenium_handler)

# Login to TikTok (manual browser login)
uploader.login_to_tiktok()

# Upload videos from a folder
uploader.bulk_upload_videos("downloads/username")

# Upload with limit
uploader.bulk_upload_videos("downloads/username", upload_limit=3)

Configuration

from tiktok_reup import settings

# Access configuration
print(settings.DEFAULT_DOWNLOAD_FOLDER)
print(settings.MAX_CAPTION_LENGTH)

# Modify settings (if needed)
settings.DEFAULT_UPLOAD_DELAY = 20  # seconds between uploads

๐Ÿ”ง API Reference

TikTokDownloader

class TikTokDownloader:
    def __init__(self, download_folder="downloads"):
        """Initialize downloader with custom download folder"""
    
    def download_user_videos(self, username, max_videos=None):
        """Download all videos from a TikTok user"""
    
    def download_single_video(self, video_url, custom_filename=None):
        """Download a single video by URL"""
    
    def close_browser(self):
        """Close any open browser instances"""

TikTokUploader

class TikTokUploader:
    def __init__(self, selenium_handler):
        """Initialize uploader with selenium handler"""
    
    def login_to_tiktok(self):
        """Login to TikTok (manual browser login)"""
    
    def upload_video(self, video_path, caption_path, custom_caption=None):
        """Upload a single video with caption"""
    
    def bulk_upload_videos(self, user_folder, upload_limit=None):
        """Upload multiple videos from folder"""

โš™๏ธ Configuration

Settings File (config/settings.py)

# Default settings
DEFAULT_DOWNLOAD_FOLDER = "downloads"
DEFAULT_UPLOAD_DELAY = 15  # seconds between uploads
MAX_CAPTION_LENGTH = 2200
MAX_SCROLLS = 5
UPLOAD_TIMEOUT = 120  # seconds

# Browser options
CHROME_OPTIONS_HEADLESS = [...]  # Headless browsing options
CHROME_OPTIONS_UPLOAD = [...]    # Upload browsing options

# API endpoints
API_ENDPOINTS = [...]  # TikTok API endpoints

๐Ÿ“‹ Requirements

  • Python 3.8+
  • Google Chrome browser (for Selenium)
  • All packages listed in requirements.txt:
    • requests>=2.31.0
    • tqdm>=4.65.0
    • colorama>=0.4.6
    • yt-dlp>=2023.7.6
    • selenium>=4.15.0
    • webdriver-manager>=4.0.1
    • urllib3>=1.26.0
    • certifi>=2023.7.22

๐Ÿ”’ Security & Privacy

  • Manual Login: Upload functionality requires manual login for security
  • No Credentials Stored: The package does not store any login credentials
  • Respectful Usage: Built-in delays to avoid rate limiting
  • Terms Compliance: Please respect TikTok's Terms of Service

๐Ÿ› ๏ธ Development

Install for Development

# Clone repository
git clone https://github.com/xuancuong2006/tiktok-reup.git
cd tiktok-reup

# Install in development mode
pip install -e .

# Install development dependencies
pip install -r requirements.txt

Building the Package

# Build distribution packages
python -m build

# Install locally
pip install dist/tiktok_reup-2.0.0-py3-none-any.whl

Running Tests

# Run the CLI interface
python -m tiktok_reup.cli

# Or use the installed command
tiktok-reup

๐Ÿ“š Module Descriptions

Core Module (core/downloader.py)

  • Main TikTokDownloader class
  • Video downloading logic
  • User video scanning
  • File management

API Module (api/tiktok_api.py)

  • TikTokAPI class for API interactions
  • Multiple API endpoint handling
  • Direct URL downloading
  • JSON response parsing

Selenium Handler (selenium_handler/browser.py)

  • SeleniumHandler class for browser automation
  • User profile scraping
  • Upload automation
  • Login management

Upload Module (upload/uploader.py)

  • TikTokUploader class for upload operations
  • Bulk upload functionality
  • Caption processing
  • Upload status tracking

Utils Module (utils/helpers.py)

  • Utility functions used across modules
  • File naming and sanitization
  • Caption processing
  • BMP character filtering

Config Module (config/settings.py)

  • Centralized configuration
  • Browser options
  • API endpoints
  • CSS selectors

๐Ÿšจ Troubleshooting

Common Issues

  1. Chrome Driver Issues

    # Update webdriver-manager
    pip install --upgrade webdriver-manager
    
  2. Import Errors

    # Reinstall package
    pip uninstall tiktok-reup
    pip install -e .
    
  3. Upload Issues

    • Ensure Chrome browser is installed
    • Check TikTok login status
    • Verify internet connection

Getting Help

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

โš ๏ธ Disclaimer

This software is for educational purposes only. Please respect TikTok's Terms of Service and applicable laws when using this software. The authors are not responsible for any misuse of this software.

๐Ÿ‘จโ€๐Ÿ’ป Author

Created by xuancuong2006


โญ Star this repository if you find it helpful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiktok_reup-2.0.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiktok_reup-2.0.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file tiktok_reup-2.0.0.tar.gz.

File metadata

  • Download URL: tiktok_reup-2.0.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for tiktok_reup-2.0.0.tar.gz
Algorithm Hash digest
SHA256 8c82fd8ed6de7fb5fa6cadbaa9d59bb80db87c2259a4bd53541cd5ce029c2ea8
MD5 8ff3c509d1e8c675780753505ac6f459
BLAKE2b-256 73a30ecd41a34a161ffcd35a1f2d8317143ca64f90b0b8c5cc62db22a2f754ad

See more details on using hashes here.

File details

Details for the file tiktok_reup-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: tiktok_reup-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for tiktok_reup-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d9709cac67722b692df682449020c9b485d46e069a97727576ef09191d0a0f1
MD5 33674a5ef7fc3ad282be6adff5599c4c
BLAKE2b-256 dea44b3947e4a0321bd112fb1bce0847412597246147e7075212e9deeff58a5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page