# Perun YouTube Podcast Downloader A Python script that automatically downloads the latest video from the Perun YouTube channel, converts it to MP3 with metadata, removes sponsor segments, and uploads it to a podcast server. ## Features - **Automatic Detection**: Checks for new episodes by comparing with Audiobookshelf library - **Audio Conversion**: Downloads and converts YouTube videos to MP3 format - **Sponsor Removal**: Uses SponsorBlock API to remove sponsored segments - **Metadata Injection**: Adds title, artist, track number, date, and description to MP3 files - **SFTP Upload**: Automatically uploads to remote podcast server - **Push Notifications**: Sends notification when new episode is available ## Prerequisites - Python 3.8+ - yt-dlp - ffmpeg (for audio conversion) - SSH key-based authentication configured - Audiobookshelf server with API access ## Installation ```bash pip install -r requirements.txt ``` Install ffmpeg: ```bash # Ubuntu/Debian sudo apt install ffmpeg # macOS brew install ffmpeg ``` ## Usage Run the script manually: ```bash python get_episode.py ``` Or schedule with cron and use the provided `grabEpisode.sh` (Monday at 7 AM): ```bash 0 7 * * 1 /path/to/script/grabEpisode.sh ``` Youtube blocks a lot of server IPs so running this locally is just easier. ## Configuration Create a `.env` file with the following variables: ```env # YouTube channel to monitor YOUTUBE_CHANNEL_URL=https://www.youtube.com/@PerunAU/videos # Audiobookshelf API PODCAST_API_URL=https://your-audiobookshelf.com/api/items/{item-id} PODCAST_AUTHORIZATION_TOKEN=your_token_here # SFTP upload destination REMOTE_HOSTNAME=your_ssh_host_alias REMOTE_PATH=/path/to/podcast/folder # Backend notification service BACKEND_API_URL=http://backend:8101/internal/receive-notifications BACKEND_API_KEY=your_api_key ``` ## Output MP3 files are named: `perun-YYYY-MM-DD.mp3` Example: `perun-2025-10-19.mp3`