From a9499f0463096a2b486bda44a2235088e5370c38 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 21 Jan 2025 22:49:15 -0500 Subject: [PATCH] [video] Fix youtube redirects --- vrobbler/apps/scrobbles/models.py | 6 ++++++ vrobbler/apps/videos/models.py | 2 +- vrobbler/apps/videos/views.py | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 4e9458e..51f61d1 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -680,6 +680,12 @@ class Scrobble(TimeStampedModel): logger.info(f"Redirecting to {self.media_obj.url}") redirect_url = self.media_obj.get_read_url() + if ( + self.media_type == self.MediaType.VIDEO + and self.media_obj.youtube_id + ): + redirect_url = self.media_obj.youtube_link + return redirect_url @property diff --git a/vrobbler/apps/videos/models.py b/vrobbler/apps/videos/models.py index e2a2a55..da19416 100644 --- a/vrobbler/apps/videos/models.py +++ b/vrobbler/apps/videos/models.py @@ -263,7 +263,7 @@ class Video(ScrobblableMixin): @property def youtube_link(self) -> str: if self.youtube_id: - return YOUTUBE_BASE_URL + self.youtube_id + return f"https://www.youtube.com/watch?v={self.youtube_id}" return "" @property diff --git a/vrobbler/apps/videos/views.py b/vrobbler/apps/videos/views.py index cdd8563..4b5444f 100644 --- a/vrobbler/apps/videos/views.py +++ b/vrobbler/apps/videos/views.py @@ -29,8 +29,8 @@ class SeriesDetailView(LoginRequiredMixin, generic.DetailView): user_id ).next_imdb_id if self.object.is_episode_playing(user_id): - next_episode_id = None - context_data["next_episode_id"] = next_episode_id + next_episode_id = "" + context_data["next_episode_id"] = "tt" + next_episode_id return context_data