From 17586aa9bdadc090ef42549547fa8775c7f35e0f Mon Sep 17 00:00:00 2001 From: jbannon Date: Fri, 22 Jul 2022 04:57:10 +0000 Subject: [PATCH] work on later --- .../soundcloud/albums_and_singles.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py b/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py index 75c94cb1..c7c3e7e9 100644 --- a/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py +++ b/src/ytdl_sub/downloaders/soundcloud/albums_and_singles.py @@ -1,4 +1,4 @@ -from typing import Dict +from typing import Dict, Optional from typing import List from ytdl_sub.downloaders.soundcloud.abc import SoundcloudDownloader @@ -6,6 +6,7 @@ from ytdl_sub.downloaders.soundcloud.abc import SoundcloudDownloaderOptions from ytdl_sub.entries.soundcloud import SoundcloudAlbum from ytdl_sub.entries.soundcloud import SoundcloudTrack from ytdl_sub.validators.url_validator import SoundcloudUsernameUrlValidator +from ytdl_sub.validators.validators import BoolValidator class SoundcloudAlbumsAndSinglesDownloadOptions(SoundcloudDownloaderOptions): @@ -35,6 +36,9 @@ class SoundcloudAlbumsAndSinglesDownloadOptions(SoundcloudDownloaderOptions): self._url = self._validate_key( key="url", validator=SoundcloudUsernameUrlValidator ).username_url + self._download_individually = self._validate_key_if_present( + "download_individually", BoolValidator, default=True + ) @property def url(self) -> str: @@ -43,6 +47,15 @@ class SoundcloudAlbumsAndSinglesDownloadOptions(SoundcloudDownloaderOptions): """ return self._url + @property + def download_individually(self) -> Optional[bool]: + """ + Optional. Downloads files from the channel individually instead of in bulk. Setting to True + is safer when downloading large amounts of videos in case an error occurs. Downloading by + bulk (by setting to False) can increase speeds. Defaults to True. + """ + return self._download_individually.value + class SoundcloudAlbumsAndSinglesDownloader( SoundcloudDownloader[SoundcloudAlbumsAndSinglesDownloadOptions] @@ -120,7 +133,8 @@ class SoundcloudAlbumsAndSinglesDownloader( artist_albums_url = self.artist_albums_url(artist_url=self.download_options.url) artist_tracks_url = self.artist_tracks_url(artist_url=self.download_options.url) - # Albums do not need to download anything since tracks contain all album tracks + # Albums do not need to download anything since tracks contain all album tracks. + # We just need to get the metadata from the album itself album_entry_dicts = self.extract_info_via_info_json( ytdl_options_overrides={ "skip_download": True,