This commit is contained in:
krateng 2024-01-20 20:32:50 +01:00
parent c648b25d28
commit ac5c58c919
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ from ._exceptions import *
from .. import database
import datetime
from ._apikeys import apikeystore
from ..database.exceptions import DuplicateScrobble
from ..pkg_global.conf import malojaconfig
@ -25,6 +26,7 @@ class Listenbrainz(APIHandler):
InvalidAuthException: (401, {"code": 401, "error": "Incorrect Authorization"}),
InvalidMethodException: (200, {"code": 200, "error": "Invalid Method"}),
MalformedJSONException: (400, {"code": 400, "error": "Invalid JSON document submitted."}),
DuplicateScrobble: (200, {"status": "ok"}),
Exception: (500, {"code": 500, "error": "Unspecified server error."})
}

View File

@ -360,15 +360,14 @@ def add_scrobbles(scrobbleslist,update_album=False,dbconn=None):
result = dbconn.execute(DB['scrobbles'].select().where(
DB['scrobbles'].c.timestamp == scrobble_entry['timestamp']
)).first()
print("Existing",result)
if result.track_id == scrobble_entry['track_id']:
exists += 1
else:
errors += 1
if errors > 0: log(f"{errors} Scrobbles have not been written to database!",color='red')
if exists > 0: log(f"{exists} Scrobbles have not been written to database (duplicate)", color='orange')
if errors > 0: log(f"{errors} Scrobbles have not been written to database (duplicate timestamps)!", color='red')
if exists > 0: log(f"{exists} Scrobbles have not been written to database (already exist)", color='orange')
return success, exists, errors
@connection_provider