You are a happy macOS user, and you've successfully survived the transition from iTunes to the new Music app, introduced with macOS Catalina last year. You might like the interface, the scriptabilty, or you simply need Music to sync music to your iPhone or iPad, or stream to your AppleTV. If you have a sizeable music library, you will probably recognise these scenarios:
- You have an awesome disco compilation that was released in 2018, but contains tracks from 1975-1985. Tagging these tracks with 2018 makes little sense: your smart playlist of "70s Disco" will not pick these tracks up, and instead these tunes show up between modern songs by Jessie Ware and Dua Lipa.
- You have ripped your cherished red and blue Beatles best-of CDs, released in 1993. To your frustration, these songs keep appearing in your "90s Rock" playlists.
- You have a big folder of loose tracks you downloaded on Napster back in the 1990s because you loved the videos on MTV! But they have no genre or year tags. So none of these songs ever get included in your Genre or Decade playlists, and this makes you sad.
- You have a compilation album with collected hit singles, but they're pretty diverse: Pop, Punk Rock, Hip-Hop, House, Reggaeton. But unfortunately, all songs are tagged with the same genre(s).
- You've started using a new music player that supports multiple genres, but all your tracks are tagged with one genre.
- You might have tried auto-tagging genres with some tagger using last.fm or MusicBrainz but you've found out that the genres in those databases are all over the place.
Clearly, for search/filter/smart playlists to work as expected, these songs need to be tagged with their original release year, and preferably, the genre of the specific song. But looking up every single song, checking its original release year and genre(s), and writing that in the tags is tedious manual work. MusicBrainz Picard is pretty awesome, but will still tag (most) compilation album tracks with the release date of the album, not the years when the original singles were released. Genres also only go on the album level. This is where this script comes in: it will try to find the original single on Discogs, and tag the song with that year and its specific genre(s).
- Create new script in macOS Script Editor
- Copy/paste the code from DiscogsYearGenres.txt to the new Applescript
- Replace the text
please_insert_your_own_API_key_here
in theQueryDiscogs
function with your own Discogs API key (you need to set up a Discogs account if you haven't got one) - If you are on macOS Mojave or older, you still have iTunes. Replace the
tell application "Music"
line withtell application "iTunes"
- Save the script as
Discogs Year and Genres.scpt
- Put this file in
/Library/Music/Scripts
(all users) or/User/johndoe/Library/Music/Scripts
(one user). If the folder doesn't exist, create it. (note: for iTunes users, the folder isLibrary/iTunes/Scripts
) - When you open Music, there's now a scripts dropdown menu in the top menu bar between
Window
andHelp
- You select one or more songs in Music, you run the script
Discogs Year and Genres
- You choose to write Year, Genre or both
- Choose Genre: the script will the prompt you for each track for the Genre to write. One Genre (Auto) the script will write only one Genre. Multiple Genres (Auto): the script will write all genres and styles in the Genre field, separated by semicolons, for example
Pop;New Wave;Synthpop
- The script can optionally write the
"Artist - Release"
of the Discogs item into the Comments field, so you can check afterwards which master release this year came from.
- The script performs a Discogs search for
Artist SongTitle
for the 'master release' of the single, gets back the Year, Genres and Styles. - The script writes the tags. If you've chosen Choose Genre and Discogs has more than one Genre/Style for the release, you will get a popup to pick which Genre to apply (note: yes 3 items max - blame Apple since AppleScript dialog boxes max out at three buttons)
- and shows a dialog at the end how many songs were updated
- The Year and Genre are updated
Note 1: even though this Discogs search query specifies that only singles should be included in the search, in fact Discogs seems to ignore this, and will also return years from albums, compilations etc. Hence, the script optionally writes the Discogs "Artist - Release" to the comments field, so you can check where the hell Discogs got that year from. This script is not perfect, various things can make the search not return the 'correct' master release: special characters, misspellings, multiple artists, etc. Feel free to tweak the code to make these searches more reliable.
Note 2: I am aware that semicolons as genre separators are non-standard. Technically, multiple genres are not allowed at all in id3v2.3, and are defined as null-separated strings in id3v2.4. However, a) while non-standard, semicolon-separated multiple genres are nonetheless supported by many other players (such as Windows Media Player, Kodi, Plex, MusicBee, Emby, foobar2000 and DBPowerAmp), and b) neither iTunes nor Apple's Music app can handle null-separated genres (more precise: if the id3v2.4 tag is UTF-8 encoded, multiple genres look like this: RockPopReggae
, it the tag is ISO-8859-1 encoded it will display only the first genre Rock
). Apple developers should hang their heads in shame, it's twenty (!) years after id3v2.4 was published and they still can't be bothered to implement it correctly. So for tagging in Music, the choice is to either tag one genre, or tag multiple genres with another separator. I might implement 'proper' null-separated genres in the future, but first I'd have to figure out a way in Applescript to detect if a tag is UTF-8 encoded id3v2.4.
Note 3 This is not a fast script. Discogs only allows 60 requests per minute for their API, so the code intentionally has a 1 second delay per track built in. If you let this script loose on big selections, go grab a cup of coffee, walk your dog, look at cat pictures on the internet.