Keeping my music offline
| ~5 minute read
In the age of streaming, here I am, keeping an offline library of music. Let's talk about why and how I do it, and my experience so far.
Note: There are multiple ways to get music offline. You can buy music in various formats, and you can just download from any website. Lets not discuss the ethicality of either of these options.
The issues with YouTube
I used to primarily use YouTube for music. Their recommendations are good, and all the creators post there. But there were many issues with that, though I still go there in search for new songs.
One major issue I've had is videos suddenly disappearing from my playlist due to various reasons. Sometimes they get blocked in my area for some reason, sometimes they get deleted. This is annoying especially because YouTube doesn't even show the title of those "Unavailable" videos.
Why not Spotify, etc?
I already have a YouTube account, and with uBlock Origin on PC, and NewPipe on my phone I have background play and no ads. Same can't be done for Spotify, amirite? Also since I'm already on YouTube I see no valid reason to create a new account on another service; I'd rather just have one.
I also once tried Amazon Music (not sure if it still exists) and also Gaana (not sure about that either!) and hated pretty much both of them. Youtube is nice.
The pros of downloading music
I've been downloading for 3-4 months. And have seen many benefits so far.
Here are some highlights:
- No need to care about limited/slow internet access
- I can listen to music on a plane
- There are many music players I can choose from
- Even if a particular song becomes unavailable offline, I have access to it!
- Browsing a local library is a lot snappier than scrolling through a YouTube playlist
The major downside
Managing a library is a long process. It's definitely not as straightforward as
just adding a song to a playlist. Sometimes you can download the song files officially
but sometimes you have to make do with things like yt-dlp
In such cases the file may not have the correct metadata which might be fine for some people but definitely not for me. I have spent a good amount of time properly setting the title, file name, album art, artist, etc using this handy tool called tageditor. I even add the lyrics to the mp3 file so I can be fully offline and check the lyrics whenever I want to! This is a long and still ongoing process though.
Just as a note it is possible to add metadata using ffmpeg
but the reason I don't use
it is a whole new story.
The "Screening Process"
I don't wanna waste disk space on songs I don't like, so I have a "Screening Process" to decide what makes it into the local library. It goes like this:
- I find a new song
- Add it to my playlist on YouTube (or NewPipe)
- Everytime I listen to music its a mix of the downloaded stuff and the online playlist
- When the playlist reaches about 10-15 titles (or every few days) I remove the ones I don't really like, and download the others and clear the playlist
It's neither perfect or consistent but works for me!
My setup
On my phone I use RetroMusic which is available on F-Droid. It is a beautiful music player app which is highly customizable. It is arguably the best music player app on android.
My laptop is where all the major stuff happens. I download music, add metadata with tageditor if needed, and move the files to my songs folder. Then the folder is synced to my phone and optionally on a USB flash drive that can be plugged into the car, etc (saves my phone's battery!). To listen to music on the laptop I just use mpd and ncmpcpp.
If you want to download audio from YouTube just run this simple command replacing the URL accordingly:
yt-dlp -x --audio-format mp3 "https://youtu.be/JJ9IX4zgyLs"
Here's how you can download a whole playlist:
If I'm not wrong, yt-dlp
can take URL of a playlist as input, but with large playlists it might
fail or take too long. Sometimes you might want to partially download a playlist and resume the process
later on. Use this script for that:
in this example I'll call it dl.sh
#!/bin/bash
FILE=$@
LINES=$(cat $FILE)
counter=1
for line in $LINES; do
yt-dlp -x --audio-format mp3 "https://www.youtube.com/watch?v=$line" || echo "$line" >> "$FILE""_failed"
counter=$((counter+1))
tail -n "+$counter" "$FILE" > "$FILE""_remaining"
done
rm "$FILE""_remaining"
Steps:
-
Go to https://takeout.google.com and create a new takeout with only YouTube selected.
-
Download the takeout when it is ready, open the CSV file of the playlist you want to download and delete all the other columns except the Video ID. Also delete the column header (first line)
The end result would look like this:
vA86QFrXoho JJ9IX4zgyLs MGOP3blxUw4
-
Run
./dl.sh <file_name>
. This may create additional files named<file_name>_remaining
and<file_name>_failed
If any video(s) fail to download you can check this file later on. If you want to stop this script the
_remaining
file would hold the Video IDs that are yet to be downloaded, so you can just start at that file.
This is post 06 of #100DaysToOffload