Added album importing, GH-231

This commit is contained in:
krateng 2023-08-13 04:20:48 +02:00
parent a7e4a869cc
commit 8acf142745
2 changed files with 6 additions and 4 deletions

View File

@ -485,7 +485,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None):
@connection_provider
def get_album_id(albumdict,create_new=True,ignore_albumartists=False,dbconn=None):
ntitle = normalize_name(albumdict['albumtitle'])
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in albumdict.get('artists') or []]
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in (albumdict.get('artists') or [])]
artist_ids = list(set(artist_ids))
op = DB['albums'].select(

View File

@ -80,9 +80,6 @@ def import_scrobbles(inputf):
# extra info
extrainfo = {}
if scrobble.get('album_name'): extrainfo['album_name'] = scrobble['album_name']
# saving this in the scrobble instead of the track because for now it's not meant
# to be authorative information, just payload of the scrobble
scrobblebuffer.append({
"time":scrobble['scrobble_time'],
@ -90,6 +87,11 @@ def import_scrobbles(inputf):
"artists":scrobble['track_artists'],
"title":scrobble['track_title'],
"length":scrobble['track_length'],
"album":{
"albumtitle":scrobble.get('album_name') or None,
"artists":scrobble.get('album_artists') or scrobble['track_artists'] or None
# TODO: use same heuristics as with parsing to determine album?
}
},
"duration":scrobble['scrobble_duration'],
"origin":"import:" + typeid,