Add manual scrobbling by TheSportsDB ID

This commit is contained in:
2023-01-15 02:41:36 -05:00
parent 0378dfe6eb
commit c484905d11
8 changed files with 159 additions and 24 deletions

View File

@ -148,6 +148,25 @@ class Scrobble(TimeStampedModel):
scrobble, backoff, wait_period, scrobble_data
)
@classmethod
def create_or_update_for_sport_event(
cls, event: "SportEvent", user_id: int, jellyfin_data: dict
) -> "Scrobble":
jellyfin_data['sport_event_id'] = event.id
scrobble = (
cls.objects.filter(sport_event=event, user_id=user_id)
.order_by('-modified')
.first()
)
# Backoff is how long until we consider this a new scrobble
backoff = timezone.now() + timedelta(minutes=VIDEO_BACKOFF)
wait_period = timezone.now() + timedelta(days=VIDEO_WAIT_PERIOD)
return cls.update_or_create(
scrobble, backoff, wait_period, jellyfin_data
)
@classmethod
def update_or_create(
cls,