Skip to content

dimzjin/-youtube-weekly-upload-agent

Repository files navigation

YouTube Weekly Upload Agent

Template automation untuk upload YouTube mingguan dari Telegram + Google Drive + cron.

Core Workflow

  • 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
  • Setelah 004 berhasil upload, Drive cleanup menghapus file batch dan mengosongkan active batch.

Components

  • auth_test.py creates Google OAuth token.json.
  • upload_weekly.py uploads one scheduled YouTube video per run.
  • telegram_batch_agent.py receives Telegram files and uploads them to Drive.
  • drive_batch_scanner.py detects files uploaded directly to Drive, such as from PC rclone.
  • batch_reminder.py sends weekly incomplete-batch reminders.
  • AGENTS.md documents agent behavior and safety rules.

File Naming

Use numeric codes:

  • 001_video.mp4
  • 001_thumbnail.png
  • 002_video.mp4
  • 002_thumbnail.png
  • 003_video.mp4
  • 003_thumbnail.png
  • 004_video.mp4
  • 004_thumbnail.png

Do Not Commit

Never commit:

  • .env
  • token.json
  • client_secret.json
  • upload_history.json
  • batch_state.json
  • reminder_state.json
  • drive_scanner_state.json
  • drive_scanner_start.txt
  • logs/
  • downloads/
  • telegram_inbox/
  • SSH keys or .pem files
  • rclone config files

Install

  1. python3 -m venv .venv
  2. source .venv/bin/activate
  3. pip install -r requirements.txt
  4. cp .env.example .env
  5. Edit .env with your own values.

Google OAuth

  1. Enable YouTube Data API v3.
  2. Enable Google Drive API.
  3. Create OAuth Client ID as Desktop app.
  4. Download JSON as client_secret.json.
  5. Run python auth_test.py.
  6. Open the auth URL and grant access.
  7. Confirm token.json exists.

Cron Example

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

PC rclone Option

For large videos, Telegram Bot API may be too limited. Recommended PC workflow:

  1. Install rclone on Windows.
  2. Configure a Google Drive remote named gdrive.
  3. Put weekly files in a local folder like Documents/youtube-batch.
  4. Run a local .bat script to upload files to Drive.
  5. VPS drive_batch_scanner.py detects the files and sends Telegram status.

Do not store Telegram tokens directly in public scripts.

Thumbnail Note

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.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages