Win Beets+SABnzbd: Automate your music tagging
#1
Music 
This guide is for people who want to automate their music tagging from MusicBrainz after downloading from SABnzbd.


Let me begin by saying that if you do not use MusicBrainz data in your tags, then stop reading. I always hated having to open supplimentary tools like Picard to tag my recently acquired music. There is something clunky about downloading with SAB, then opening another program, properly tagging, embedding art etc, then finally moving it into your library. Why can't this be scripted..... ohh wait, it can!

I came across an amazing CLI tool called Beets!. This program is amazingly powerful and down right effective. I won't get into how to install, because the authors of Beets have already made a Getting Started Guide.

Beets does all sorts of amazing things, but for this guide we will focus on just a couple of things when it comes to integration with SABnzbd and some of my preferred Beets settings.

Heres what will happen if you follow this guide:
An album gets downloaded with SABnzbd.
SABnzbd will call on Beets.
Beets will match the album via MusicBrainz and update tags/download cover art/embed cover art and finally move it into your final library folder. If it can't find a suitable match, it will exit gracefully and do nothing.

My Beets Settings:
So I will assume you have at least created the beets config.yaml in the appropriate directory, you did follow the Getting Started Guide right? RIGHT?

Open up the config.yaml with a decent text editor and paste the following below your "library:" line.

Code:
import:
    move: yes
plugins: fetchart embedart
art_filename: folder
id3v23: yes
match:
    strong_rec_thresh: 0.2
    ignored: missing_tracks unmatched_tracks
paths:
    default: $albumartist/$album%aunique{}/$track $title
    comp: Various Artists/$album%aunique{}/$track $title

So what exactly does that config do, lets break it down:

Code:
import:
    move: yes
This will move your MusicBrainz matched albums to your destination directory. (Your final destination directory, based on the paths setting further on)

Code:
plugins: fetchart embedart
art_filename: folder
This enables the plugins fetchart (downloads the album art if available), and places a file named folder(.jpg, .png, etc) within the album directory. The plugin embedart will take that same file and embed it within the file itself.

Code:
id3v23: yes
Quote:By default, beets writes MP3 tags using the ID3v2.4 standard, the latest version of ID3. Enable this option to instead use the older ID3v2.3 standard, which is preferred by certain older software such as Windows Media Player.

Code:
match:
    strong_rec_thresh: 0.2
    ignored: missing_tracks unmatched_tracks

This is where things get interesting....

Quote:The threshold is a distance value between 0.0 and 1.0, so you can think of it as the opposite of a similarity value. For example, if you want to automatically accept any matches above 90% similarity, use:
match:
strong_rec_thresh: 0.10

In my config, I'm using a threshold of 80%, you can obviously change this to a higher rating if you want to make sure your matches are more stringent.
Quote:ignored: missing_tracks unmatched_tracks

So suppose you download an album, it is missing track 16 of an album it has matched on MusicBrainz, It will not do any more processing at that point and intentionally leave the album untouched. Likewise, if it has extra songs that don't match any known release it will not NOT attempt to tag those albums either.

Code:
paths:
    default: $albumartist/$album%aunique{}/$track $title
    comp: Various Artists/$album%aunique{}/$track $title

The paths function will sort your physical files after they have been matched. Feel free to change this if your final folder paths do not match my final layout.


SABnzbd Configuration:

Create a .bat or .cmd file and place it in your SABnzbd "Post Processing Scripts Folder", I named mine beets.bat and my script folder is using Sickbeards "autoProcessTV" folder.

Paste the following into the .bat.
Code:
@echo off
beet import -q "%1"
Image

In your SABnzbd config page, click the Catagories link. Make sure your music catagory/catagories now use your new beets.bat as its post processing script.

Image

Also, it might be worth mentioning to create a temporary music directory (not your final library path) where SAB downloads the music to. In my example, it moves the file to E:\Music (this is not my final library directory). You can do this so that if beets can not find a match it will leave it in that temporary directory so that you can manually tag it, or even better, add the album to MusicBrainz yourself so it can be tagged correctly for others!

So after downloading an album with SAB, it will then call on beets as its post processing script and you should end up with something similar to the following:

Image

Clicking on the View Script Log from SAB, you can see that beets tagged and changed the following tags and also added MusicBrainz MBID data etc.

Code:
E:\Music\Jeff_Beck-Best_of_Beck-CD-FLAC-1995 (14 items)
Correcting tags from:
    Jeff Beck - Best of Beck CD
To:
    Jeff Beck - Best of Beck
(Similarity: 98.6%) (album) (CD, 1995, US, Epic)
* Shapes Of Things              -> Shapes of Things
* Plynth (Water Down The Drain) -> Plynth (Water Down the Drain)
* She's A Woman                 -> She's a Woman

If beets does not find a suitable match, beets will exit gracefully and the SAB script log will say "Skipping" and leave the album untouched and not moved.

That should be it, everything should now work as advertised. Remember, if beets doesn't process the album, its either because the album doesn't exist on MusicBrainz or it did not find a close enough match.
Reply
#2
Updated with some pictures.
Reply
#3
Very cool, I'll give this a shot tonight.
Reply
#4
Looks like a stray colon in your config file.

Reply
#5
Quote:Looks like a stray colon in your config file.

Good catch MadClicker, fixed.
Reply
#6
Thanks for this guide but I wanted to share something that stumped me for a few hours. In order to use the fetchart plugin you need to run the following command:

pip install requests

By default this is not mentioned in the Getting Started Guide. Only when you click on the fetchart plugin do you find this command.
Reply
#7
Addendum to this topic (which was GREAT btw, and has been a huge help!)

To get this working properly with SabNZBD you need to go to Config->Switches->Naming and turn ON "Replace Spaces in Folder Names"
Otherwise you'll get an error in executing the script that it can't find the folder as soon as it hits the space in the name.
Reply
#8
Good catch Dr. Grinch. I had actually set that option a long time ago even before I used Beets.

Just a heads up for Windows beets users, the next update 1.3.7 will fix a nasty bug that deals with "special characters" in the filenames.

It was extrememly annoying if it has happened to you.
Reply
#9
@helta - how is this working out for you? still in use?
Reply
#10
(2014-06-13, 21:46)helta Wrote: Good catch Dr. Grinch. I had actually set that option a long time ago even before I used Beets.

Just a heads up for Windows beets users, the next update 1.3.7 will fix a nasty bug that deals with "special characters" in the filenames.

It was extrememly annoying if it has happened to you.

Hello Helta , i know this a old post but can you help me?

I am using ubuntu , so i need a sh script, to import on sabnzbd, can you help me make one?

Thank you in advice.
Reply

Logout Mark Read Team Forum Stats Members Help
Beets+SABnzbd: Automate your music tagging0