This is an automated archive made by the Lemmit Bot.

The original was posted on /r/selfhosted by /u/Punk_Saint on 2025-08-08 16:00:12+00:00.


Project Main Menu in the terminal

I don’t know if its the right flair

  1. Downloaded my data from spotify (they sent it to me after 2-3 days)
  2. Created a prototype python script that uses yt-dlp to find each song in the tracks.json and downloads it
  3. been running since last night at 10 p.m and finished earlier
  4. downloaded almost all of them except 30
  5. upgraded the prototype to a full fledged project with a main menu, system check, more functionality, better logging,
  6. Using Foobar2000, I now have my own music library without the need for internet.

downloader.py

This script automates downloading audio tracks from YouTube using yt-dlp. The download_track function handles downloading a single track based on an artist and track name, formats the search query, and runs a yt-dlp command to extract the audio in the specified format. It logs the progress, success, or failure using helper logging functions (log_info, log_success, log_error), and includes an optional delay between downloads to avoid rate limits. The _download_worker function is a lighter, quieter version meant for background batch processing, suppressing most output while still reporting the result.

The batch_download function runs multiple downloads in parallel using Python’s asyncio and a ThreadPoolExecutor. It takes a list of tracks (each with artist and track), splits them into concurrent download tasks, and updates a progress bar from the tqdm library as each finishes. By combining asynchronous task scheduling with multithreading, the script efficiently downloads several tracks at once while keeping the user informed of progress and errors.

How the program looks when it’s running in batch mode

Right now, I’m going through the elements it missed on its first run.

from 1049 songs, it missed 30. which is about 2% loss, not bad.

Also some songs just do not exist on youtube, or it will download the wrong thing when the song is not existent.

I’m working right now to make it use the playlist file so that it can:

  • Sort the downloaded tracks to folders based on your playlists.

  • Download directly from the playlist file straight to their respective playlist directories

prototype.py

the prototype was what I used to download the first 1049 songs, and it works well as well.

link to the github in the comments if the mods approve.

EDIT #1: New features enabled:

  • Interactive multi-level menu system

  • New modular structure

  • Sequential and asynchronous batch downloads with progress bars

  • Embed metadata (artist, track info) into downloaded audio files

  • Check downloaded vs pending tracks automatically