ytdlpDownloader
This commit is contained in:
parent
ab1824ee1c
commit
45bf87c857
7 changed files with 16 additions and 15 deletions
|
|
@ -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
|
||||
----------
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue