Music piracy!

or how to selfhost your own music streaming service

Using Navidrome, Copyparty, MusicBrainz Picard and yt-dlp to host, build and curate your own music library.

Preamble

This guide is not for total beginners. I assume you have at least some knowledge of Linux, servers and Docker. Setting up a server and installing Docker is outside the scope of this guide.

Each section gives you the tools to make these open source software work together. These instructions are in addition to the softwares own installation instructions.

The goal of this guide is to present the technologies I use for curating my music library, and to save you the cognitive load of researching and deciding what to use. Your needs can and probably will be different from mine and you can always change any part of this system. The one caveat of the setup is that Navidrome really likes albums. If you're listening to the latest singles or underground music that isn't released as albums, Navidrome (and most other services I've used) do not offer great support.

Storage

Copyparty is an excellent general file server. Copyparty is also great for sharing files (you can give your friends access to it) and it can even be mounted as a network drive for easy access from your PC. You could use Copyparty on its own for an okay music streaming experience, but Navidrome is so much better and has support for ratings, favourites and playlists.

I run Copyparty in Docker, with the files mounted on disk in an easy to access location. Navidrome will use the same location as its library.

~/containers/copyparty  # Copypartys directory
~/containers/navidrome  # Navidromes directory
~/files                 # Root of Copyparty
~/files/music           # Music folder in copyparty, root of Navidrome library

Copypartys example compose file works fine. I have made the following modifications

# This file is ~/containers/copyparty/compose.yml

    # Commented out the user line because I'm running rootless Docker.
    # user: "1000:1000"
    volumes:
      - ./cfg:/cfg:z
      - ~/files:/w:z

If you're running behind multiple reverse proxies, connect from the outermost proxy directly to Copypartys port. It makes it work a lot faster and a lot easier.

Navidrome

Navidrome is a music streaming server with a web interface and great compatibility with clients (like Symfonium!).

I run Navidrome in Docker. Make sure to mount a folder from your Copyparty files as Navidromes music library!

# This file is ~/containers/navidrome/compose.yml

    # Commented out the user line because I'm running rootless Docker.
    # user: 1000:1000
    volumes:
      - "./data:/data"
      - "~/files/music:/music:ro"

Navidrome is smart about music, it doesn't care if you reorganize the files, as long as the tags remain the same. If your music doesn't have tags, you will end up with missing files when reorganizing.

Acquiring music

If you have the means, or care about audio quality, purchase your music from the artists directly. Bandcamp is great for this, most artists are on there, at least the ones that release albums.

If you already have a music collection, you can skip to the next or the last section!

I use yt-dlp to get a playlist from YouTube.

# !! This code is for PowerShell, it will not run correctly in CMD or Bash !!

# Remember to upgrade yt-dlp periodically! YouTube fights back against it, so old versions might not work.
pip install --upgrade yt-dlp

# yt-dlp command breakdown:
# --yes-playlist makes yt-dlp download the entire playlist
# -x extracts audio
# --cookies-from-browser reads your session data so to YouTube it looks like you're logged in
# -o sets the output name. You can customize the output in various ways. 
# I recommend at least using %(playlist_index)s at the start of the filename to make tagging easier.
yt-dlp --yes-playlist -x `
--cookies-from-browser firefox `
-o "./%(playlist_title)s/%(playlist_index)s %(uploader)s - %(title)s [%(id)s].%(ext)s" `
https://www.youtube.com/playlist?list=OLAK5uy_nWrBd-n_L0xHfL8lmH-qM9U2cTlKAOQYs

You can further customize yt-dlp with your own config files or scripts.

Be aware that some releases that YouTube recommends by default are actually just normal playlists and can contain music videos. For example, here's the first result for aldn's 'post spring, self destruction' https://www.youtube.com/playlist?list=PLqMQc3fDn2VfmW7DH2i2e-jYJO7UQCEKv. It's all music videos. You do not want to rip music videos as they will often include sound effects or an intro fade in etc. all kinds of things that retract from the listening experience.

You can find the release version of 'post spring, self destruction' by searching for any of the songs on YouTube Music and then clicking on the album name under the controls. Notice that the link of the release playlist https://music.youtube.com/playlist?list=OLAK5uy_kpgxPDEzXpo1S79pzfkd8ziTa5DDHITpM is different from the first one, but if you play it on YouTube Music it will play the music videos from the first one... You have to remove music. from the url to get to the one you actually want to download, eg. https://www.youtube.com/playlist?list=OLAK5uy_kpgxPDEzXpo1S79pzfkd8ziTa5DDHITpM.

All of this is to say, if you can, support the artists and get their music legitimately, it's much easier and more ethical. But if you're not going to buy the album, paying Spotify to give your favourite artists 2 nths of a cent per stream really doesn't move the needle so you might as well download it.

Tagging

MusicBrainz Picard is the best when it comes to tagging albums that are popular enough to be in the MusicBrainz database. Picard can automatically detect songs and set the appropriate tags and even embed the album art.

If you're nerdy (duh?) and care about music enough, you should register on MusicBrainz to be able to add releases that they don't yet have. Please do take care when adding releases on MusicBrainz and get familiar with their terminology and rules. You don't have to add data you don't know, like the barcode or release number of physical CDs you obviously don't have. You can use Harmony to automatically import releases from streaming services (Spotify works the best) into MusicBrainz. Remember, you still have to manually confirm the data.

Once you're logged into MusicBrainz, you can right click and choose "Lookup in Browser" in Picard to make MusicBrainz offer a green "tagger" button, which lets you manually import releases into Picard. This is great for when Picard can't automatically match your songs.

mp3tag is great for individual songs or releases that aren't on MusicBrainz. mp3tag can also add tags by connecting songs to releases, but you have to manually search for the release from either Discogs or MusicBrainz (which you would prefer to use Picard for anyway). I mainly use mp3tag when a release is on Discogs but not on MusicBrainz and I'm too lazy to import it using Harmony... Be better and use Harmony!

If neither program can find your release information, use Genius or YouTube / Spotify to get the information yourself and add it manually per song in mp3tag or Picard.

Uploading

Once you've tagged your tracks, you should upload them into Copyparty. Remember to put the files under /music in Copyparty so Navidrome can find it.

After uploading you can open Navidrome and enjoy your music!

Advanced techniques

Optional tricks you can do with the complete setup.

Mounting Copyparty

You can use rsync to mount Copyparty as a drive, so you can download the albums directly into Copyparty! As in, opening your shell in W:\music and running the yt-dlp commands there!

The Copyparty / rsync documentation is kind of obtuse, so this is what you need. Create %AppData%/Roaming/rclone/rclone.conf and put this in it:

[cpp-rw]
type = webdav
vendor = owncloud
url = <copyparty url, starting with https:// and ending with />
headers = Cookie,cppwd=<your  copyparty password>
pacer_min_sleep = 0.01ms

After creating the file and editing the right information, this command will mount Copyparty as W:\

rclone mount --vfs-cache-mode writes --vfs-cache-max-age 5s --attr-timeout 5s --dir-cache-time 5s cpp-rw: W:

If this doesn't work, you might need to make your Copyparty user have the same name as your Windows user.

Mobile playback

Using Symfonium (it's a premium app, not open source, but it really is the best one), you can connect to your Navidrome instance.

The option "Manage media providers" is under Miscellaneous settings. Add a media provider and choose "(Open) Subsonic)" and enter your Navidrome url and login details.