This project automates the process of fetching, downloading, and managing YouTube music videos.
It integrates with the YouTube Data API v3 to access your liked videos or any playlist you choose, and uses yt-dlp to downloads.
It also retrieves artist names, track titles, youtube thumbnails and some other metadata.
You can also automatically add lyrics or tags by fetching the title and uploader name of the songs or video (fully customizable), and remove segments via sponsorblock
-
Fetch & Download
- Download videos or audio from any playlist (default liked_videos).
- Supports only
mp3due to tags, lyrics and metadatas usagebut may extend to other formats in the future - Skips videos that are private or unavailable.
-
Metadata & Lyrics
- Can automatically extract artist, title, and uploader information.
- Fetch lyrics with syncedlyrics (no token or api required), or the youtube subtitles if there are some, in this order: manual subtitles > syncedlyrics > auto subtitles
- Can automatically add tags to your file, depending on what's inside the filename and uploader name, customize that here
- can automatically remove segments marked from sponsorblock
-
Error Handling
- Detects and skips private videos.
- Keeps track of failed downloads in separate log files.
-
Configuration System
- Uses structured TOML configuration file for easy customization
- All settings centralized in
CONFIG/config.toml - Flexible parameter override system
-
Clone the repository
git clone https://github.com/Elnix90/Youtube-Downloader.git cd Youtube-Downloader -
Create and activate a virtual environment (recommended)
python -m venv venv source venv/bin/activate # Linux/Mac # or on Windows: # venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
The application uses a structured TOML configuration file. Here's what you need to configure:
Essential settings:
[paths]
download_path = "/your/music/folder" # Where to save downloaded music
db_path = "music.db" # SQLite database file
[processing]
playlist_id = "LL" # "LL" = liked videos, or specific playlist ID
get_lyrics = true # Download lyrics automatically
add_tags = true # Apply automatic tagging (based on your settings)
test_run = false # Set to true for testing without downloadingAvailable processing options:
embed_metadata- Add metadata to MP3 filesget_lyrics- Fetch lyrics from syncedlyrics or YouTube subtitlesget_thumbnail- Add thumbnails to MP3 filesuse_sponsorblock- Remove sponsored segmentsadd_tags- Apply automatic tags based on title/artist patternsadd_album- Organize tracks into Public/Private albums
For accessing private playlists or liked videos:
- Create a project in the Google Cloud Console
- Enable the YouTube Data API v3
- Create an OAuth Client ID with the type "Desktop app"
- Download the
client_secret.jsonfile and place it inCREDS/
-
Configure the application:
# Edit CONFIG/config.toml vim CONFIG/config.toml -
Set your music folder in
CONFIG/config.toml:[paths] download_path = "~/YOUTUBE/MUSICS" # Change this path
-
Run the application:
python main.py
Download your liked videos with default settings:
python main.pyTest mode (no actual downloads or any file editing):
# Edit config.toml:
[processing]
test_run = trueDownload a specific playlist:
# Edit config.toml:
[processing]
playlist_id = "PLnVyge3em-a2ElGZrft3LHoh64YnGhPsh" # Replace with your playlist IDSimple download without lyrics or tags:
# Edit config.toml:
[processing]
get_lyrics = false
add_tags = false
use_sponsorblock = false- Authentication: If using private playlists, the app opens your browser for YouTube OAuth
- Playlist Fetching: Retrieves video information from your chosen playlist
- Database Management: Stores video metadata in a SQLite database
- Download Process: Downloads new videos as MP3 files using yt-dlp
- Enrichment: Adds lyrics, tags, thumbnails, and metadata to each file
- SponsorBlock: Removes sponsored segments if enabled
Tag System: Create files in CONFIG/TAGS/:
tag_rock.txt- Words that trigger "rock" tagtag_french.txt- Words that trigger "french" tagnotag_instrumental.txt- Words that prevent tagging if word in list of words, else it gives the tag
Pattern Cleaning: Edit CONFIG/PATTERNS/unwanted_patterns.txt to improve lyrics matching by removing common words like "official", "lyrics", etc.
├── CREDS # Google creditentials tokens
├── .gitignore # Git ignore file for excluding files/folders from version control
├── CONFIG # Configuration directory
│ ├── PATTERNS # Pattern files for processing music metadata
│ ├── TAGS # Tagging rules directory
│ └── config_loader.py # Loads and validates the configuration from config.toml
├── CONSTANTS.py # Defines constants and paths used across the project
├── DEBUG # Scripts for testing and/or debugging
├── FUNCTIONS # Core functionality of the project
│ ├── HELPERS # Utility/helper functions used across modules
│ └──PROCESS # Processing modules for different music operations
├── README.md # Project overview and instructions
├── main.py # Main entry point for the program
└── requirements.txt # Python dependencies
- You must be signed in with a Google account that has access to the playlist you want to process (if unavailable by yt_dlp)
- Private videos will be skipped unless you provide cookies for authentication.
- Lyrics fetching relies syncedlyrics and youtube's subtitles not all songs will have lyrics or correct lyrics
- Tags automatically searching is only dependent of your customisation, same for ablum
yt-dlpformat support depends on YouTube's availability.
- Interactive CLI or GUI for easier use
- Enhanced configuration validation and error handling
- Batch processing with progress bars (partially implemented)
- Easier customisation of tags and lyrics
This project is open-source under the MIT License.