Skip to content

silaspuma/yourexplorepage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TikTok to YouTube Automation Service

A long-running Python service that automatically detects trending TikTok videos and reposts them to YouTube Shorts with proper attribution.

Features

  • ✅ Monitors TikTok's non-personalized trending feed every 10-15 minutes
  • ✅ Detects when the top video changes
  • ✅ Downloads videos in highest quality using yt-dlp
  • ✅ Extracts caption, hashtags, and creator information
  • ✅ Enforces 24-hour upload cooldown to avoid spam
  • ✅ Uploads to YouTube Shorts with proper attribution
  • ✅ Persistent state tracking to avoid reprocessing
  • ✅ Robust error handling with exponential backoff
  • ✅ Designed for 24/7 operation on Linux VPS

Prerequisites

System Requirements

  • Python 3.8 or higher
  • ffmpeg (for video processing)
  • Linux VPS (Ubuntu 20.04+ recommended)
  • Stable internet connection

YouTube API Setup

  1. Go to Google Cloud Console

  2. Create a new project or select existing one

  3. Enable the YouTube Data API v3

  4. Create OAuth 2.0 credentials:

    • Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
    • Choose "Desktop app" as application type
    • Download the credentials JSON file
    • Rename it to client_secrets.json and place in project directory
  5. Configure OAuth consent screen:

    • Add your email as a test user
    • Add the scope: https://www.googleapis.com/auth/youtube.upload

Important: YouTube Data API has daily quotas. Each video upload costs ~1600 quota units. The default daily quota is 10,000 units (allowing ~6 uploads per day).

Installation

1. Install System Dependencies

# Ubuntu/Debian
sudo apt update
sudo apt install -y python3 python3-pip python3-venv ffmpeg

# CentOS/RHEL
sudo yum install -y python3 python3-pip ffmpeg

2. Clone or Upload Project

mkdir -p /opt/tiktok-youtube-service
cd /opt/tiktok-youtube-service

# Upload all project files here

3. Create Virtual Environment

python3 -m venv venv
source venv/bin/activate

4. Install Python Dependencies

pip install -r requirements.txt

5. Configure the Service

Edit config.yaml with your preferences:

tiktok:
  check_interval_minutes: 12  # How often to check (10-15 recommended)
  
youtube:
  client_secrets_file: "client_secrets.json"
  upload_cooldown_hours: 24
  category_id: "24"  # Entertainment
  privacy_status: "public"  # or "unlisted", "private"

6. Initial OAuth Authentication

First run requires interactive authentication:

python main.py

This will:

  1. Open a browser window for YouTube OAuth consent
  2. Ask you to authorize the application
  3. Save credentials to youtube_token.pickle for future use

After successful authentication, press Ctrl+C to stop, then proceed to set up as a system service.

Running as a System Service

Create systemd Service File

sudo nano /etc/systemd/system/tiktok-youtube.service

Paste the following (adjust paths as needed):

[Unit]
Description=TikTok to YouTube Automation Service
After=network.target

[Service]
Type=simple
User=YOUR_USERNAME
WorkingDirectory=/opt/tiktok-youtube-service
Environment="PATH=/opt/tiktok-youtube-service/venv/bin"
ExecStart=/opt/tiktok-youtube-service/venv/bin/python main.py
Restart=always
RestartSec=60
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Important: Replace YOUR_USERNAME with your Linux username.

Enable and Start Service

# Reload systemd
sudo systemctl daemon-reload

# Enable service to start on boot
sudo systemctl enable tiktok-youtube.service

# Start the service
sudo systemctl start tiktok-youtube.service

# Check status
sudo systemctl status tiktok-youtube.service

View Logs

# Real-time logs
sudo journalctl -u tiktok-youtube.service -f

# Last 100 lines
sudo journalctl -u tiktok-youtube.service -n 100

# Application log file
tail -f /opt/tiktok-youtube-service/tiktok_youtube_service.log

Service Management Commands

# Stop service
sudo systemctl stop tiktok-youtube.service

# Restart service
sudo systemctl restart tiktok-youtube.service

# Disable service
sudo systemctl disable tiktok-youtube.service

Project Structure

.
├── main.py                  # Main service orchestrator
├── config.yaml             # Configuration file
├── config_loader.py        # Configuration management
├── state_manager.py        # State persistence
├── queue_manager.py        # Upload queue management
├── tiktok_scraper.py       # TikTok trending feed scraper
├── video_downloader.py     # Video download handler
├── youtube_uploader.py     # YouTube API integration
├── retry_utils.py          # Retry logic with backoff
├── requirements.txt        # Python dependencies
├── client_secrets.json     # YouTube OAuth credentials (you provide)
├── youtube_token.pickle    # OAuth token (auto-generated)
├── state.json             # Service state (auto-generated)
├── queue.json             # Upload queue (auto-generated)
└── downloads/             # Downloaded videos (auto-created)

How It Works

  1. Polling: Service checks TikTok's trending feed every 10-15 minutes
  2. Detection: Identifies when the #1 trending video changes
  3. Validation: Checks if video has already been processed
  4. Download: Downloads video in highest quality using yt-dlp
  5. Queue: Adds video to upload queue with metadata
  6. Cooldown Check: Enforces 24-hour minimum between uploads
  7. Upload: Uploads to YouTube Shorts with attribution
  8. Cleanup: Removes local video files and updates state

Configuration Options

TikTok Settings

  • check_interval_minutes: How often to poll (10-15 recommended)
  • random_delay_seconds: Random delay range to appear human-like

YouTube Settings

  • upload_cooldown_hours: Minimum hours between uploads (24 default)
  • category_id: YouTube category (24 = Entertainment)
  • privacy_status: public, unlisted, or private
  • made_for_kids: COPPA compliance setting

Storage Settings

  • state_file: Processed video IDs storage
  • video_download_dir: Temporary video storage
  • queue_file: Pending uploads queue

Troubleshooting

TikTok API Changes

TikTok's unofficial API endpoints may change. If trending detection fails:

  1. Check logs for specific errors
  2. Update tiktok_scraper.py with new API endpoints
  3. Monitor TikTok's network traffic using browser DevTools

YouTube Quota Exceeded

If you hit YouTube's daily quota:

  • Service will log errors but continue running
  • Uploads will resume automatically the next day
  • Consider requesting quota increase from Google

OAuth Token Expired

If authentication fails:

# Delete old token
rm youtube_token.pickle

# Re-authenticate
python main.py

FFmpeg Not Found

# Install ffmpeg
sudo apt install ffmpeg

# Verify installation
ffmpeg -version

Service Won't Start

# Check for errors
sudo journalctl -u tiktok-youtube.service -n 50

# Verify Python environment
cd /opt/tiktok-youtube-service
source venv/bin/activate
python -c "import yt_dlp, googleapiclient; print('OK')"

Legal and Ethical Considerations

⚠️ Important Disclaimers:

  • Copyright: This service reposts content created by others. Ensure you have proper rights or fair use applies.
  • Attribution: The service includes creator attribution in titles and descriptions.
  • TikTok ToS: Web scraping may violate TikTok's Terms of Service.
  • YouTube ToS: Ensure uploaded content complies with YouTube's policies.
  • Responsibility: You are responsible for all content uploaded to your YouTube channel.

Recommendations:

  • Use responsibly and ethically
  • Consider reaching out to creators for permission
  • Monitor your channel for copyright claims
  • Be prepared to remove content if requested

Monitoring

Check Service Health

# View statistics from state
cat state.json

# Check queue size
cat queue.json

# Monitor disk usage
du -sh downloads/

Set Up Alerts (Optional)

Use cron to monitor service status:

crontab -e

# Add line to check every hour
0 * * * * systemctl is-active --quiet tiktok-youtube.service || echo "Service is down!" | mail -s "TikTok-YouTube Service Alert" your@email.com

Performance

  • CPU: Minimal (< 5% average)
  • RAM: ~200-500 MB
  • Disk: ~100 MB per video (cleaned automatically)
  • Network: Depends on video sizes (~10-50 MB per download)
  • API Calls: ~144 TikTok checks/day, 1 YouTube upload/day

Updates and Maintenance

# Stop service
sudo systemctl stop tiktok-youtube.service

# Update code
cd /opt/tiktok-youtube-service
git pull  # or upload new files

# Update dependencies
source venv/bin/activate
pip install -r requirements.txt --upgrade

# Restart service
sudo systemctl start tiktok-youtube.service

Support

For issues or questions:

  1. Check application logs: tiktok_youtube_service.log
  2. Check system logs: sudo journalctl -u tiktok-youtube.service
  3. Verify API credentials and quotas
  4. Test components individually

License

This project is provided as-is for educational purposes. Use at your own risk and ensure compliance with all applicable laws and terms of service.

About

the code behind @yourexplorepage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors