Added addartists rule type

This commit is contained in:
Krateng 2019-10-24 04:03:44 +02:00
parent a8a15826c3
commit 580350c1d6
5 changed files with 24 additions and 8 deletions

View File

@ -11,12 +11,16 @@ class CleanerAgent:
self.updateRules()
def updateRules(self):
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.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"}
self.rules_ignoreartist = [b.lower() for [a,b,c] in raw if a=="ignoreartist"]
raw = tsv.parse_all("rules","string","string","string","string")
self.rules_belongtogether = [b for [a,b,c,d] in raw if a=="belongtogether"]
self.rules_notanartist = [b for [a,b,c,d] in raw if a=="notanartist"]
self.rules_replacetitle = {b.lower():c for [a,b,c,d] in raw if a=="replacetitle"}
self.rules_replaceartist = {b.lower():c for [a,b,c,d] in raw if a=="replaceartist"}
self.rules_ignoreartist = [b.lower() for [a,b,c,d] in raw if a=="ignoreartist"]
self.rules_addartists = {c.lower():(b.lower(),d) for [a,b,c,d] in raw if a=="addartists"}
#self.rules_regexartist = [[b,c] for [a,b,c,d] in raw if a=="regexartist"]
#self.rules_regextitle = [[b,c] for [a,b,c,d] in raw if a=="regextitle"]
# TODO
# we always need to be able to tell if our current database is made with the current rules
self.checksums = utilities.checksumTSV("rules")
@ -28,6 +32,12 @@ class CleanerAgent:
title = self.parseTitle(self.removespecial(title))
(title,moreartists) = self.parseTitleForArtists(title)
artists += moreartists
if title.lower() in self.rules_addartists:
reqartists, allartists = self.rules_addartists[title.lower()]
reqartists = reqartists.split("")
allartists = allartists.split("")
if set(reqartists).issubset(set(a.lower() for a in artists)):
artists += allartists
artists = list(set(artists))
artists.sort()

2
maloja
View File

@ -302,7 +302,7 @@ def update():
returnval = os.system("./update_requirements.sh")
assert returnval == 0
except:
print("Make sure to update required modules! (" + yellow("bash update_requirements.sh") + ")")
print("Make sure to update required modules! (" + yellow("./update_requirements.sh") + ")")
if stop(): start() #stop returns whether it was running before, in which case we restart it

View File

@ -1,6 +1,6 @@
bottle>=0.12.16
waitress>=1.3
doreah>=1.0
doreah>=1.1.7
nimrodel>=0.4.9
setproctitle>=1.1.10
wand>=0.5.4

View File

@ -16,6 +16,7 @@ replacetitle Cause I'm God Girl Roll Deep
countas 2Yoon 4Minute
replaceartist 4minute 4Minute
replacetitle 미쳐 Crazy
addartists HyunA Change Jun Hyung
# BLACKPINK
countas Jennie BLACKPINK

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

View File

@ -16,6 +16,10 @@ The first column defines the type of the rule:
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.
Second column is the artist
Third column the replacement artist / grouping label
addartists Defines a certain combination of artists and song title that should always have other artists added.
Second column is artists that need to be already present for this rule to apply
Third column is the song title
Fourth column are artists that shoud be added, separated by ␟
Rules in non-tsv files are ignored. '#' is used for comments. Additional columns are ignored. To have a '#' in a name, use '\num'
Comments are not supported in scrobble lists, but you probably never edit these manually anyway.
@ -30,3 +34,4 @@ replacetitle 첫 사랑니 (Rum Pum Pum Pum) Rum Pum Pum Pum
replaceartist Dal Shabet Dal★Shabet
replaceartist Mr FijiWiji, AgNO3 Mr FijiWiji␟AgNO3 # one artist is replaced by two artists
countas Trouble Maker HyunA
addartists HyunA Change Jun Hyung