This commit is contained in:
Jesse Bannon 2022-09-14 23:06:12 -07:00
parent 6033f0bc63
commit 12d9f53f1f
3 changed files with 10 additions and 5 deletions

View file

@ -66,8 +66,8 @@ class DownloaderValidator(StrictDictValidator, AddsVariablesMixin, ABC):
Placeholder class to define downloader options Placeholder class to define downloader options
""" """
@abc.abstractmethod
@property @property
@abc.abstractmethod
def collection_validator(self) -> CollectionValidator: def collection_validator(self) -> CollectionValidator:
""" """
Returns Returns
@ -354,6 +354,11 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
############################################################################################### ###############################################################################################
# DOWNLOAD FUNCTIONS # DOWNLOAD FUNCTIONS
@property
def collection(self) -> CollectionValidator:
"""Return the download options collection"""
return self.download_options.collection_validator
@contextlib.contextmanager @contextlib.contextmanager
def _separate_download_archives(self): def _separate_download_archives(self):
""" """
@ -401,7 +406,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
def _download_parent_entry(self, parent: EntryParent) -> Generator[Entry, None, None]: def _download_parent_entry(self, parent: EntryParent) -> Generator[Entry, None, None]:
"""Download in reverse order, that way we download older entries ones first""" """Download in reverse order, that way we download older entries ones first"""
if parent.is_entry(): if parent.is_entry():
yield parent.to_type(Entry) yield self._download_entry(parent.to_type(Entry))
return return
for entry_child in reversed(parent.entry_children()): for entry_child in reversed(parent.entry_children()):
@ -450,7 +455,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
) -> Iterable[DownloaderEntryT] | Iterable[Tuple[DownloaderEntryT, FileMetadata]]: ) -> Iterable[DownloaderEntryT] | Iterable[Tuple[DownloaderEntryT, FileMetadata]]:
"""The function to perform the download of all media entries""" """The function to perform the download of all media entries"""
# download the bottom-most urls first since they are top-priority # download the bottom-most urls first since they are top-priority
for collection_url in reversed(self.download_options.collection_urls.list): for collection_url in reversed(self.collection.collection_urls.list):
parents = self._download_url_metadata(collection_url=collection_url) parents = self._download_url_metadata(collection_url=collection_url)
for entry in self._download_url(collection_url=collection_url, parents=parents): for entry in self._download_url(collection_url=collection_url, parents=parents):
yield entry yield entry

View file

@ -135,7 +135,7 @@ class YoutubeChannelDownloader(YoutubeDownloader[YoutubeChannelDownloaderOptions
""" """
Downloads all videos from a channel Downloads all videos from a channel
""" """
collection_url = self.download_options.collection_validator.collection_urls.list[0] collection_url = self.collection.collection_urls.list[0]
super()._download_url_metadata(collection_url=collection_url) super()._download_url_metadata(collection_url=collection_url)
# TODO: Handle this better # TODO: Handle this better

View file

@ -100,7 +100,7 @@ class YoutubePlaylistDownloader(
""" """
Downloads all videos in a Youtube playlist. Downloads all videos in a Youtube playlist.
""" """
collection_url = self.download_options.collection_validator.collection_urls.list[0] collection_url = self.collection.collection_urls.list[0]
super()._download_url_metadata(collection_url) super()._download_url_metadata(collection_url)
# TODO: Handle this better # TODO: Handle this better