From 12d9f53f1fd904c0e95384fa15c79a5db92048ea Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Wed, 14 Sep 2022 23:06:12 -0700 Subject: [PATCH] fixed? --- src/ytdl_sub/downloaders/downloader.py | 11 ++++++++--- src/ytdl_sub/downloaders/youtube/channel.py | 2 +- src/ytdl_sub/downloaders/youtube/playlist.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ytdl_sub/downloaders/downloader.py b/src/ytdl_sub/downloaders/downloader.py index 26dd6143..0f466110 100644 --- a/src/ytdl_sub/downloaders/downloader.py +++ b/src/ytdl_sub/downloaders/downloader.py @@ -66,8 +66,8 @@ class DownloaderValidator(StrictDictValidator, AddsVariablesMixin, ABC): Placeholder class to define downloader options """ - @abc.abstractmethod @property + @abc.abstractmethod def collection_validator(self) -> CollectionValidator: """ Returns @@ -354,6 +354,11 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT] ############################################################################################### # DOWNLOAD FUNCTIONS + @property + def collection(self) -> CollectionValidator: + """Return the download options collection""" + return self.download_options.collection_validator + @contextlib.contextmanager 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]: """Download in reverse order, that way we download older entries ones first""" if parent.is_entry(): - yield parent.to_type(Entry) + yield self._download_entry(parent.to_type(Entry)) return for entry_child in reversed(parent.entry_children()): @@ -450,7 +455,7 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT] ) -> Iterable[DownloaderEntryT] | Iterable[Tuple[DownloaderEntryT, FileMetadata]]: """The function to perform the download of all media entries""" # 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) for entry in self._download_url(collection_url=collection_url, parents=parents): yield entry diff --git a/src/ytdl_sub/downloaders/youtube/channel.py b/src/ytdl_sub/downloaders/youtube/channel.py index 300fe602..de684943 100644 --- a/src/ytdl_sub/downloaders/youtube/channel.py +++ b/src/ytdl_sub/downloaders/youtube/channel.py @@ -135,7 +135,7 @@ class YoutubeChannelDownloader(YoutubeDownloader[YoutubeChannelDownloaderOptions """ 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) # TODO: Handle this better diff --git a/src/ytdl_sub/downloaders/youtube/playlist.py b/src/ytdl_sub/downloaders/youtube/playlist.py index 1ba4cd58..68af8d2b 100644 --- a/src/ytdl_sub/downloaders/youtube/playlist.py +++ b/src/ytdl_sub/downloaders/youtube/playlist.py @@ -100,7 +100,7 @@ class YoutubePlaylistDownloader( """ 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) # TODO: Handle this better