[videos] Fix youtube videos longer than an hour

This commit is contained in:
2025-03-19 00:17:21 -04:00
parent 444562235f
commit 50d1a4a2bd
2 changed files with 15 additions and 4 deletions

View File

@ -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"):

View File

@ -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):