mirror of https://github.com/krateng/maloja.git
Compare commits
3 Commits
515fa69fce
...
1eaba888c7
Author | SHA1 | Date |
---|---|---|
krateng | 1eaba888c7 | |
krateng | 084c7d5a1e | |
krateng | ac498bde73 |
|
@ -23,6 +23,10 @@ minor_release_name: "Soyeon"
|
||||||
- "[Bugfix] Fixed leftover whitespaces when parsing titles"
|
- "[Bugfix] Fixed leftover whitespaces when parsing titles"
|
||||||
- "[Bugfix] Fixed handling of fallthrough values in config file"
|
- "[Bugfix] Fixed handling of fallthrough values in config file"
|
||||||
3.1.3:
|
3.1.3:
|
||||||
|
commit: "f3a04c79b1c37597cdf3cafcd95e3c923cd6a53f"
|
||||||
notes:
|
notes:
|
||||||
- "[Bugfix] Fixed infinite recursion with capitalized featuring delimiters"
|
- "[Bugfix] Fixed infinite recursion with capitalized featuring delimiters"
|
||||||
- "[Bugfix] Fixed favicon display"
|
- "[Bugfix] Fixed favicon display"
|
||||||
|
3.1.4:
|
||||||
|
notes:
|
||||||
|
- "[Feature] Expanded information saved from Listenbrainz API"
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Listenbrainz(APIHandler):
|
||||||
try:
|
try:
|
||||||
metadata = listen["track_metadata"]
|
metadata = listen["track_metadata"]
|
||||||
artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
|
artiststr, titlestr = metadata["artist_name"], metadata["track_name"]
|
||||||
|
additional = metadata.get("additional_info",{})
|
||||||
try:
|
try:
|
||||||
timestamp = int(listen["listened_at"])
|
timestamp = int(listen["listened_at"])
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -62,10 +63,19 @@ class Listenbrainz(APIHandler):
|
||||||
except Exception:
|
except Exception:
|
||||||
raise MalformedJSONException()
|
raise MalformedJSONException()
|
||||||
|
|
||||||
|
extrafields = {
|
||||||
|
# fields that will not be consumed by regular scrobbling
|
||||||
|
# will go into 'extra'
|
||||||
|
k:additional[k]
|
||||||
|
for k in ['release_mbid','artist_mbids','recording_mbid','tags']
|
||||||
|
if k in additional
|
||||||
|
}
|
||||||
|
|
||||||
self.scrobble({
|
self.scrobble({
|
||||||
'track_artists':[artiststr],
|
'track_artists':[artiststr],
|
||||||
'track_title':titlestr,
|
'track_title':titlestr,
|
||||||
'scrobble_time':timestamp
|
'scrobble_time':timestamp,
|
||||||
|
**extrafields
|
||||||
},client=client)
|
},client=client)
|
||||||
|
|
||||||
return 200,{"status":"ok"}
|
return 200,{"status":"ok"}
|
||||||
|
|
|
@ -82,7 +82,7 @@ class CleanerAgent:
|
||||||
|
|
||||||
def parseArtists(self,a):
|
def parseArtists(self,a):
|
||||||
|
|
||||||
if isinstance(a,list):
|
if isinstance(a,list) or isinstance(a,tuple):
|
||||||
res = [self.parseArtists(art) for art in a]
|
res = [self.parseArtists(art) for art in a]
|
||||||
return [a for group in res for a in group]
|
return [a for group in res for a in group]
|
||||||
|
|
||||||
|
@ -156,38 +156,37 @@ class CleanerAgent:
|
||||||
# t = p(t).strip()
|
# t = p(t).strip()
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def parseTitleForArtists(self,t):
|
def parseTitleForArtists(self,title):
|
||||||
for d in self.delimiters_feat:
|
|
||||||
if re.match(r"(.*) [\(\[]" + d + " (.*?)[\)\]]",t,flags=re.IGNORECASE) is not None:
|
|
||||||
(title,artists) = self.parseTitleForArtists(re.sub(r"(.*) [\(\[]" + d + " (.*?)[\)\]]",r"\1",t,flags=re.IGNORECASE))
|
|
||||||
artists += self.parseArtists(re.sub(r"(.*) [\(\[]" + d + " (.*?)[\)\]].*",r"\2",t,flags=re.IGNORECASE))
|
|
||||||
return (title,artists)
|
|
||||||
if re.match(r"(.*) - " + d + " (.*)",t,flags=re.IGNORECASE) is not None:
|
|
||||||
(title,artists) = self.parseTitleForArtists(re.sub(r"(.*) - " + d + " (.*)",r"\1",t,flags=re.IGNORECASE))
|
|
||||||
artists += self.parseArtists(re.sub(r"(.*) - " + d + " (.*).*",r"\2",t,flags=re.IGNORECASE))
|
|
||||||
return (title,artists)
|
|
||||||
if re.match(r"(.*) " + d + " (.*)",t,flags=re.IGNORECASE) is not None:
|
|
||||||
(title,artists) = self.parseTitleForArtists(re.sub(r"(.*) " + d + " (.*)",r"\1",t,flags=re.IGNORECASE))
|
|
||||||
artists += self.parseArtists(re.sub(r"(.*) " + d + " (.*).*",r"\2",t,flags=re.IGNORECASE))
|
|
||||||
return (title,artists)
|
|
||||||
|
|
||||||
artists = []
|
artists = []
|
||||||
|
for delimiter in malojaconfig["DELIMITERS_FEAT"]:
|
||||||
|
for pattern in [
|
||||||
|
r" [\(\[]" + re.escape(delimiter) + " (.*?)[\)\]]",
|
||||||
|
r" - " + re.escape(delimiter) + " (.*)",
|
||||||
|
r" " + re.escape(delimiter) + " (.*)"
|
||||||
|
]:
|
||||||
|
matches = re.finditer(pattern,title,flags=re.IGNORECASE)
|
||||||
|
for match in matches:
|
||||||
|
title = match.re.sub('',match.string) # Remove matched part
|
||||||
|
artists += self.parseArtists(match.group(1)) # Parse matched artist string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if malojaconfig["PARSE_REMIX_ARTISTS"]:
|
if malojaconfig["PARSE_REMIX_ARTISTS"]:
|
||||||
for filter in malojaconfig["FILTERS_REMIX"]:
|
for filter in malojaconfig["FILTERS_REMIX"]:
|
||||||
# match remix in brackets
|
for pattern in [
|
||||||
m = re.match(r".*[\(\[](.*)" + filter + "[\)\]]", t, flags=re.IGNORECASE)
|
r" [\(\[](.*)" + re.escape(filter) + "[\)\]]", # match remix in brackets
|
||||||
if m:
|
r" - (.*)" + re.escape(filter) # match remix split with "-"
|
||||||
artists += self.parseArtists(m.groups()[0])
|
]:
|
||||||
|
match = re.search(pattern,title,flags=re.IGNORECASE)
|
||||||
|
if match:
|
||||||
|
# title stays the same
|
||||||
|
artists += self.parseArtists(match.group(1))
|
||||||
|
|
||||||
|
|
||||||
# match remix split with "-"
|
|
||||||
m = re.match(r".*-(.*)" + filter, t, flags=re.IGNORECASE)
|
|
||||||
if m:
|
|
||||||
artists += self.parseArtists(m.groups()[0])
|
|
||||||
|
|
||||||
for st in self.rules_artistintitle:
|
for st in self.rules_artistintitle:
|
||||||
if st in t.lower(): artists += self.rules_artistintitle[st].split("␟")
|
if st in title.lower(): artists += self.rules_artistintitle[st].split("␟")
|
||||||
return (t,artists)
|
return (title,artists)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue