I have tweaked the script and added settings for retrieving top artist genres using the Last.fm API.
Core Functionality
-
The script queries the Last.fm artist.gettoptags API to retrieve artist tags.
-
It maps the returned top tags directly to the Genre field.
-
The script automatically capitalizes the first letter of each tag name returned by Last.fm.
Configurable Settings
The script includes a built-in settings page to adjust the output format:
-
Maximum number of genres: Defines how many top tags to write to the Genre field. Available options are 1, 2, 3, 4, 5, and 10. The default limit is 3.
-
Separator: Defines the characters used to separate multiple genres. Available options are ; , , , /, \\, and |. The default separator is ; .
Let me know if anyone is interested in testing this or integrating it into their workflow.
Script - Last.fm#S - Last.fm Genres.src
# โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
#โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค W E B S O U R C E โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
#โ โฐโโโโฎ โขโโโโ ๎ฉฆ โโโโโข โญโโโโฏ โ
#โ โขโโโโโโโโขโโโโโโโโขโโโโโโโโข โ M P 3 T A G โ โขโโโโโโโโขโโโโโโโโขโโโโโโโโข โ
#โ โฐโโโโโโโโโโโโโโโโโโโโฏ โ
#โ โ
#โ โโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโ โ
#โ โโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ โ
#โ โโโ โโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโโโโโโโโโ โ
#โ โโโ โโโโโโโโโโโโโโโโ โโโ โโโโโโ โโโโโโโโโโโ โ
#โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโ โโโ โโโ โโโ โ
#โ โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโ โโโ โโโ โ
#โ โโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
#โ โโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
#โ โโโ โโโโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโโ โ
#โ โโโ โโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโ โ
#โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
#โ โโโโโโโ โโโโโโโโโโโ โโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
#โ โ
#โ https://github.com/deathrashed/mp3tag โ
#โ โ
#โ Last.fm artist top tags genre retrieval script for Mp3tag โ
#โ โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข โ
#โ configurable genre limit โข customizable separators โข unified configuration โ
#โ โ
#โ โญโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
#โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค L A S T U P D A T E D โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
# โฐโโโโโโโโโโโโโกโโโโโโโโโโโโฏ
# July 18, 2026
# Mp3tag Web Source for Last.fm Top Tag
# Gets Last.fm artist tags as Genre based on settings
[Name]=Last.fm Genres v2
[BasedOn]=www.last.fm
[AlbumUrl]=https://ws.audioscrobbler.com/2.0/?method=artist.gettoptags&artist=%s&api_key=YOUR_API_KEY&format=xml
[WordSeperator]=+
[SearchBy]=$replace(%artist%,/,'%'252F,&,'%'2526)
[Encoding]=url-utf-8
[Settings]=Last.fm#Settingsโฆ.settings
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
# ALBUM PARSER
# - Queries Last.fm artist.gettoptags API and maps top tags to Genre.
# - Returns: Genre (configurable count and separator)
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
[ParserScriptAlbum]=...
#debug "on" "debug_lastfm_genres.html"
findline "<?xml"
joinuntil "</lfm>"
# Check valid Last.fm response
findinline "<lfm status=\"ok\">"
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
# SEPARATOR INIT
# - Buffers the chosen separator into a temp variable for reuse between genres.
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
outputto "_TEMP_SEP"
IfVar "genreSeparator" "; "
say "; "
EndIf
IfVar "genreSeparator" ", "
say ", "
EndIf
IfVar "genreSeparator" " / "
say " / "
EndIf
IfVar "genreSeparator" " \\\\ "
say " \\\\ "
EndIf
IfVar "genreSeparator" "|"
say "|"
EndIf
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
# CAPITALIZE GENRES
# - Uppercases the first letter of each tag name returned by Last.fm.
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
replace "<name>a" "<name>A"
replace "<name>b" "<name>B"
replace "<name>c" "<name>C"
replace "<name>d" "<name>D"
replace "<name>e" "<name>E"
replace "<name>f" "<name>F"
replace "<name>g" "<name>G"
replace "<name>h" "<name>H"
replace "<name>i" "<name>I"
replace "<name>j" "<name>J"
replace "<name>k" "<name>K"
replace "<name>l" "<name>L"
replace "<name>m" "<name>M"
replace "<name>n" "<name>N"
replace "<name>o" "<name>O"
replace "<name>p" "<name>P"
replace "<name>q" "<name>Q"
replace "<name>r" "<name>R"
replace "<name>s" "<name>S"
replace "<name>t" "<name>T"
replace "<name>u" "<name>U"
replace "<name>v" "<name>V"
replace "<name>w" "<name>W"
replace "<name>x" "<name>X"
replace "<name>y" "<name>Y"
replace "<name>z" "<name>Z"
replace " a" " A"
replace " b" " B"
replace " c" " C"
replace " d" " D"
replace " e" " E"
replace " f" " F"
replace " g" " G"
replace " h" " H"
replace " i" " I"
replace " j" " J"
replace " k" " K"
replace " l" " L"
replace " m" " M"
replace " n" " N"
replace " o" " O"
replace " p" " P"
replace " q" " Q"
replace " r" " R"
replace " s" " S"
replace " t" " T"
replace " u" " U"
replace " v" " V"
replace " w" " W"
replace " x" " X"
replace " y" " Y"
replace " z" " Z"
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
# GENRE OUTPUT (limit 1 โ 10, controlled by Settings)
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
outputto "Genre"
findinline "<name>"
sayuntil "</name>"
# Genre 2
IfVar "genreLimit" "2"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
endif
EndIf
# Genre 3
IfVar "genreLimit" "3"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
endif
endif
EndIf
# Genre 4
IfVar "genreLimit" "4"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
endif
endif
endif
EndIf
# Genre 5
IfVar "genreLimit" "5"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
endif
endif
endif
endif
EndIf
# Genre 10
IfVar "genreLimit" "10"
do
findinline "</tag>" 1 1
if "<tag"
sayoutput "_TEMP_SEP"
findinline "<name>"
sayuntil "</name>"
endif
while "<tag" 8
EndIf
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
# CLEANUP
# - Clears temp variables to prevent leakage into other tag fields.
#โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโข
set "_TEMP_SEP"
Settings - Last.fm#Settingsโฆ.settings
{
"key": "lastfm",
"title": "Last.fm Genres Settings",
"settings": [
{
"type": "string",
"key": "genreLimit",
"title": "Maximum number of genres",
"description": "How many Top Tags from Last.fm to write to the Genre field",
"choices": [
"1",
"2",
"3",
"4",
"5",
"10"
],
"default": "3"
},
{
"type": "string",
"key": "genreSeparator",
"title": "Separator",
"description": "Characters used to separate multiple genres",
"choices": [
"; ",
", ",
" / ",
" \\\\ ",
"|"
],
"default": "; "
}
]
}