From 489d8b9152ad843951b2f26c6fce553feffa41bc Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 10 Mar 2023 09:32:57 -0500 Subject: [PATCH] Fix lookup of long play media types --- vrobbler/apps/scrobbles/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 1b14a82..a0baced 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -5,6 +5,7 @@ from typing import Optional from uuid import uuid4 from books.models import Book +from django.apps import apps from django.contrib.auth import get_user_model from django.db import models from django.urls import reverse @@ -614,16 +615,17 @@ class Scrobble(TimeStampedModel): logger.info(f"{self.id} - {self.source}") class_name = self.media_obj.__class__.__name__ - if class_name in LONG_PLAY_MEDIA: + if class_name in LONG_PLAY_MEDIA.values(): now = timezone.now() self.played_to_completion = True self.playback_position = (now - self.timestamp).seconds # TODO Refactor ticks outta here, this is silly - self.playback_position_ticks = int(updated_playback) * 1000 + self.playback_position_ticks = int(self.playback_position) * 1000 media_filter = models.Q(video_game=self.video_game) if class_name == "Book": media_filter = models.Q(book=self.book) + # Check for last scrobble, and if present, update long play time last_scrobble = Scrobble.objects.filter( media_filter,