I would like each and every album to just have 1 genre tag, even if it ends up slightly inaccurate, I prefer to browse music like this. I see a few albums with “different across multiple items” - is it possible to override this and have it set 1 main genre for such items?
Do you want to provide the override manually, or try to get it automatically (e.g. the genre from the first track on the album)? Also, do you want to replace the genre tag in the files or just use this for file naming?
Okay, I haven’t tested this, but you might be able to achieve your desired result using the following…
First, from the Genres section of the Metadata Options, set the maximum number of genres to 1. You might also want to enable the “Fall back on album’s artists genres…” setting. This will help ensure that you end up with one and only one genre per track (although they may still be different between tracks at this point).
Next, install and enable the Persistent Variables plugin from the Plugins Options page in Picard. This will provide the functions necessary to create and retrieve a variable with a value common to all tracks on a release.
EDIT: Note that you need to use the “Make It So!” button to save your changes and activate the plugin before proceeding to adding the new scripts.
The third step is to create a new tagging script in the Scripting Options page. The script should be enabled (checked) and the “Enable Tagger Script(s)” option should also be checked. The script should contain the following:
This script retrieves the value of the %genre% tag from the first track on the first CD and stores it in a special album-level variable called _common_genre.
Now create another tagging script after (below) the one just created, and make sure that it is also enabled. This new script should contain the following:
$set(genre,$if2($get_a(_common_genre),None))
This script retrieves the value of the album-level variable _common_genre saved in the first script, and stores it in the %genre% tag for each of the tracks in the album. If there was no genre found for the first track of the first disc, the %genre% tag will be set to “None”. If you would like a different default genre value to be used, simply replace “None” in the second script with your preferred default.
As I said earlier, I haven’t tested this so please let me know if it it works for you or if you run into any problems. Thanks.
Hi @rdswift. I’m hopping on this old thread to ask if your script could be adapted to have, say, the 3 most common genres (or 2 or 4 or whatever) applied to all tracks on an album.
I certainly prefer to keep genres simple, but paring it all the way down to just 1 would give me a whole lot of “rock” . Stepping into a bit of detail would give me some variety at least.
As well, I’m not a fan of each track on an album potentially having differing genres. To me, that’s the other end of the spectrum, feeling over-done and too-much-information.
So, I bumped into this thread researching options, and if I’m correct, I might just need a modified version of what you came up with above?
You might be able to get some ideas from the discussion in Script to create an album genre from its various recording genres. That should help you get the most common genres from each of the tracks to find the common ones on the album. Once you have that, you can use another tagging script to assign those genres to each of the tracks (replacing the current %genre% tag).
Multi-value variables have the elements separated by a semicolon and space when they are displayed in Picard. If it is a true multi-value it is stored as an array, and different applications might display the values differently. You can also convert the multi-value to a single string, using whatever separators you like, for those applications that don’t properly handle the real multi-value array.
I like what was done with the tagger scripts in that other thread to tidy up genres, but I do think outputting genres as separate items would be more useful and versatile.
Happy to start a new topic if you like, and post what I have. It’s only had a couple of changes to comments and typos.
Not sure how difficult it would be to take that earlier work and version it in this different way.
I’ve only played with it a bit so far, but Plex / Plexamp in particular seems to read the multi-genre tag as a genre just fine… but you can’t really search for the separate terms inside it, rendering it only useful for presentation.
So I suppose the primary thing for me is simply not having multiple genres within a single album. Having the 5 most common ones, that’s great too.
Plex does not handle multi-value tags well. The best way to ensure they will be readable and listed as separate, searchable items is to “flatten” them once any scripting done to this tag is complete by placing the following at the bottom of any script that modifies the genre tag:
Adding that single line as one final script does indeed do the job, and I can see Plex recognizing genres in a useful way now, so thanks @rhetticent for speaking up with that.
Now, it feels like a very long way around to compact all the genres down, just to separate them back out at the end… however, there’s lots of other good work along the way here (identifying and putting to use the most commonly used genres, as well as tidying up albums that have a smattering of different genres across different tracks).
If there’s a more straightforward approach overall, I’d be happy to open another topic to discuss that. That said, this does get me what I wanted.
To recap, and for my own notes, this is where I ended up. I have disabled (and not included below) two of the original scripts (clean genres and sort genres) for now at least.
Script A: Create Persistent Variable Of Aggregated Genres
Script C: Count And Save Frequency Of Recording Genres
$noop(___Script C: Count And Save Frequency Of Recording Genres___)
$if(%_genre_count_processed%,,
$foreach($get(_aggregate_genre),
$set(_genre_key,_Genre '%_loop_value%' count)
$set(%_genre_key%,$add($if2($get(%_genre_key%),0),1))
$unset(_genre_key)
,; )
)
$set(_genre_count_processed,1)
Script D: Create Album Genre From Genre Counts
$noop(___Script D: Create Album Genre From Genre Counts___)
$if(%_album_genre_processed%,,
$foreach($get(_aggregate_genre),
$if($gte($mul($get(_Genre '%_loop_value%' count),2),%_totalalbumtracks%),
$if($not(%_album_genre%),$setmulti(_album_genre,%_loop_value%),
$copymerge(_album_genre,_loop_value))
)
)
)
$set(genre,%_album_genre%)
$set(_album_genre_processed,1)
Script E and F (Clean Genres and Sort Genres) SKIPPED FOR NOW
Script G: Separate Multi-Genres Back Out to Individuals
$noop(___Script G: Separate Multi-Genres Back Out to Individuals___)
$set(genre,%genre%)