From 45bf87c857aa0943ef2e7ec3f1ef391b8087f959 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Mon, 13 Mar 2023 00:24:28 -0700 Subject: [PATCH] ytdlpDownloader --- src/ytdl_sub/config/preset_class_mappings.py | 3 +-- src/ytdl_sub/downloaders/downloader.py | 2 +- src/ytdl_sub/downloaders/generic/multi_url.py | 4 ++-- src/ytdl_sub/downloaders/generic/url.py | 4 ++-- src/ytdl_sub/subscriptions/base_subscription.py | 4 ++-- .../subscriptions/subscription_ytdl_options.py | 4 ++-- tests/unit/prebuilt_presets/conftest.py | 10 ++++++---- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/ytdl_sub/config/preset_class_mappings.py b/src/ytdl_sub/config/preset_class_mappings.py index d738e911..46d3439a 100644 --- a/src/ytdl_sub/config/preset_class_mappings.py +++ b/src/ytdl_sub/config/preset_class_mappings.py @@ -3,7 +3,6 @@ from typing import List from typing import Type from ytdl_sub.downloaders.downloader import BaseDownloader -from ytdl_sub.downloaders.downloader import Downloader from ytdl_sub.downloaders.generic.multi_url import MultiUrlDownloader from ytdl_sub.downloaders.generic.url import UrlDownloader from ytdl_sub.plugins.audio_extract import AudioExtractPlugin @@ -82,7 +81,7 @@ class DownloadStrategyMapping: ) @classmethod - def get(cls, source: str, download_strategy: str) -> Type[Downloader]: + def get(cls, source: str, download_strategy: str) -> Type[BaseDownloader]: """ Parameters ---------- diff --git a/src/ytdl_sub/downloaders/downloader.py b/src/ytdl_sub/downloaders/downloader.py index 18b467d9..194a52ab 100644 --- a/src/ytdl_sub/downloaders/downloader.py +++ b/src/ytdl_sub/downloaders/downloader.py @@ -122,7 +122,7 @@ class BaseDownloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC): """The function to perform the download of all media entries""" -class Downloader(BaseDownloader[DownloaderOptionsT], ABC): +class YtDlpDownloader(BaseDownloader[DownloaderOptionsT], ABC): """ Class that interacts with ytdl to perform the download of metadata and content, and should translate that to list of Entry objects. diff --git a/src/ytdl_sub/downloaders/generic/multi_url.py b/src/ytdl_sub/downloaders/generic/multi_url.py index a78d6f15..ce0ed70f 100644 --- a/src/ytdl_sub/downloaders/generic/multi_url.py +++ b/src/ytdl_sub/downloaders/generic/multi_url.py @@ -1,5 +1,5 @@ -from ytdl_sub.downloaders.downloader import Downloader from ytdl_sub.downloaders.downloader import DownloaderValidator +from ytdl_sub.downloaders.downloader import YtDlpDownloader from ytdl_sub.downloaders.generic.validators import MultiUrlValidator @@ -44,5 +44,5 @@ class MultiUrlDownloadOptions(MultiUrlValidator, DownloaderValidator): return self -class MultiUrlDownloader(Downloader[MultiUrlDownloadOptions]): +class MultiUrlDownloader(YtDlpDownloader[MultiUrlDownloadOptions]): downloader_options_type = MultiUrlDownloadOptions diff --git a/src/ytdl_sub/downloaders/generic/url.py b/src/ytdl_sub/downloaders/generic/url.py index bf29ef59..ed1091a2 100644 --- a/src/ytdl_sub/downloaders/generic/url.py +++ b/src/ytdl_sub/downloaders/generic/url.py @@ -1,5 +1,5 @@ -from ytdl_sub.downloaders.downloader import Downloader from ytdl_sub.downloaders.downloader import DownloaderValidator +from ytdl_sub.downloaders.downloader import YtDlpDownloader from ytdl_sub.downloaders.generic.validators import MultiUrlValidator from ytdl_sub.downloaders.generic.validators import UrlValidator @@ -36,5 +36,5 @@ class UrlDownloadOptions(UrlValidator, DownloaderValidator): ) -class UrlDownloader(Downloader[UrlDownloadOptions]): +class UrlDownloader(YtDlpDownloader[UrlDownloadOptions]): downloader_options_type = UrlDownloadOptions diff --git a/src/ytdl_sub/subscriptions/base_subscription.py b/src/ytdl_sub/subscriptions/base_subscription.py index afbf8b8a..cf314d1d 100644 --- a/src/ytdl_sub/subscriptions/base_subscription.py +++ b/src/ytdl_sub/subscriptions/base_subscription.py @@ -8,7 +8,7 @@ from ytdl_sub.config.preset import PresetPlugins from ytdl_sub.config.preset_options import OutputOptions from ytdl_sub.config.preset_options import Overrides from ytdl_sub.config.preset_options import YTDLOptions -from ytdl_sub.downloaders.downloader import Downloader +from ytdl_sub.downloaders.downloader import BaseDownloader from ytdl_sub.downloaders.downloader import DownloaderValidator from ytdl_sub.ytdl_additions.enhanced_download_archive import EnhancedDownloadArchive @@ -52,7 +52,7 @@ class BaseSubscription(ABC): ) @property - def downloader_class(self) -> Type[Downloader]: + def downloader_class(self) -> Type[BaseDownloader]: """ Returns ------- diff --git a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py index c660d630..9acb2866 100644 --- a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py +++ b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py @@ -6,7 +6,7 @@ from typing import Type from typing import TypeVar from ytdl_sub.config.preset import Preset -from ytdl_sub.downloaders.downloader import Downloader +from ytdl_sub.downloaders.downloader import BaseDownloader from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder from ytdl_sub.plugins.audio_extract import AudioExtractPlugin from ytdl_sub.plugins.chapters import ChaptersPlugin @@ -43,7 +43,7 @@ class SubscriptionYTDLOptions: return None @property - def _downloader(self) -> Type[Downloader]: + def _downloader(self) -> Type[BaseDownloader]: return self._preset.downloader @property diff --git a/tests/unit/prebuilt_presets/conftest.py b/tests/unit/prebuilt_presets/conftest.py index e1f8ad14..a78af19f 100644 --- a/tests/unit/prebuilt_presets/conftest.py +++ b/tests/unit/prebuilt_presets/conftest.py @@ -11,7 +11,7 @@ import pytest from resources import copy_file_fixture from ytdl_sub.config.config_file import ConfigFile -from ytdl_sub.downloaders.downloader import Downloader +from ytdl_sub.downloaders.downloader import YtDlpDownloader from ytdl_sub.entries.variables.kwargs import DESCRIPTION from ytdl_sub.entries.variables.kwargs import EPOCH from ytdl_sub.entries.variables.kwargs import EXT @@ -112,7 +112,7 @@ def mock_download_collection_thumbnail(mock_downloaded_file_path): return False with patch.object( - Downloader, + YtDlpDownloader, "_download_thumbnail", new=lambda _, thumbnail_url, output_thumbnail_path: _mock_download_thumbnail( output_thumbnail_path @@ -202,8 +202,10 @@ def mock_download_collection_entries( ] with patch.object( - Downloader, "extract_info_via_info_json", new=_write_entries_to_working_dir - ), patch.object(Downloader, "_extract_entry_info_with_retry", new=lambda _, entry: entry): + YtDlpDownloader, "extract_info_via_info_json", new=_write_entries_to_working_dir + ), patch.object( + YtDlpDownloader, "_extract_entry_info_with_retry", new=lambda _, entry: entry + ): # Stub out metadata. TODO: update this if we do metadata plugins yield