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:
parent
6d55d60535
commit
1086dfee25
@ -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))
|
result = len(sqldb.get_scrobbles_of_artist(artist=keys['artist'],since=since,to=to,resolve_references=False,dbconn=dbconn))
|
||||||
elif 'track' in keys:
|
elif 'track' in keys:
|
||||||
result = len(sqldb.get_scrobbles_of_track(track=keys['track'],since=since,to=to,resolve_references=False,dbconn=dbconn))
|
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:
|
else:
|
||||||
result = sqldb.get_scrobbles_num(since=since,to=to,dbconn=dbconn)
|
result = sqldb.get_scrobbles_num(since=since,to=to,dbconn=dbconn)
|
||||||
return result
|
return result
|
||||||
@ -359,6 +361,21 @@ def get_top_tracks(dbconn=None,**keys):
|
|||||||
|
|
||||||
return results
|
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
|
@waitfordb
|
||||||
def artist_info(dbconn=None,**keys):
|
def artist_info(dbconn=None,**keys):
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ def connection_provider(func):
|
|||||||
# "artists":list,
|
# "artists":list,
|
||||||
# "title":string,
|
# "title":string,
|
||||||
# "album":{
|
# "album":{
|
||||||
# "title":string,
|
# "albumtitle":string,
|
||||||
# "artists":list
|
# "artists":list
|
||||||
# },
|
# },
|
||||||
# "length":None
|
# "length":None
|
||||||
@ -240,7 +240,7 @@ def albums_db_to_dict(rows,dbconn=None):
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"artists":artists[row.id],
|
"artists":artists[row.id],
|
||||||
"title":row.albtitle,
|
"albumtitle":row.albtitle,
|
||||||
}
|
}
|
||||||
for row in rows
|
for row in rows
|
||||||
]
|
]
|
||||||
@ -279,8 +279,8 @@ def artist_dict_to_db(info,dbconn=None):
|
|||||||
|
|
||||||
def album_dict_to_db(info,dbconn=None):
|
def album_dict_to_db(info,dbconn=None):
|
||||||
return {
|
return {
|
||||||
"albtitle":info.get('title'),
|
"albtitle":info.get('albumtitle'),
|
||||||
"albtitle_normalized":normalize_name(info.get('title'))
|
"albtitle_normalized":normalize_name(info.get('albumtitle'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ def get_artist_id(artistname,create_new=True,dbconn=None):
|
|||||||
@cached_wrapper
|
@cached_wrapper
|
||||||
@connection_provider
|
@connection_provider
|
||||||
def get_album_id(albumdict,create_new=True,dbconn=None):
|
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 = [get_artist_id(a,dbconn=dbconn) for a in albumdict['artists']]
|
||||||
artist_ids = list(set(artist_ids))
|
artist_ids = list(set(artist_ids))
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False,forceAlbum=False,api
|
|||||||
filterkeys = {"artist":keys.get("artist")}
|
filterkeys = {"artist":keys.get("artist")}
|
||||||
if "associated" in keys: filterkeys["associated"] = True
|
if "associated" in keys: filterkeys["associated"] = True
|
||||||
elif type == "album":
|
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:
|
else:
|
||||||
filterkeys = {}
|
filterkeys = {}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ def internal_to_uri(keys):
|
|||||||
elif "album" in keys:
|
elif "album" in keys:
|
||||||
for a in keys["album"]["artists"]:
|
for a in keys["album"]["artists"]:
|
||||||
urikeys.append("artist",a)
|
urikeys.append("artist",a)
|
||||||
urikeys.append("albumtitle",keys["album"]["title"])
|
urikeys.append("albumtitle",keys["album"]["albumtitle"])
|
||||||
|
|
||||||
#time
|
#time
|
||||||
if "timerange" in keys:
|
if "timerange" in keys:
|
||||||
|
@ -177,7 +177,7 @@ malojaconfig = Configuration(
|
|||||||
|
|
||||||
},
|
},
|
||||||
"Database":{
|
"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"),
|
"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"),
|
"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"),
|
"delimiters_feat":(tp.Set(tp.String()), "Featuring Delimiters", ["ft.","ft","feat.","feat","featuring"], "Delimiters used for extra artists, even when in the title field"),
|
||||||
|
Loading…
Reference in New Issue
Block a user