1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Some improvements to rule handling

This commit is contained in:
Krateng 2019-04-08 13:38:47 +02:00
parent 441be436c6
commit 1ca459e58e
5 changed files with 30 additions and 19 deletions

View File

@ -14,8 +14,8 @@ class CleanerAgent:
raw = tsv.parse_all("rules","string","string","string")
self.rules_belongtogether = [b for [a,b,c] in raw if a=="belongtogether"]
self.rules_notanartist = [b for [a,b,c] in raw if a=="notanartist"]
self.rules_replacetitle = {b:c for [a,b,c] in raw if a=="replacetitle"}
self.rules_replaceartist = {b:c for [a,b,c] in raw if a=="replaceartist"}
self.rules_replacetitle = {b.lower():c for [a,b,c] in raw if a=="replacetitle"}
self.rules_replaceartist = {b.lower():c for [a,b,c] in raw if a=="replaceartist"}
# we always need to be able to tell if our current database is made with the current rules
self.checksums = utilities.checksumTSV("rules")
@ -61,8 +61,8 @@ class CleanerAgent:
if a.strip() in self.rules_belongtogether:
return [a.strip()]
if a.strip() in self.rules_replaceartist:
return self.rules_replaceartist[a.strip()].split("")
if a.strip().lower() in self.rules_replaceartist:
return self.rules_replaceartist[a.strip().lower()].split("")
@ -91,8 +91,8 @@ class CleanerAgent:
return [a.strip()]
def parseTitle(self,t):
if t.strip() in self.rules_replacetitle:
return self.rules_replacetitle[t.strip()]
if t.strip().lower() in self.rules_replacetitle:
return self.rules_replacetitle[t.strip().lower()]
t = t.replace("[","(").replace("]",")")

View File

@ -125,7 +125,7 @@ def readScrobble(artists,title,time):
def getArtistID(name):
obj = name
objlower = name.lower()
objlower = name.lower().replace("'","")
if objlower in ARTIST_SET:
return ARTISTS_LOWER.index(objlower)
@ -142,7 +142,7 @@ def getTrackID(artists,title):
for a in artists:
artistset.add(getArtistID(name=a))
obj = Track(artists=frozenset(artistset),title=title)
objlower = Track(artists=frozenset(artistset),title=title.lower())
objlower = Track(artists=frozenset(artistset),title=title.lower().replace("'",""))
if objlower in TRACK_SET:
return TRACKS_LOWER.index(objlower)
@ -792,17 +792,11 @@ def build_db():
coa.updateIDs(ARTISTS)
global db_rulestate
db_rulestate = consistentRulestate("scrobbles",cla.checksums)
# load cached images
#loadCache()
#start regular tasks
update_medals()
global db_rulestate
db_rulestate = consistentRulestate("scrobbles",cla.checksums)
log("Database fully built!")

View File

@ -0,0 +1,17 @@
# NAME: Jeremy Soule
# DESC: Fixes various different spellings and mistakes for Jeremy Soule's soundtracks
# MORROWIND
replacetitle Nerevar Rising (Morrowind Title Song) Nerevar Rising
replacetitle Nerevar Rising (Morrowind Title Song Reprise) Nerevar Rising (Reprise)
# OBLIVION
replacetitle Elder Scrolls: Oblivion Reign of the Septims
# SKYRIM
# GUILD WARS
replacetitle Guild Wars Nightfall Theme Land of the Golden Sun
replacetitle Under the Dark Span (Asura Theme) Under the Dark Span
Can't render this file because it has a wrong number of fields in line 5.

View File

@ -22,7 +22,7 @@ replacetitle AS IF IT'S YOUR LAST As If It's Your Last
replacetitle BOOMBAYAH Boombayah
replacetitle WHISTLE Whistle
replacetitle DDU-DU DDU-DU Ddu-Du Ddu-Du
replacetitle PLAYING WITH FIRE Playing With Fire
replacetitle PLAYING WITH FIRE Playing with Fire
replaceartist BLΛƆKPIИK BLACKPINK
# Dal Shabet

Can't render this file because it has a wrong number of fields in line 5.

View File

@ -7,10 +7,10 @@ The first column defines the type of the rule:
This artist will be accepted without further parsing. If you want to replace the spelling, you need a replaceartist entry instead
Second column is the full name of the artist
replacetitle Defines an alternative spelling of a track title that should be replaced.
Second column is the 'wrong' spelling
Second column is the 'wrong' spelling. Capitalization is ignored.
Third column the correct spelling
replaceartist Defines and alternative spelling of an artist that should be replaced
Second column is the 'wrong' spelling
Second column is the 'wrong' spelling. Capitalization is ignored.
Third column the correct spelling. Use ␟ if the spelling should correct to several artists
countas Defines an artist that should be counted together with another artist for chart statistics etc.
This will not change the separation in the database and all effects of this rule will disappear as soon as it is no longer active.