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

Added descriptions to API return dicts

This commit is contained in:
krateng 2022-04-22 18:36:06 +02:00
parent 009d77a75e
commit d208290956
3 changed files with 16 additions and 6 deletions

View File

@ -458,7 +458,8 @@ def post_scrobble(
'track': {
'artists':result['track']['artists'],
'title':result['track']['title']
}
},
'desc':f"Scrobbled {result['track']['title']} by {','.join(result['track']['artists'])}"
}
if extra_kwargs:
responsedict['warnings'] = [
@ -684,6 +685,12 @@ def merge_artists(target_id,source_ids):
def reparse_scrobble(timestamp):
"""Internal Use Only"""
result = database.reparse_scrobble(timestamp)
if result:
return {
"status":"success"
}
else:
return {
"status":"no-operation",
"desc":"No action was taken."
}

View File

@ -119,7 +119,7 @@ def reparse_scrobble(timestamp):
scrobble = sqldb.get_scrobble(timestamp=timestamp, include_internal=True)
if not scrobble or not scrobble['rawscrobble']:
return
return False
newscrobble = rawscrobble_to_scrobbledict(scrobble['rawscrobble'])
@ -128,6 +128,9 @@ def reparse_scrobble(timestamp):
# check if id changed
if sqldb.get_track_id(scrobble['track']) != track_id:
sqldb.edit_scrobble(timestamp, {'track':newscrobble['track']})
return True
return False
def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None):

View File

@ -41,7 +41,7 @@ function notifyCallback(request) {
if (status == 200) {
var notification_type = 'info';
var title = "Success!";
var msg = "Scrobbled " + body.track.title + " by " + body.track.artists.join(", ");
var msg = body.desc || body;
}
else {
var notification_type = 'warning';