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

Adjusted reparse additions to new branch changes

This commit is contained in:
krateng 2022-04-22 17:25:58 +02:00
parent e9189b8903
commit a8f8d86ec1
2 changed files with 17 additions and 13 deletions

View File

@ -680,6 +680,10 @@ def merge_artists(target_id,source_ids):
@api.post("reparse_scrobble") @api.post("reparse_scrobble")
@authenticated_function(api=True) @authenticated_function(api=True)
@catch_exceptions
def reparse_scrobble(timestamp): def reparse_scrobble(timestamp):
"""Internal Use Only""" """Internal Use Only"""
database.reparse_scrobble(timestamp) result = database.reparse_scrobble(timestamp)
return {
"status":"success"
}

View File

@ -115,23 +115,23 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None):
@waitfordb @waitfordb
def reparse_scrobble(timestamp): def reparse_scrobble(timestamp):
log(f"Reparsing Scrobble {timestamp}") log(f"Reparsing Scrobble {timestamp}")
scrobble = sqldb.get_scrobble(timestamp=timestamp, include_internal=True) scrobble = sqldb.get_scrobble(timestamp=timestamp, include_internal=True)
if not scrobble or not scrobble['rawscrobble']: if not scrobble or not scrobble['rawscrobble']:
return return
scrobbledict = rawscrobble_to_scrobbledict(scrobble['rawscrobble']) scrobbledict = rawscrobble_to_scrobbledict(scrobble['rawscrobble'])
track_id = sqldb.get_track_id(scrobbledict['track']) track_id = sqldb.get_track_id(scrobbledict['track'])
# check if id changed # check if id changed
if sqldb.get_track_id(scrobble['track']) != track_id: if sqldb.get_track_id(scrobble['track']) != track_id:
sqldb.update_scrobble_track_id(timestamp, track_id) sqldb.update_scrobble_track_id(timestamp, track_id)
def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None): def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None):
# raw scrobble to processed info # raw scrobble to processed info
scrobbleinfo = {**rawscrobble} scrobbleinfo = {**rawscrobble}
if fix: if fix:
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'])