From 3f41a52e56cb5f48d14558887056104eeca226dd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 18 Mar 2025 09:04:47 +0100 Subject: [PATCH] filters --- rwx/sw/yt_dlp/__init__.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/rwx/sw/yt_dlp/__init__.py b/rwx/sw/yt_dlp/__init__.py index d884724..7308868 100644 --- a/rwx/sw/yt_dlp/__init__.py +++ b/rwx/sw/yt_dlp/__init__.py @@ -202,14 +202,14 @@ def extract_channel(channel_id: str) -> dict: } -def extract_channel_videos(channel_id: str) -> list[str]: +def extract_videos(channel_id: str) -> list[str]: """Return extracted channel videos dict. :rtype: dict """ d = extract({ }, f"{URL}/channel/{channel_id}/videos") - log.info(d) + return d return [entry["id"] for entry in reversed(d["entries"])] @@ -220,12 +220,31 @@ def extract_video(video_id: str) -> dict: """ d = extract({ }, f"{URL}/watch?v={video_id}") - log.info(d) + return d + + +def filter_video(d: dict) -> dict: + """Return filtered video dict. + + :param d: video info dict + :type d: dict + :rtype: dict + """ return { "title": d["title"], } +def filter_videos(d: dict) -> list[str]: + """Return filtered videos dict. + + :param d: videos dict + :type d: dict + :rtype: dict + """ + return [entry["id"] for entry in reversed(d["entries"])] + + def next_download(videos: list[str]) -> str | None: index = 0 for video_id in videos: