Fix lookup of long play media types
This commit is contained in:
@ -5,6 +5,7 @@ from typing import Optional
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from books.models import Book
|
from books.models import Book
|
||||||
|
from django.apps import apps
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -614,16 +615,17 @@ class Scrobble(TimeStampedModel):
|
|||||||
logger.info(f"{self.id} - {self.source}")
|
logger.info(f"{self.id} - {self.source}")
|
||||||
|
|
||||||
class_name = self.media_obj.__class__.__name__
|
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()
|
now = timezone.now()
|
||||||
self.played_to_completion = True
|
self.played_to_completion = True
|
||||||
self.playback_position = (now - self.timestamp).seconds
|
self.playback_position = (now - self.timestamp).seconds
|
||||||
# TODO Refactor ticks outta here, this is silly
|
# 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)
|
media_filter = models.Q(video_game=self.video_game)
|
||||||
if class_name == "Book":
|
if class_name == "Book":
|
||||||
media_filter = models.Q(book=self.book)
|
media_filter = models.Q(book=self.book)
|
||||||
|
|
||||||
# Check for last scrobble, and if present, update long play time
|
# Check for last scrobble, and if present, update long play time
|
||||||
last_scrobble = Scrobble.objects.filter(
|
last_scrobble = Scrobble.objects.filter(
|
||||||
media_filter,
|
media_filter,
|
||||||
|
|||||||
Reference in New Issue
Block a user