Template automation untuk upload YouTube mingguan dari Telegram + Google Drive + cron.
- User menaruh file batch di PC atau mengirim file ke receiver bot.
- File masuk ke Google Drive folder video/thumbnail.
- VPS scanner mendeteksi file baru di Google Drive.
- Batch state dicatat di
batch_state.json. - Cron upload menjalankan satu video per hari:
- Senin 06:00 upload
001, public 14:00 WIB - Rabu 06:00 upload
002, public 14:00 WIB - Jumat 06:00 upload
003, public 14:00 WIB - Minggu 06:00 upload
004, public 14:00 WIB
- Senin 06:00 upload
- Setelah
004berhasil upload, Drive cleanup menghapus file batch dan mengosongkan active batch.
auth_test.pycreates Google OAuthtoken.json.upload_weekly.pyuploads one scheduled YouTube video per run.telegram_batch_agent.pyreceives Telegram files and uploads them to Drive.drive_batch_scanner.pydetects files uploaded directly to Drive, such as from PC rclone.batch_reminder.pysends weekly incomplete-batch reminders.AGENTS.mddocuments agent behavior and safety rules.
Use numeric codes:
001_video.mp4001_thumbnail.png002_video.mp4002_thumbnail.png003_video.mp4003_thumbnail.png004_video.mp4004_thumbnail.png
Never commit:
.envtoken.jsonclient_secret.jsonupload_history.jsonbatch_state.jsonreminder_state.jsondrive_scanner_state.jsondrive_scanner_start.txtlogs/downloads/telegram_inbox/- SSH keys or
.pemfiles - rclone config files
python3 -m venv .venvsource .venv/bin/activatepip install -r requirements.txtcp .env.example .env- Edit
.envwith your own values.
- Enable YouTube Data API v3.
- Enable Google Drive API.
- Create OAuth Client ID as
Desktop app. - Download JSON as
client_secret.json. - Run
python auth_test.py. - Open the auth URL and grant access.
- Confirm
token.jsonexists.
Upload cron:
0 6 * * 1,3,5,0 cd /home/ubuntu/youtube-agent && /home/ubuntu/youtube-agent/.venv/bin/python /home/ubuntu/youtube-agent/upload_weekly.py >> /home/ubuntu/youtube-agent/logs/cron_upload.log 2>&1
Telegram receiver cron:
* * * * * cd /home/ubuntu/youtube-agent && /home/ubuntu/youtube-agent/.venv/bin/python /home/ubuntu/youtube-agent/telegram_batch_agent.py >> /home/ubuntu/youtube-agent/logs/telegram_batch.log 2>&1
Drive scanner cron:
* * * * * cd /home/ubuntu/youtube-agent && /home/ubuntu/youtube-agent/.venv/bin/python /home/ubuntu/youtube-agent/drive_batch_scanner.py >> /home/ubuntu/youtube-agent/logs/drive_scanner.log 2>&1
Reminder cron:
0 20 * * * cd /home/ubuntu/youtube-agent && /home/ubuntu/youtube-agent/.venv/bin/python /home/ubuntu/youtube-agent/batch_reminder.py >> /home/ubuntu/youtube-agent/logs/batch_reminder.log 2>&1
For large videos, Telegram Bot API may be too limited. Recommended PC workflow:
- Install rclone on Windows.
- Configure a Google Drive remote named
gdrive. - Put weekly files in a local folder like
Documents/youtube-batch. - Run a local
.batscript to upload files to Drive. - VPS
drive_batch_scanner.pydetects the files and sends Telegram status.
Do not store Telegram tokens directly in public scripts.
YouTube custom thumbnail upload requires the channel to have custom thumbnails / advanced features enabled. The script can compress thumbnails under 2 MB, but it cannot bypass YouTube account permissions.