mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Merge branch 'feature-albums' into next_minor_version
This commit is contained in:
commit
6bb7f13ca3
@ -26,6 +26,7 @@ class CleanerAgent:
|
|||||||
self.rules_belongtogether = [r[1] for r in rawrules if r[0]=="belongtogether"]
|
self.rules_belongtogether = [r[1] for r in rawrules if r[0]=="belongtogether"]
|
||||||
self.rules_notanartist = [r[1] for r in rawrules if r[0]=="notanartist"]
|
self.rules_notanartist = [r[1] for r in rawrules if r[0]=="notanartist"]
|
||||||
self.rules_replacetitle = {r[1].lower():r[2] for r in rawrules if r[0]=="replacetitle"}
|
self.rules_replacetitle = {r[1].lower():r[2] for r in rawrules if r[0]=="replacetitle"}
|
||||||
|
self.rules_replacealbumtitle = {r[1].lower():r[2] for r in rawrules if r[0]=="replacealbumtitle"}
|
||||||
self.rules_replaceartist = {r[1].lower():r[2] for r in rawrules if r[0]=="replaceartist"}
|
self.rules_replaceartist = {r[1].lower():r[2] for r in rawrules if r[0]=="replaceartist"}
|
||||||
self.rules_ignoreartist = [r[1].lower() for r in rawrules if r[0]=="ignoreartist"]
|
self.rules_ignoreartist = [r[1].lower() for r in rawrules if r[0]=="ignoreartist"]
|
||||||
self.rules_addartists = {r[2].lower():(r[1].lower(),r[3]) for r in rawrules if r[0]=="addartists"}
|
self.rules_addartists = {r[2].lower():(r[1].lower(),r[3]) for r in rawrules if r[0]=="addartists"}
|
||||||
@ -188,9 +189,14 @@ class CleanerAgent:
|
|||||||
if st in title.lower(): artists += self.rules_artistintitle[st].split("␟")
|
if st in title.lower(): artists += self.rules_artistintitle[st].split("␟")
|
||||||
return (title,artists)
|
return (title,artists)
|
||||||
|
|
||||||
|
def parseAlbumtitle(self,t):
|
||||||
|
if t.strip().lower() in self.rules_replacealbumtitle:
|
||||||
|
return self.rules_replacealbumtitle[t.strip().lower()]
|
||||||
|
|
||||||
|
t = t.replace("[","(").replace("]",")")
|
||||||
|
|
||||||
|
t = t.strip()
|
||||||
|
return t
|
||||||
|
|
||||||
|
|
||||||
def flatten(lis):
|
def flatten(lis):
|
||||||
|
@ -144,8 +144,14 @@ def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None):
|
|||||||
scrobbleinfo['track_artists'],scrobbleinfo['track_title'] = cla.fullclean(scrobbleinfo['track_artists'],scrobbleinfo['track_title'])
|
scrobbleinfo['track_artists'],scrobbleinfo['track_title'] = cla.fullclean(scrobbleinfo['track_artists'],scrobbleinfo['track_title'])
|
||||||
if scrobbleinfo.get('album_artists'):
|
if scrobbleinfo.get('album_artists'):
|
||||||
scrobbleinfo['album_artists'] = cla.parseArtists(scrobbleinfo['album_artists'])
|
scrobbleinfo['album_artists'] = cla.parseArtists(scrobbleinfo['album_artists'])
|
||||||
|
if scrobbleinfo.get("album_title"):
|
||||||
|
scrobbleinfo['album_title'] = cla.parseAlbumtitle(scrobbleinfo['album_title'])
|
||||||
scrobbleinfo['scrobble_time'] = scrobbleinfo.get('scrobble_time') or int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
scrobbleinfo['scrobble_time'] = scrobbleinfo.get('scrobble_time') or int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||||
|
|
||||||
|
# if we send [] as albumartists, it means various
|
||||||
|
# if we send nothing, the scrobbler just doesnt support it and we assume track artists
|
||||||
|
if 'album_artists' not in scrobbleinfo:
|
||||||
|
scrobbleinfo['album_artists'] = scrobbleinfo.get('track_artists')
|
||||||
|
|
||||||
# processed info to internal scrobble dict
|
# processed info to internal scrobble dict
|
||||||
scrobbledict = {
|
scrobbledict = {
|
||||||
|
@ -309,6 +309,8 @@ def parse_lastfm(inputf):
|
|||||||
'scrobble_time': int(datetime.datetime.strptime(
|
'scrobble_time': int(datetime.datetime.strptime(
|
||||||
time + '+0000',
|
time + '+0000',
|
||||||
"%d %b %Y %H:%M%z"
|
"%d %b %Y %H:%M%z"
|
||||||
|
# lastfm exports have time in UTC
|
||||||
|
# some old imports might have the wrong time here!
|
||||||
).timestamp()),
|
).timestamp()),
|
||||||
'scrobble_duration':None
|
'scrobble_duration':None
|
||||||
},'')
|
},'')
|
||||||
|
Loading…
Reference in New Issue
Block a user