Skip to content
/ YTMASC Public

Your offline music with YouTube as it's backend!

License

Notifications You must be signed in to change notification settings

Egezenn/YTMASC

Repository files navigation

YTMASC

horrible orange triangle

YTMASC(YouTube Music Audio Scraper & synChronizer) in a nutshell, aims to get your music library off of YouTube and provide you an offline backup of it along with other maintenance niceties.

Grab the latest alpha version here!

It's features are:

  • Scraping your library page from YouTube
  • Importing favorites from a RiMusic database
  • Import a CSV of your own (columns are: *watch_id, artist, title)
  • Maintaining a data file for your music for an easily reproducible collection
  • Automatic downloading, converting and tagging
  • Some helper functions to modify your data file easier and for easy migration
  • A GUI and a CLI (shipped as a binary for Windows!)

The project just keeps expanding as I learn more stuff and want to implement niche things. So it's currently in alpha stages, you may see new features come and go every now and then.

CLI Usage Examples

ytmasc | ytmasc gui: launches the deprecated gui

ytmasc -h: shows the help

ytmasc gui: will run the tkinter gui (it may get broken in the future)

ytmasc run: runs tasks according to the current configuration

ytmasc set: will show you the state of the config

ytmasc set run-fetcher 1: sets the fetcher to run

ytmasc --export-library-as-csv: exports the library as csv to the data directory

Side notes

  • You need ffmpeg binaries for conversion.
  • YouTube blocks API requests if you exceed the amount they classify you as a bot (around 200 requests). You can either use a VPN, proxy or just wait to bypass this. See related yt-dlp issue. Currently the download loop breaks and skips to the next task.
  • While downloading, some changes may occur in YouTube which results in an error. You can use ytmasc --db-replace-fails to replace these watch_ids to something else.

fetcher.py

This part is a little duct taped, I couldn't find a good way to get the libraryPage formerly known as likesPage so I just emulated user input. It's written for a Windows computer that has firefox or zen as the default browser and file explorer. Shouldn't be hard to tinker and get it to work for your configuration. You can do this manually too, shouldn't take much of your time.

Change resendAmount based on your internet connection, page length. Rule of thumb is to divide your like amount by 10 for this.

Change openingDelay based on your internet connection.

Change savePageAsIndexOnRightClick to which index your save as is on your browser.

The rest is fine if you don't have a really old computer.

Requirements to run from source or build

  • ~=python3.11
  • python3-tk (Linux)
  • ffmpeg

Dependencies

Binaries

Python ~=3.11 - Core language. Licensed under PSFL license.

FFmpeg - Required for the conversion of files. Licensed under LGPLv2.1 license.

Python packages

beautifulsoup4 - Used in parsing the user's likes page HTML. Licensed under MIT license.

eyed3 - Used in tagging the files. Licensed under GPL-3.0 license.

ffmpeg-python - Used in converting files to desired format(s) as a wrapper. Licensed under Apache-2.0 license.

mutagen* - Subdependency, planned to replace eyed3. Licensed under GPL-2.0 license.

pandas - Used in CSV/JSON helper utilities. Licensed under BSD-3-Clause license.

pillow - Used in modification of covers. Licensed under MIT-CMU license.

pyautogui - Used in fetcher to get the user's likes page. Licensed under BSD-3-Clause license.

pyinstaller - Used in compilation. Licensed under a GPLv2 license.

pyyaml - Used in handling user's config files. Licensed under MIT license.

yt-dlp - Used in downloading user's library. Licensed under Unlicense license.

ytmusicapi - Used in metadata fetching. Licensed under MIT license.

fuzzywuzzy - Used in comparison utilities for migration for fuzzy matching. Licensed under GPLv2 license.

python-levenshtein* - Subdependency for fuzzywuzzy. Licensed under GPL-2.0 license.

keyboard - Used in comparison utilities for migration to handle keypresses. Licensed under MIT license.

prettytable - Used in comparison utilities as a part of UX. Licensed under a custom license.

Disclaimer

This project is not in any way, shape or form affiliated with YouTube, Google or any of their subsidiaries and affiliates.