1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Implemented and changed more album stuff

This commit is contained in:
krateng 2023-03-28 18:16:15 +02:00
parent 6d55d60535
commit 1086dfee25
4 changed files with 25 additions and 8 deletions

View File

@ -235,6 +235,8 @@ def get_scrobbles_num(dbconn=None,**keys):
result = len(sqldb.get_scrobbles_of_artist(artist=keys['artist'],since=since,to=to,resolve_references=False,dbconn=dbconn))
elif 'track' in keys:
result = len(sqldb.get_scrobbles_of_track(track=keys['track'],since=since,to=to,resolve_references=False,dbconn=dbconn))
elif 'album' in keys:
result = len(sqldb.get_scrobbles_of_album(album=keys['album'],since=since,to=to,resolve_references=False,dbconn=dbconn))
else:
result = sqldb.get_scrobbles_num(since=since,to=to,dbconn=dbconn)
return result
@ -359,6 +361,21 @@ def get_top_tracks(dbconn=None,**keys):
return results
@waitfordb
def get_top_albums(dbconn=None,**keys):
rngs = ranges(**{k:keys[k] for k in keys if k in ["since","to","within","timerange","step","stepn","trail"]})
results = []
for rng in rngs:
try:
res = get_charts_albums(timerange=rng,dbconn=dbconn)[0]
results.append({"range":rng,"album":res["album"],"scrobbles":res["scrobbles"]})
except Exception:
results.append({"range":rng,"album":None,"scrobbles":0})
return results
@waitfordb
def artist_info(dbconn=None,**keys):

View File

@ -166,7 +166,7 @@ def connection_provider(func):
# "artists":list,
# "title":string,
# "album":{
# "title":string,
# "albumtitle":string,
# "artists":list
# },
# "length":None
@ -240,7 +240,7 @@ def albums_db_to_dict(rows,dbconn=None):
return [
{
"artists":artists[row.id],
"title":row.albtitle,
"albumtitle":row.albtitle,
}
for row in rows
]
@ -279,8 +279,8 @@ def artist_dict_to_db(info,dbconn=None):
def album_dict_to_db(info,dbconn=None):
return {
"albtitle":info.get('title'),
"albtitle_normalized":normalize_name(info.get('title'))
"albtitle":info.get('albumtitle'),
"albtitle_normalized":normalize_name(info.get('albumtitle'))
}
@ -441,7 +441,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None):
@cached_wrapper
@connection_provider
def get_album_id(albumdict,create_new=True,dbconn=None):
ntitle = normalize_name(albumdict['title'])
ntitle = normalize_name(albumdict['albumtitle'])
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in albumdict['artists']]
artist_ids = list(set(artist_ids))

View File

@ -28,7 +28,7 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False,forceAlbum=False,api
filterkeys = {"artist":keys.get("artist")}
if "associated" in keys: filterkeys["associated"] = True
elif type == "album":
filterkeys = {"album":{"artists":keys.getall("artist"),"title":keys.get("title") or keys.get("albumtitle")}}
filterkeys = {"album":{"artists":keys.getall("artist"),"albumtitle":keys.get("title") or keys.get("albumtitle")}}
else:
filterkeys = {}
@ -98,7 +98,7 @@ def internal_to_uri(keys):
elif "album" in keys:
for a in keys["album"]["artists"]:
urikeys.append("artist",a)
urikeys.append("albumtitle",keys["album"]["title"])
urikeys.append("albumtitle",keys["album"]["albumtitle"])
#time
if "timerange" in keys:

View File

@ -177,7 +177,7 @@ malojaconfig = Configuration(
},
"Database":{
"album_information_trust":(tp.Choice({'first':"First",'last':"Last"}),"Album Information Authority","first", "Whether to trust the first album information that is sent with a track or update every time a different album is sent"),
"album_information_trust":(tp.Choice({'first':"First",'last':"Last",'majority':"Majority"}), "Album Information Authority","first", "Whether to trust the first album information that is sent with a track or update every time a different album is sent"),
"invalid_artists":(tp.Set(tp.String()), "Invalid Artists", ["[Unknown Artist]","Unknown Artist","Spotify"], "Artists that should be discarded immediately"),
"remove_from_title":(tp.Set(tp.String()), "Remove from Title", ["(Original Mix)","(Radio Edit)","(Album Version)","(Explicit Version)","(Bonus Track)"], "Phrases that should be removed from song titles"),
"delimiters_feat":(tp.Set(tp.String()), "Featuring Delimiters", ["ft.","ft","feat.","feat","featuring"], "Delimiters used for extra artists, even when in the title field"),