From a1584c4f2e1755f042e0e6faad094f818b35d6f2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 18 Mar 2025 20:51:27 +0100 Subject: [PATCH] wip --- rwx/sw/ytdlp/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rwx/sw/ytdlp/__init__.py b/rwx/sw/ytdlp/__init__.py index b947254..031c779 100644 --- a/rwx/sw/ytdlp/__init__.py +++ b/rwx/sw/ytdlp/__init__.py @@ -9,6 +9,7 @@ from yt_dlp import YoutubeDL from rwx import Object from rwx.log import stream as log +TIMESTAMP = "%Y%m%d%H%M%S" URL = "https://youtube.com" @@ -41,11 +42,13 @@ class Channel(Object): self.description = d["description"] self.tags = d["tags"] # TODO thumbnails + self.thumbnails = d["thumbnails"] + # TODO thumbnail from thumbnails self.uploader_id = d["uploader_id"] self.uploader = d["uploader"] # videos - self.videos_ids = [ - entry["id"] + self.videos = [ + Video(entry) for entry in reversed(d["entries"]) if entry["availability"] != "subscriber_only" ] @@ -75,15 +78,15 @@ class Video(Object): :param d: video info :type d: dict """ - self.at = datetime.now().strftime("%Y%m%d%H%M%S") - # info self.uid = d["id"] self.title = d["title"] self.description_cut = d["description"] self.duration = int(d["duration"]) + self.thumbnails = [thumbnail["url"] for thumbnail in d["thumbnails"]] # TODO thumbnail from thumbnails def load_extra(self): + self.at = datetime.now().strftime(TIMESTAMP) d = extract_video(self.uid) # TODO formats # TODO thumbnail from thumbnails @@ -98,7 +101,7 @@ class Video(Object): # TODO subtitles self.chapters = d["chapters"] self.likes = d["like_count"] - self.timestamp = datetime.fromtimestamp(d["timestamp"]).strftime("%Y%m%d%H%M%S") + self.timestamp = datetime.fromtimestamp(d["timestamp"]).strftime(TIMESTAMP) self.fulltitle = d["fulltitle"]