From 212fbf368e38281f45a0d8dd63dc051dbd8cd8cf Mon Sep 17 00:00:00 2001 From: Krateng Date: Wed, 2 Dec 2020 21:08:44 +0100 Subject: [PATCH] Database fixing now finally respects existing separation --- maloja/__pkginfo__.py | 2 +- maloja/cleanup.py | 13 ++++++++++--- .../rules/predefined/krateng_kpopgirlgroups.tsv | 2 ++ maloja/database.py | 2 +- maloja/proccontrol/tasks/fixexisting.py | 4 ++-- maloja/web/jinja/wait.jinja | 4 ++-- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index ca25c7a..409e49f 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -5,7 +5,7 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,10,6 +version = 2,10,7 versionstr = ".".join(str(n) for n in version) links = { "pypi":"malojaserver", diff --git a/maloja/cleanup.py b/maloja/cleanup.py index c34e322..4166010 100644 --- a/maloja/cleanup.py +++ b/maloja/cleanup.py @@ -48,9 +48,12 @@ class CleanerAgent: return (artists,title) def removespecial(self,s): - s = s.replace("\t","").replace("␟","").replace("\n","") - s = re.sub(" +"," ",s) - return s + if isinstance(s,list): + return [self.removespecial(se) for se in s] + else: + s = s.replace("\t","").replace("␟","").replace("\n","") + s = re.sub(" +"," ",s) + return s # if an artist appears in any created rule, we can assume that artist is meant to exist and be spelled like that @@ -67,6 +70,10 @@ class CleanerAgent: def parseArtists(self,a): + if isinstance(a,list): + res = [self.parseArtists(art) for art in a] + return [a for group in res for a in group] + if a.strip() in settings.get_settings("INVALID_ARTISTS"): return [] diff --git a/maloja/data_files/rules/predefined/krateng_kpopgirlgroups.tsv b/maloja/data_files/rules/predefined/krateng_kpopgirlgroups.tsv index 12f3e33..d28d2f2 100644 --- a/maloja/data_files/rules/predefined/krateng_kpopgirlgroups.tsv +++ b/maloja/data_files/rules/predefined/krateng_kpopgirlgroups.tsv @@ -148,6 +148,8 @@ replaceartist 여자친구 GFriend GFriend # Girl's Generation replaceartist 소녀시대 Girls' Generation replaceartist SNSD Girls' Generation +replaceartist Girls' Generation-TTS TaeTiSeo +countas TaeTiSeo Girls' Generation # Apink replaceartist A Pink Apink diff --git a/maloja/database.py b/maloja/database.py index 5d47604..1e2bfa3 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -577,7 +577,7 @@ def incoming_scrobble(artists,title,album=None,duration=None,time=None,fix=True) log("Incoming scrobble (): ARTISTS: " + str(artists) + ", TRACK: " + title,module="debug") if fix: - (artists,title) = cla.fullclean("/".join(artists),title) + (artists,title) = cla.fullclean(artists,title) trackdict = createScrobble(artists,title,time,album,duration) sync() diff --git a/maloja/proccontrol/tasks/fixexisting.py b/maloja/proccontrol/tasks/fixexisting.py index 409918f..e1016d0 100644 --- a/maloja/proccontrol/tasks/fixexisting.py +++ b/maloja/proccontrol/tasks/fixexisting.py @@ -49,7 +49,7 @@ def fix(): a,t = re.sub(exp,r"\3",l), re.sub(exp,r"\5",l) r1,r2,r3 = re.sub(exp,r"\1\2",l),re.sub(exp,r"\4",l),re.sub(exp,r"\6",l) - a = a.replace("␟",";") + a = a.split("␟") (al,t) = wendigo.fullclean(a,t) a = "␟".join(al) @@ -59,7 +59,7 @@ def fix(): #os.system("diff " + "scrobbles/" + fn + "_new" + " " + "scrobbles/" + fn) with open(datadir("scrobbles",filename_new),"r") as newfile, open(datadir("scrobbles",filename),"r") as oldfile: - diff = difflib.unified_diff(oldfile.read().split("\n"),newfile.read().split("\n"),lineterm="") + diff = difflib.unified_diff(oldfile.read().split("\n"),newfile.read().split("\n"),lineterm="",n=0) diff = list(diff) with open(os.path.join(patchfolder,filename + ".diff"),"w") as patchfile: diff --git a/maloja/web/jinja/wait.jinja b/maloja/web/jinja/wait.jinja index a24006a..7ab6351 100644 --- a/maloja/web/jinja/wait.jinja +++ b/maloja/web/jinja/wait.jinja @@ -10,7 +10,7 @@ {% block scripts %}