Over the last couple of days I rediscovered a program I once wrote, App::Muletracks, for downloading albums from your library on https://nugs.net. It didn’t work anymore (which is a chronic malady of inofficial HTML-based clients automating tasks on websites), so I repaired it. Last time I did that, I left it in a library-only state, without writing an interface program to use the library conveniently. (Luckily my shell history is unlimited, so I could recover the perl -Ilib -MApp::Muletracks -E ...
oneliners I used to get the job done at the time.) Today I wrote the interface, too, and therefore the code is usable by others and I can write about it.
Let me say upfront that this program is easily among the most unspectacular ones around. Its main purpose is to automate the login to your user account and click on download links in your library (but it is capable of doing a little extra work). Nugs.net already offer their own downloader which is presumably always up to date with their API. On the other hand, I don’t know anything about it, not even whether it is open source or not, because I never looked at it.
My program actually predates my awareness of Nugs.net. The first commit on it was on January 1, 2018, when I wrote a rather sketchy downloader for my purchases on http://muletracks.com (which explains the name App::Muletracks). That original client was written in Perl 6 (it even predates the renaming of Perl 6 to Raku.) Muletracks was the website where Gov’t Mule (and Warren Haynes solo) would sell their concert recordings. When they switched to Nugs.net and my program became completely broken, I rewrote it in Perl as a general Nugs.net client but kept the original name — even though it is now no longer specific to Gov’t Mule. (I’ve been having a great time with Bruce Springsteen and The E Street Band recently.)
For all I know, Nugs.net has been a godsend. I’ve been a fan of Bluesrock, and whatever adjacent genres call themselves, since my teenage years and since shortly afterwards it has been my firm opinion that the only Blues or Rock that is worth listening to is (recordings of) live concerts. Nugs.net makes those available fast, at a high quality and for a uniform, reasonable price. The purchase is available for download as ordinary files (no proprietary formats, no DRM) and they have always had flawless metadata as well. They are doing a very good job in all the respects that I can observe. In short: I’m a satisfied customer.
The source code of my client can be obtained here: App::Muletracks. At the moment, you have to install it from the source on your own using standard Perl authoring tools (dzil
and cpanm
).
What you get are some modules and a frontend script, muletracks
, which has an interactive prompt:
$ muletracks
Configuration file... $HOME/.config/muletracks/config.yml (empty)
muletracks is ready!
>
You may want to kill the process now and write the configuration file in the indicated location. It is a YAML document containing four keys:
username
: your username / email address on Nugs.netpassword
: the corresponding passworddestination
: the download directory used by the programformat
: the filename templateI pick destination
to be $HOME/muletracks
. This is where all downloaded files end up. If this is not set, the program will operate in the CWD. The format
is a printf-style format string which specifies how to rename downloaded files based on their metadata. The default is my favorite: %(artist)s - %(album)s/(CD%(cd)1d) %(track)02d. %(title)s"
. See below for examples of how the filenames turn out.
With the file written, we can start muletracks
again and view the shows available for download using the list
command:
$ muletracks
Configuration file... $HOME/.config/muletracks/config.yml
muletracks ready!
> list
Login successful.
Found 3 available show(s):
469470 / Dave Matthews Band: 8-19-1993 The Wetlands New York, NY
557769 / Bruce Springsteen & The E Street Band: 8-22-1985 Giants Stadium East Rutherford, NJ
434129 / Bruce Springsteen & The E Street Band: 9-30-1999 United Center Chicago, IL
The program uses your login credentials to log into your Nugs.net account whenever it needs to (and it keeps the session cookies around until it terminates). The number at the beginning of every show is the media ID. This is used to identify shows to download.
> download --cmus-add 469470
Downloading 1 / 1 - 469470 / Dave Matthews Band: 8-19-1993 The Wetlands New York, NY
dmb930819d1_01_Satellite.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 01. Satellite.flac
dmb930819d1_02_Ants_Marching.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 02. Ants Marching.flac
dmb930819d1_03_Granny.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 03. Granny.flac
dmb930819d1_04_Recently.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 04. Recently.flac
dmb930819d1_05_One_Sweet_World.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 05. One Sweet World.flac
dmb930819d1_06_Seek_Up.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 06. Seek Up.flac
dmb930819d1_07_Song_That_Jane_Likes.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 07. Song That Jane Likes.flac
dmb930819d1_08_True_Reflections.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 08. True Reflections.flac
dmb930819d1_09_All_Along_The_Watchtower.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD1) 09. All Along The Watchtower.flac
dmb930819d2_01_Tripping_Billies.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 01. Tripping Billies.flac
dmb930819d2_02_Lie_In_Our_Graves.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 02. Lie In Our Graves.flac
dmb930819d2_03_Warehouse.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 03. Warehouse.flac
dmb930819d2_04_Dancing_Nancies.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 04. Dancing Nancies.flac
dmb930819d2_05_Typical_Situation.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 05. Typical Situation.flac
dmb930819d2_06_Blue_Water.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 06. Blue Water.flac
dmb930819d2_07_The_Best_Of_Whats_Around.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 07. The Best Of What's Around.flac
dmb930819d2_08_Christmas_Song.flac -> $HOME/muletracks/Dave Matthews Band - 1993-08-19 New York, NY/(CD2) 08. Christmas Song.flac
The download
command takes a list of media IDs and gets to work. It downloads all files associated with each media ID from your library and renames them using the embedded tags and the format
configuration key. I want to emphasize again that this works so smoothly only because Nugs.net has a high standard for tagging their files correctly. The --cmus-add
option refers to the cmus
music player which I use. It adds all downloaded and renamed files to your cmus
library at the end.
What I really, really liked about the first version of this client, which interfaced with the old Muletracks site, was that I just had to pipe the purchase confirmation email from mutt
into it and it would find, download, rename the new purchase and add it to my cmus
library without any manual intervention (finding the media ID). This is still missing in this new version — I vaguely remember that the emails from Nugs.net do not contain the necessary information anymore to make it completely automatic but I would have to re-check.