[videos] Switch to TMDB for scraping videos

This commit is contained in:
2025-06-13 11:19:15 -04:00
parent d5da8ae701
commit 24ac545f55
6 changed files with 154 additions and 4 deletions

View File

@ -20,6 +20,7 @@ from scrobbles.mixins import (
from taggit.managers import TaggableManager
from videos.metadata import VideoMetadata
from videos.sources.imdb import lookup_video_from_imdb
from videos.sources.tmdb import lookup_video_from_tmdb
from videos.sources.youtube import lookup_video_from_youtube
YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v="
@ -206,6 +207,7 @@ class Video(ScrobblableMixin):
next_imdb_id = models.CharField(max_length=20, **BNULL)
imdb_id = models.CharField(max_length=20, **BNULL)
imdb_rating = models.FloatField(**BNULL)
tmdb_rating = models.FloatField(**BNULL)
cover_image = models.ImageField(upload_to="videos/video/", **BNULL)
cover_image_small = ImageSpecField(
source="cover_image",
@ -307,11 +309,13 @@ class Video(ScrobblableMixin):
def get_from_imdb_id(
cls, imdb_id: str, overwrite: bool = False
) -> "Video":
if "tt" in imdb_id:
imdb_id = imdb_id[2:]
video, created = cls.objects.get_or_create(imdb_id=imdb_id)
if not created and not overwrite:
return video
vdict, cover, genres = lookup_video_from_imdb(
vdict, cover, genres = lookup_video_from_tmdb(
imdb_id
).as_dict_with_cover_and_genres()
if created or overwrite: