From 52a9a8db8638e923492539830a5f3e51280c95e3 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 25 Oct 2022 22:49:59 -0700 Subject: [PATCH] download strats --- .../downloaders/soundcloud/albums_and_singles.py | 10 ++++++++++ src/ytdl_sub/downloaders/youtube/playlist.py | 12 ++++++++++++ src/ytdl_sub/downloaders/youtube/video.py | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py b/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py index b6529f7e..70a89e97 100644 --- a/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py +++ b/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py @@ -1,3 +1,4 @@ +from typing import Any from typing import Dict from typing import Generator @@ -32,6 +33,15 @@ class SoundcloudAlbumsAndSinglesDownloadOptions(DownloaderValidator): _required_keys = {"url"} _optional_keys = {"skip_premiere_tracks"} + @classmethod + def partial_validate(cls, name: str, value: Any) -> None: + """ + Partially validate a Soundcloud source + """ + if isinstance(value, dict): + value["url"] = value.get("url", "https://soundcloud.com/jessebannon") + _ = cls(name, value) + def __init__(self, name, value): super().__init__(name, value) self._url = self._validate_key( diff --git a/src/ytdl_sub/downloaders/youtube/playlist.py b/src/ytdl_sub/downloaders/youtube/playlist.py index 7a3c7e91..d8c42835 100644 --- a/src/ytdl_sub/downloaders/youtube/playlist.py +++ b/src/ytdl_sub/downloaders/youtube/playlist.py @@ -1,3 +1,4 @@ +from typing import Any from typing import Dict from typing import List from typing import Optional @@ -31,6 +32,17 @@ class YoutubePlaylistDownloaderOptions(DownloaderValidator): _required_keys = {"playlist_url"} _optional_keys = {"playlist_thumbnail_name"} + @classmethod + def partial_validate(cls, name: str, value: Any) -> None: + """ + Partially validate a YouTube playlist source + """ + if isinstance(value, dict): + value["playlist_url"] = value.get( + "playlist_url", "https://www.youtube.com/playlist?list=UCsvn_Po0SmunchJYtttWpOxMg" + ) + _ = cls(name, value) + def __init__(self, name, value): super().__init__(name, value) self._playlist_url = self._validate_key( diff --git a/src/ytdl_sub/downloaders/youtube/video.py b/src/ytdl_sub/downloaders/youtube/video.py index c9b9f951..0c30c11e 100644 --- a/src/ytdl_sub/downloaders/youtube/video.py +++ b/src/ytdl_sub/downloaders/youtube/video.py @@ -1,3 +1,4 @@ +from typing import Any from typing import Dict from ytdl_sub.downloaders.downloader import Downloader @@ -32,6 +33,15 @@ class YoutubeVideoDownloaderOptions(DownloaderValidator): _required_keys = {"video_url"} + @classmethod + def partial_validate(cls, name: str, value: Any) -> None: + """ + Partially validate a YouTube video source + """ + if isinstance(value, dict): + value["video_url"] = value.get("video_url", "youtube.com/watch?v=VMAPTo7RVDo") + _ = cls(name, value) + def __init__(self, name, value): super().__init__(name, value) self._video_url = self._validate_key("video_url", YoutubeVideoUrlValidator).video_url