From f04f8b04c0b63bc3c35bfe1bf5a30b5ebdcd9db5 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 2 Apr 2023 22:37:56 -0400 Subject: [PATCH] Ooops, need to pop after updating --- vrobbler/apps/scrobbles/models.py | 10 ++++------ vrobbler/apps/scrobbles/utils.py | 7 ++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 5d7510d..9e7a505 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -608,12 +608,7 @@ class Scrobble(TimeStampedModel): # but we also don't want to create new videos, so in # this special case, we allow jellyfin resumed status # to allow a scrobble to be updated. - jellyfin_in_progress = ( - scrobble_data.pop("jellyfin_status", None) is "resumed" - ) - # We also discard mopidy_status, unused presently - scrobble_data.pop("mopidy_status", None) - + jellyfin_in_progress = scrobble_data.get("jellyfin_status", None) if scrobble and (scrobble.can_be_updated or jellyfin_in_progress): logger.info( f"Updating {scrobble.id}", @@ -621,6 +616,9 @@ class Scrobble(TimeStampedModel): ) return scrobble.update(scrobble_data) + # Discard status before creating + scrobble_data.pop("mopidy_status", None) + scrobble_data.pop("jellyfin_status", None) source = scrobble_data["source"] logger.info( f"Creating for {media.id} - {source}", diff --git a/vrobbler/apps/scrobbles/utils.py b/vrobbler/apps/scrobbles/utils.py index 71331b2..7915e9c 100644 --- a/vrobbler/apps/scrobbles/utils.py +++ b/vrobbler/apps/scrobbles/utils.py @@ -79,9 +79,8 @@ def check_scrobble_for_finish( scrobble: "Scrobble", force_to_100=False, force_finish=False ) -> None: completion_percent = scrobble.media_obj.COMPLETION_PERCENT - # scrobble.refresh_from - db() if scrobble.percent_played >= completion_percent or force_finish: - logger.info(f"{scrobble.id} finished, updating") + logger.info(f"{scrobble.id} finished at {scrobble.percent_played}") scrobble.playback_position_seconds = ( scrobble.media_obj.run_time_seconds ) @@ -99,7 +98,9 @@ def check_scrobble_for_finish( ] ) else: - logger.info(f"{scrobble.id} not complete") + logger.info( + f"{scrobble.id} not complete at {scrobble.percent_played}%" + ) def check_long_play_for_finish(scrobble):