[videos] Refactor lookup to use new library

This commit is contained in:
2025-11-17 17:56:15 -05:00
parent cd5dc25642
commit 7addd50577
5 changed files with 89 additions and 96 deletions

View File

@ -123,9 +123,8 @@ def jellyfin_scrobble_media(
/ 10000000
)
if media_type == Scrobble.MediaType.VIDEO:
media_obj = Video.get_from_imdb_id(
post_data.get("Provider_imdb", "").replace("tt", "")
)
imdb_id = post_data.get("Provider_imdb", "")
media_obj = Video.find_or_create(imdb_id)
else:
media_obj = Track.find_or_create(
title=post_data.get("Name", ""),
@ -162,18 +161,14 @@ def jellyfin_scrobble_media(
def web_scrobbler_scrobble_media(
youtube_id: str, user_id: int, status: str = "started"
) -> Optional[Scrobble]:
video = Video.get_from_youtube_id(youtube_id)
video = Video.find_or_create(youtube_id)
return video.scrobble_for_user(user_id, status, source="Web Scrobbler")
def manual_scrobble_video(
video_id: str, user_id: int, source: str = "IMDb", action: Optional[str] = None
):
if "tt" in video_id:
video = Video.get_from_imdb_id(video_id)
else:
video = Video.get_from_youtube_id(video_id)
video = Video.find_or_create(video_id)
# When manually scrobbling, try finding a source from the series
if video.tv_series: