From 1ca459e58e21d840c26f4f34b152cdbc514caa31 Mon Sep 17 00:00:00 2001 From: Krateng Date: Mon, 8 Apr 2019 13:38:47 +0200 Subject: [PATCH] Some improvements to rule handling --- cleanup.py | 12 ++++++------ database.py | 14 ++++---------- rules/predefined/krateng_jeremysoule.tsv | 17 +++++++++++++++++ rules/predefined/krateng_kpopgirlgroups.tsv | 2 +- rules/rules.info | 4 ++-- 5 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 rules/predefined/krateng_jeremysoule.tsv diff --git a/cleanup.py b/cleanup.py index 25f88bd..c8660b3 100644 --- a/cleanup.py +++ b/cleanup.py @@ -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("]",")") diff --git a/database.py b/database.py index 35db8dc..556ddfc 100644 --- a/database.py +++ b/database.py @@ -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!") diff --git a/rules/predefined/krateng_jeremysoule.tsv b/rules/predefined/krateng_jeremysoule.tsv new file mode 100644 index 0000000..70e3da8 --- /dev/null +++ b/rules/predefined/krateng_jeremysoule.tsv @@ -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 diff --git a/rules/predefined/krateng_kpopgirlgroups.tsv b/rules/predefined/krateng_kpopgirlgroups.tsv index 754210a..f91eea5 100644 --- a/rules/predefined/krateng_kpopgirlgroups.tsv +++ b/rules/predefined/krateng_kpopgirlgroups.tsv @@ -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 diff --git a/rules/rules.info b/rules/rules.info index 18f16f0..b28e612 100644 --- a/rules/rules.info +++ b/rules/rules.info @@ -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.