[scrobbles] Allow skipping checks for existing scrobbles
This commit is contained in:
@ -1087,6 +1087,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
key = media_class_to_foreign_key(media.__class__.__name__)
|
key = media_class_to_foreign_key(media.__class__.__name__)
|
||||||
media_query = models.Q(**{key: media})
|
media_query = models.Q(**{key: media})
|
||||||
scrobble_data[key + "_id"] = media.id
|
scrobble_data[key + "_id"] = media.id
|
||||||
|
skip_in_progress_check = kwargs.get("skip_in_progress_check", False)
|
||||||
|
|
||||||
# Find our last scrobble of this media item (track, video, etc)
|
# Find our last scrobble of this media item (track, video, etc)
|
||||||
scrobble = (
|
scrobble = (
|
||||||
@ -1110,6 +1111,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
)
|
)
|
||||||
return scrobble
|
return scrobble
|
||||||
|
|
||||||
|
if not skip_in_progress_check:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[create_or_update] check for existing scrobble to update ",
|
f"[create_or_update] check for existing scrobble to update ",
|
||||||
extra={
|
extra={
|
||||||
@ -1119,7 +1121,9 @@ class Scrobble(TimeStampedModel):
|
|||||||
"scrobble_data": scrobble_data,
|
"scrobble_data": scrobble_data,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scrobble_data["playback_status"] = scrobble_data.pop("status", None)
|
scrobble_data["playback_status"] = scrobble_data.pop(
|
||||||
|
"status", None
|
||||||
|
)
|
||||||
# If it's marked as stopped, send it through our update mechanism, which will complete it
|
# If it's marked as stopped, send it through our update mechanism, which will complete it
|
||||||
if scrobble and (
|
if scrobble and (
|
||||||
scrobble.can_be_updated
|
scrobble.can_be_updated
|
||||||
@ -1131,6 +1135,7 @@ class Scrobble(TimeStampedModel):
|
|||||||
|
|
||||||
# Discard status before creating
|
# Discard status before creating
|
||||||
scrobble_data.pop("playback_status")
|
scrobble_data.pop("playback_status")
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"[scrobbling] creating new scrobble",
|
f"[scrobbling] creating new scrobble",
|
||||||
extra={
|
extra={
|
||||||
|
|||||||
Reference in New Issue
Block a user