Choosing cover art from multiple sources and other automations

Continuing the discussion from Feature Request (or tell me if it's possible to do): Use cover art from other release

Hello folks.
I’ve been dealing with the same hassle regarding getting the right cover art for a specific release. So I wanted to share a plugin I have been working on that, while still being WIP and somewhat experimental, I believe can provide a workaround to those of yall willing to get your hands a bit dirty.
If you follow the instructions below, it will allow you to automatically open a page in your browser where you can choose a cover art from several providers and have it downloaded in the album’s folder for each album you tag. (This assumes you keep all tracks of an album in the same folder, otherwise the download should go to the location of the first track you added.) The page will look like this:

If you just want to know how to do it skip to the tutorial section below.

What it does

It lets you add commands that execute after an album or a track has been moved to the right hand pane. The idea comes from @affronttonature in picard-2743. Like they proposed, this can be used to run the COV integration tool found on covers.musichoarders.xyz and automatically search for an album and download a cover art inside an album’s folder with one click.
The goal is to be able to run other scripts/programs and pass things like metadata or file paths as arguments.
But be warned, the code was not reviewed and I would not call this finished yet. I shared it at this stage because I thought some of yall might still find it useful after seeing the linked topic.

Tutorial

I tested this on Linux and Windows, but macOS should fare similar to the former. Download the COV integration tool for Windows, Linux or directly on their website. Download the post tagging actions plugin and install it by going to the plugins page of Picard’s options. After saving, reopen the options page and go to Post Tagging Actions found below the plugins page. You can click the “Add file” button to search for the COV integration tool and add its path to the text field. Then, copy the following into the text field. (Omit the <covit path>)

<covit path> --address covers.musichoarders.xyz --query-artist "%albumartist%" --query-album "%album%" --primary-output "%album_path%/cover"

(For Linux you might want to replace " with ') Check “Wait for process to finish” and click on “Add action”. You can save and now you should be all set. If you want to also automatically apply the cover art to your files, keep reading.
It requires Python and the Mutagen module to be installed. Download this script I pasted together. This is to be considered VERY experimental. There is probably a much better way to do this but I initially wrote it just as a proof of concept for the plugin. (It’s good enough for my own personal use case.) It should work with mp3, ogg, and flac files, though I have not tester the latter thoroughly. Add the following to the text box and replace <script path> with the script’s actual path:

python <script path> --path "%track_path%"

On Windows you might need to replace python with py. Click “Wait for process to finish” and “Execute for tracks”. Then “Add action” and you are good to go. If you also want to remove the image downloaded previously from the folder you can do:
(Linux)

rm '%album_path%'/cover.jpg

(Windows)

cmd /c del "%album_path%\cover.jpg"

Click “Add action” and you are done.

There are still things to be worked on such as improving the UI. I was also considering, instead of running the commands when tagging an album, to make it a context menu action and/or execute after the files are saved.

Thank you for reading all the way through, I apologize for the long post. Anyways, let me know if you find any issues (you probably will) or think anything is missing. This week I’ll be busy with uni exams, but I’ll still find time to answer. Cheers!

7 Likes