download strats

This commit is contained in:
Jesse Bannon 2022-10-25 22:49:59 -07:00
parent 4bdbb27b63
commit 52a9a8db86
3 changed files with 32 additions and 0 deletions

View file

@ -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(

View file

@ -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(

View file

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