[videos] Dont always lookup from IMDB
All checks were successful
build & deploy / test (push) Successful in 1m41s
build & deploy / deploy (push) Successful in 23s

This commit is contained in:
2026-03-13 15:54:57 -04:00
parent 7cf817025b
commit 31d3a85e8c

View File

@ -178,13 +178,17 @@ class Series(TimeStampedModel):
def last_scrobbled_episode(self, user_id: int) -> Optional["Video"]:
episode = None
last_scrobble = self.scrobbles_for_user(user_id, include_playing=True).first()
last_scrobble = self.scrobbles_for_user(
user_id, include_playing=True
).first()
if last_scrobble:
episode = last_scrobble.media_obj
return episode
def is_episode_playing(self, user_id: int) -> bool:
last_scrobble = self.scrobbles_for_user(user_id, include_playing=True).first()
last_scrobble = self.scrobbles_for_user(
user_id, include_playing=True
).first()
return not last_scrobble.played_to_completion
def fix_metadata(self, force_update=False):
@ -359,7 +363,9 @@ class Video(ScrobblableMixin):
self.cover_image.save(fname, ContentFile(r.content), save=True)
@classmethod
def get_from_youtube_id(cls, youtube_id: str, overwrite: bool = False) -> "Video":
def get_from_youtube_id(
cls, youtube_id: str, overwrite: bool = False
) -> "Video":
video, created = cls.objects.get_or_create(youtube_id=youtube_id)
if not created and not overwrite:
return video
@ -379,7 +385,9 @@ class Video(ScrobblableMixin):
return video
@classmethod
def get_from_imdb_id(cls, imdb_id: str, overwrite: bool = False) -> "Video":
def get_from_imdb_id(
cls, imdb_id: str, overwrite: bool = False
) -> "Video":
video, created = cls.objects.get_or_create(imdb_id=imdb_id)
if not created and not overwrite:
return video
@ -405,7 +413,9 @@ class Video(ScrobblableMixin):
return video
@classmethod
def find_or_create(cls, source_id: str, overwrite: bool = True) -> "Video":
def find_or_create(
cls, source_id: str, overwrite: bool = False
) -> "Video":
if "tt" in source_id:
return cls.get_from_imdb_id(source_id, overwrite)
if bool(YOUTUBE_ID_PATTERN.match(source_id)):