From 50d1a4a2bd810993df68a479e8a424c35c39f2bc Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 19 Mar 2025 00:17:21 -0400 Subject: [PATCH] [videos] Fix youtube videos longer than an hour --- vrobbler/apps/videos/sources/youtube.py | 17 ++++++++++++++--- vrobbler/apps/webpages/models.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/vrobbler/apps/videos/sources/youtube.py b/vrobbler/apps/videos/sources/youtube.py index cf48078..d538b28 100644 --- a/vrobbler/apps/videos/sources/youtube.py +++ b/vrobbler/apps/videos/sources/youtube.py @@ -40,10 +40,21 @@ def lookup_video_from_youtube(youtube_id: str) -> VideoMetadata: .get("contentDetails", {}) .get("duration") ) - minutes = duration_iso8601.split("PT")[1].split("M")[0] - seconds = duration_iso8601.split("PT")[1].split("M")[1].replace("S", "") - duration = (int(minutes) * 60) + int(seconds) + duration_str = duration_iso8601.split("PT")[1] + hours = 0 + minutes = 0 + seconds = 0 + if "H" in duration_str: + hours = duration_str.split("H")[0] + duration_str = duration_str.split("H")[1] + if "M" in duration_str: + minutes = duration_str.split("M")[0] + duration_str = duration_str.split("M")[1] + if "S" in duration_str: + seconds = duration_str.replace("S", "") + + duration = (int(hours) * 60 * 60) + (int(minutes) * 60) + int(seconds) if yt_metadata: if yt_metadata.get("channelId"): diff --git a/vrobbler/apps/webpages/models.py b/vrobbler/apps/webpages/models.py index 85ead43..a92414c 100644 --- a/vrobbler/apps/webpages/models.py +++ b/vrobbler/apps/webpages/models.py @@ -53,7 +53,7 @@ class WebPage(ScrobblableMixin): if self.title: return self.title if self.domain: - return self.domain + return self.domain.name return str(self.uuid) def _raw_domain(self):