A long-running Python service that automatically detects trending TikTok videos and reposts them to YouTube Shorts with proper attribution.
- ✅ 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
- Python 3.8 or higher
- ffmpeg (for video processing)
- Linux VPS (Ubuntu 20.04+ recommended)
- Stable internet connection
-
Go to Google Cloud Console
-
Create a new project or select existing one
-
Enable the YouTube Data API v3
-
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.jsonand place in project directory
-
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).
# Ubuntu/Debian
sudo apt update
sudo apt install -y python3 python3-pip python3-venv ffmpeg
# CentOS/RHEL
sudo yum install -y python3 python3-pip ffmpegmkdir -p /opt/tiktok-youtube-service
cd /opt/tiktok-youtube-service
# Upload all project files herepython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtEdit 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"First run requires interactive authentication:
python main.pyThis will:
- Open a browser window for YouTube OAuth consent
- Ask you to authorize the application
- Save credentials to
youtube_token.picklefor future use
After successful authentication, press Ctrl+C to stop, then proceed to set up as a system service.
sudo nano /etc/systemd/system/tiktok-youtube.servicePaste 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.targetImportant: Replace YOUR_USERNAME with your Linux username.
# 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# 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# Stop service
sudo systemctl stop tiktok-youtube.service
# Restart service
sudo systemctl restart tiktok-youtube.service
# Disable service
sudo systemctl disable tiktok-youtube.service.
├── 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)
- Polling: Service checks TikTok's trending feed every 10-15 minutes
- Detection: Identifies when the #1 trending video changes
- Validation: Checks if video has already been processed
- Download: Downloads video in highest quality using yt-dlp
- Queue: Adds video to upload queue with metadata
- Cooldown Check: Enforces 24-hour minimum between uploads
- Upload: Uploads to YouTube Shorts with attribution
- Cleanup: Removes local video files and updates state
check_interval_minutes: How often to poll (10-15 recommended)random_delay_seconds: Random delay range to appear human-like
upload_cooldown_hours: Minimum hours between uploads (24 default)category_id: YouTube category (24 = Entertainment)privacy_status: public, unlisted, or privatemade_for_kids: COPPA compliance setting
state_file: Processed video IDs storagevideo_download_dir: Temporary video storagequeue_file: Pending uploads queue
TikTok's unofficial API endpoints may change. If trending detection fails:
- Check logs for specific errors
- Update
tiktok_scraper.pywith new API endpoints - Monitor TikTok's network traffic using browser DevTools
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
If authentication fails:
# Delete old token
rm youtube_token.pickle
# Re-authenticate
python main.py# Install ffmpeg
sudo apt install ffmpeg
# Verify installation
ffmpeg -version# 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')"- 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
# View statistics from state
cat state.json
# Check queue size
cat queue.json
# Monitor disk usage
du -sh downloads/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- 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
# 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.serviceFor issues or questions:
- Check application logs:
tiktok_youtube_service.log - Check system logs:
sudo journalctl -u tiktok-youtube.service - Verify API credentials and quotas
- Test components individually
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.