diff --git a/maloja/apis/listenbrainz.py b/maloja/apis/listenbrainz.py index 6cc77b6..2040099 100644 --- a/maloja/apis/listenbrainz.py +++ b/maloja/apis/listenbrainz.py @@ -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."}) } diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index dfeb217..bdc73f4 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -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