I’m trying to create a script to coalesce recording genres into a more general, short list of album genres. For genre sources, I’m using both the Musicbrainz & Wikidata’s servers. My setup options roughly follows @hiccup here.
Using @rdswift’s Persistent Variables plugin, I have successfully created a persistent genre variable that has combined all the genres, but it’s not what I expected. Here’s my code snippet:
$noop(___coalesce genres across tracks___)
$if($lte(%tracknumber%,%totaltracks%),$set_a(_common_genre,$get_a(_common_genre); %genre%))
$set(genre,$if2($get_a(_common_genre),None))
Let’s say five tracks in an album each have unique genres: A, B, C, D, E.
After running that code, the genre for each track changes like this:
- A to “; A; B; C; D; E; A”
- B to “; A; B; C; D; E; A; B”
- C to “; A; B; C; D; E; A; B; C”
- D to “; A; B; C; D; E; A; B; C; D”
- E to “; A; B; C; D; E; A, B, C; D; E”
The new string starts with a semicolon because the _genre_common variable is empty for track 1. Can someone explain what’s happening beyond that? I expected to see “; A; B; C; D; E” for all tracks. It’s as if _genre_common is not static in that final line of code. When I look at the persistent variable via the context menu function, all tracks show _genre_common to equal the lengthy genre value found in the last track.
I can clean this up by making track 1’s ‘genre’ common and achieve my goal, but it’s messy as it stands. Any help would be most appreciated.