validate SC

This commit is contained in:
Jesse Bannon 2022-09-14 15:18:15 -07:00
parent 24faaa3233
commit 1be41efdd0
3 changed files with 22 additions and 6 deletions

View file

@ -114,7 +114,7 @@ for available source variables to use.
albums_and_singles albums_and_singles
__________________ __________________
.. autoclass:: ytdl_sub.downloaders.soundcloud.albums_and_singles.SoundcloudAlbumsAndSinglesDownloadOptions() .. autoclass:: ytdl_sub.downloaders.soundcloud.albums_and_singles.SoundcloudAlbumsAndSinglesDownloadOptions()
:members: :members: url, skip_premiere_tracks
:member-order: bysource :member-order: bysource
:inherited-members: :inherited-members:

View file

@ -233,7 +233,11 @@ class Preset(StrictDictValidator):
# If the formatter supports source variables, set the formatter variables to include # If the formatter supports source variables, set the formatter variables to include
# both source and override variables # both source and override variables
if not isinstance(formatter_validator, OverridesStringFormatterValidator): if not isinstance(formatter_validator, OverridesStringFormatterValidator):
source_variables = {source_var: "dummy_string" for source_var in self._source_variables} source_variables = {
source_var: "dummy_string"
for source_var in self._source_variables
+ self.downloader_options.added_source_variables()
}
variable_dict = dict(source_variables, **variable_dict) variable_dict = dict(source_variables, **variable_dict)
# For all plugins, add in any extra added source variables # For all plugins, add in any extra added source variables

View file

@ -1,12 +1,12 @@
from typing import Dict from typing import Dict
from typing import Generator from typing import Generator
from typing import List
from ytdl_sub.downloaders.downloader import Downloader from ytdl_sub.downloaders.downloader import Downloader
from ytdl_sub.downloaders.downloader import DownloaderValidator from ytdl_sub.downloaders.downloader import DownloaderValidator
from ytdl_sub.downloaders.generic.collection import CollectionDownloader from ytdl_sub.downloaders.generic.collection import CollectionDownloader
from ytdl_sub.downloaders.generic.collection import CollectionDownloadOptions from ytdl_sub.downloaders.generic.collection import CollectionDownloadOptions
from ytdl_sub.entries.entry import Entry from ytdl_sub.entries.entry import Entry
from ytdl_sub.entries.soundcloud import SoundcloudTrack
from ytdl_sub.validators.url_validator import SoundcloudUsernameUrlValidator from ytdl_sub.validators.url_validator import SoundcloudUsernameUrlValidator
from ytdl_sub.validators.validators import BoolValidator from ytdl_sub.validators.validators import BoolValidator
@ -87,12 +87,24 @@ class SoundcloudAlbumsAndSinglesDownloadOptions(DownloaderValidator):
""" """
return self._url return self._url
def added_source_variables(self) -> List[str]:
"""Validate using collection_validator"""
return self.collection_validator.added_source_variables()
def validate_with_variables(
self, source_variables: List[str], override_variables: Dict[str, str]
) -> None:
"""Validate using collection_validator"""
return self.collection_validator.validate_with_variables(
source_variables, override_variables
)
class SoundcloudAlbumsAndSinglesDownloader( class SoundcloudAlbumsAndSinglesDownloader(
Downloader[SoundcloudAlbumsAndSinglesDownloadOptions, SoundcloudTrack] Downloader[SoundcloudAlbumsAndSinglesDownloadOptions, Entry]
): ):
downloader_options_type = SoundcloudAlbumsAndSinglesDownloadOptions downloader_options_type = SoundcloudAlbumsAndSinglesDownloadOptions
downloader_entry_type = SoundcloudTrack downloader_entry_type = Entry
supports_subtitles = False supports_subtitles = False
supports_chapters = False supports_chapters = False
@ -125,7 +137,7 @@ class SoundcloudAlbumsAndSinglesDownloader(
return False return False
def download(self) -> Generator[SoundcloudTrack, None, None]: def download(self) -> Generator[Entry, None, None]:
""" """
Soundcloud subscription to download albums and tracks as singles. Soundcloud subscription to download albums and tracks as singles.
""" """