lastgenre: Whitelist/Tree fixes; Default aliases

- Fixes some inconsistencies in spelling in the data files we ship with
  the plugin as well as adds some new genres to both files that seem to
  be returned often by last.fm.
  - For some changes the default aliases feature helps to streamline
    inconsistencies that come from last.fm already.
- The default aliases file that ships with beets
  - Tests fixes that prove that most of the alias normalization patterns
    work as they are supposed to.

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
This commit is contained in:
J0J0 Todos
2026-06-24 07:54:37 +02:00
parent fda3fef148
commit c51f5755f3
4 changed files with 146 additions and 29 deletions

View File

@@ -0,0 +1,72 @@
# Ampersands / Delimiters
drum and bass:
- d(rum)?[ &n/]*b(ass)?
r&b:
- r(hythm)?[ &n/]*b(lues)?
rock and roll:
- rock[- '&n/]*roll
# Hyphenation
\1-\2:
- ([ckj])[- ]*(pop)
- (j)[- ]*(rock)
- (post)[- ]*(\w+)
- (g?lo)[- ]*(fi)
- ([pg])[- ]*(funk)
- (synth)[- ]*(pop)
avant-garde:
- avant[- ]*(garde?)?
# Adding space
\1 \2:
- (nu)[ -]*(disco|jazz|metal|soul)
- (dark)[ -]*(wave)
- (blues|folk|indie|gothic|progressive|alternative|punk)[ -]*(rock)
- (ska)[ -]*(jazz)
- (synth)[- ]*(funk)
- (glitch|hip|trip)y?(?:[ -]*hip)?[ -]*(hop)
# Removing delimiters
\1\2:
- (synth)[- ]*(wave)
- (psy)[ -]*(trance)
- (chill)[ -]*(out)
# Old School spellings: old-school death metal, oldschool hip-hop, old-skool-jungle/-hardcore
old school death metal:
- old[ -]*(?:school|skool)[ -]+death[ -]*metal
old school hip hop:
- old[ -]*(?:school|skool)[ -]+hip[ -]*hop
old school \1:
- old[ -]*(?:school|skool)[ -]+(\w+)
# Terminology / Synonyms
electronic:
- electronic music
world music:
- world
downtempo:
- down[ -]*beat
shoegaze:
- shoegaz(e?r?|ing)
footwork:
- (chicago )?footwork( music)?
juke:
- (chicago )?juke( music| house)?
# Compound genres
alternative rock:
- alt[ -]*rock
# negative lookahead avoids matching 'gothic metal'
gothic rock:
- goth(?!ic)([ -]*rock)?
# avoids matching 'progressive metal'
progressive rock:
- prog([ -]*rock)?
punk rock:
- punk
# psy folk, psych-pop, psychedelic-rock, psychedelic soul, but not psychedelic (standalone)
psychedelic \1:
- psy(?:ch(?:edelic)?)?[ -]*(folk|pop|rock|soul)
dixieland:
- dixieland[ -]*jazz

View File

@@ -257,6 +257,7 @@
- broken beat
- florida breaks
- nu skool breaks
- breaks
- chiptune:
- bitpop
- game boy music
@@ -268,12 +269,12 @@
- disco polo
- euro disco
- italo disco
- nu-disco
- nu disco
- space disco
- downtempo:
- acid jazz
- balearic beat
- chill out
- chillout
- dub music
- dubtronica
- ethnic electronica
@@ -293,7 +294,7 @@
- jungle:
- darkside jungle
- ragga jungle
- oldschool jungle
- old school jungle
- raggacore
- sambass
- techstep
@@ -327,7 +328,7 @@
- indietronica
- new rave
- space rock
- synthpop
- synth-pop
- synthpunk
- electronica:
- berlin school
@@ -358,6 +359,7 @@
- happy hardcore
- hardstyle
- jumpstyle
- old school hardcore
- makina
- speedcore
- terrorcore
@@ -426,6 +428,7 @@
- dub techno
- free tekno
- ghettotech
- industrial techno
- minimal
- nortec
- schranz
@@ -437,9 +440,10 @@
- acid trance
- classic trance
- dream trance
- goa trance:
- psytrance:
- dark psytrance
- full on
- goa trance
- psybreaks
- psyprog
- suomisaundi
@@ -492,8 +496,8 @@
- gangsta rap
- glitch hop
- golden age hip hop
- hardcore hip hop
- hip hop soul
- hip pop
- hyphy
- industrial hip hop
- instrumental hip hop
@@ -620,11 +624,13 @@
- turkish pop
- vispop
- wonky pop
- rhythm and blues:
- r&b:
- funk:
- deep funk
- go-go
- p-funk
- synth funk
- minneapolis sound
- soul:
- blue-eyed soul
- neo soul
@@ -670,6 +676,7 @@
- death/doom
- goregrind
- melodic death metal
- old school death metal
- technical death metal
- doom metal:
- epic doom metal
@@ -708,6 +715,7 @@
- traditional heavy metal
- math rock
- new wave:
- synthwave
- world fusion
- paisley underground
- pop rock
@@ -786,7 +794,7 @@
- chanson
- canción de autor
- nueva canción
- world:
- world music:
- world dub
- world fusion
- worldbeat

View File

@@ -1,5 +1,5 @@
2 tone
2-step garage
2-step
4-beat
4x4 garage
8-bit
@@ -12,10 +12,12 @@ acid rock
acoustic music
acousticana
adult contemporary music
african
african popular music
african rumba
afrobeat
aleatoric music
alternative
alternative country
alternative dance
alternative hip hop
@@ -112,7 +114,7 @@ blue-eyed soul
bluegrass
blues
blues ballad
blues-rock
blues rock
boogie
boogie woogie
boogie-woogie
@@ -123,6 +125,7 @@ brazilian jazz
breakbeat
breakbeat hardcore
breakcore
breaks
breton music
brill building pop
britfunk
@@ -227,6 +230,7 @@ chicano rap
chicha
chicken scratch
children's music
chill
chillout
chillwave
chimurenga
@@ -234,6 +238,7 @@ chinese music
chinese pop
chinese rock
chip music
chiptune
cho-kantrum
chongak
chopera
@@ -336,7 +341,6 @@ dabka
dadra
daina
dalauna
dance
dance music
dance-pop
dance-punk
@@ -349,10 +353,10 @@ danza
danzón
dark ambient
dark cabaret
dark wave
dark pop
darkcore
darkstep
darkwave
de ascultat la servici
de codru
de dragoste
@@ -395,7 +399,6 @@ disney pop
diva house
divine rock
dixieland
dixieland jazz
djambadon
djent
dodompa
@@ -415,6 +418,7 @@ drone metal
drone music
dronology
drum and bass
drumfunk
dub
dub house
dubanguthu
@@ -497,6 +501,7 @@ folk pop
folk punk
folk rock
folktronica
footwork
forró
franco-country
freak-folk
@@ -518,6 +523,7 @@ full on
funaná
funeral doom
funk
funk / soul
funk metal
funk rock
funkcore
@@ -679,6 +685,7 @@ impressionist music
improvisational
incidental music
indian pop
indie
indie folk
indie music
indie pop
@@ -688,12 +695,13 @@ indo jazz
indo rock
indonesian pop
indoyíftika
industrial
industrial death metal
industrial hip hop
industrial metal
industrial music
industrial musical
industrial rock
industrial techno
instrumental rock
intelligent dance music
international latin
@@ -755,6 +763,8 @@ jtek
jug band
jujitsu
juju
juke
juke/footwork
juke joint blues
jump blues
jumpstyle
@@ -968,6 +978,7 @@ min'yo
mineras
mini compas
mini-jazz
minimal
minimal techno
minimalist music
minimalist trance
@@ -1063,7 +1074,7 @@ nintendocore
nisiótika
no wave
noh
noise music
noise
noise pop
noise rock
nongak
@@ -1074,6 +1085,7 @@ nortec
norteño
northern soul
nota
nu disco
nu jazz
nu metal
nu soul
@@ -1083,7 +1095,10 @@ nyatiti
néo kýma
obscuro
oi!
old school death metal
old school hardcore
old school hip hop
old school jungle
old-time
oldies
olonkho
@@ -1190,11 +1205,13 @@ progressive trance
progressive thrash metal
protopunk
psych folk
psychedelic folk
psychedelic music
psychedelic pop
psychedelic rock
psychedelic trance
psychedelic soul
psychobilly
psytrance
punk blues
punk cabaret
punk jazz
@@ -1249,8 +1266,7 @@ renaissance music
requiem
rhapsody
rhyming spiritual
rhythm & blues
rhythm and blues
r&b
ricercar
riot grrrl
rock
@@ -1314,6 +1330,7 @@ shabad
shalako
shan'ge
shango
shangaan electro
shape note
shibuya-kei
shidaiqu
@@ -1328,8 +1345,10 @@ sica
siguiriyas
silat
sinawi
singer-songwriter
situational
ska
ska jazz
ska punk
skacore
skald
@@ -1406,9 +1425,11 @@ symphonic metal
symphonic poem
symphonic rock
symphony
synth-pop
synth funk
synthcore
synthpop
synthpunk
synthwave
t'ong guitar
taarab
tai tu
@@ -1454,6 +1475,7 @@ tinga
tinku
toeshey
togaku
trad
trad jazz
traditional bluegrass
traditional heavy metal

View File

@@ -1039,17 +1039,20 @@ class TestAliases:
[
("dnb", "drum and bass"),
("drum n bass", "drum and bass"),
("r&b", "rhythm and blues"),
("rnb", "rhythm and blues"),
("r&b", "r&b"),
("rnb", "r&b"),
("rock & roll", "rock and roll"),
("rock'n'roll", "rock and roll"),
("kpop", "k-pop"),
("k -pop", "k-pop"),
("j rock", "j-rock"),
("post rock", "post-rock"),
("lofi", "lo-fi"),
("lo fi", "lo-fi"),
("p funk", "p-funk"),
("synth pop", "synthpop"),
("synth funk", "synth funk"),
("synth pop", "synth-pop"),
("synth-wave", "synthwave"),
("avantgarde", "avant-garde"),
("avant gard", "avant-garde"),
("nu-jazz", "nu jazz"),
@@ -1059,11 +1062,11 @@ class TestAliases:
("nu - disco", "nu disco"),
("electronic music", "electronic"),
("world", "world music"),
("chill", "chillout"),
("chill", "chill"),
("chill out", "chillout"),
("chill-out", "chillout"),
("dark wave", "darkwave"),
("dark-wave", "darkwave"),
("dark wave", "dark wave"),
("dark-wave", "dark wave"),
("blues rock", "blues rock"),
("blues-rock", "blues rock"),
("folk-rock", "folk rock"),
@@ -1072,17 +1075,29 @@ class TestAliases:
("shoegazing", "shoegaze"),
("hip-hop", "hip hop"),
("triphop", "trip hop"),
("alt", "alternative rock"),
("punk", "punk rock"),
("alt", "alt"),
("alt rock", "alternative rock"),
("alternative", "alternative rock"),
("alternative", "alternative"),
("goth", "gothic rock"),
("goth rock", "gothic rock"),
("gothic rock", "gothic rock"),
("prog", "progressive rock"),
("prog rock", "progressive rock"),
("progressive rock", "progressive rock"),
("trad", "traditional folk"),
("traditional", "traditional folk"),
("trad", "trad"),
("traditional", "traditional"),
("indie", "indie"),
("indie rock", "indie rock"),
("juke/footwork", "juke/footwork"),
("Funk / Soul", "funk / soul"),
("psy-trance", "psytrance"),
("psy rock", "psychedelic rock"),
("psych-pop", "psychedelic pop"),
("disney", "disney"),
("old-school death-metal", "old school death metal"),
("old-skool-hip-hop", "old school hip hop"),
("old school-jungle", "old school jungle"),
],
)
def test_default_alias_patterns(self, config, input_genre, expected_genre):