correct ytdl_option ordering
This commit is contained in:
parent
186e7ca739
commit
6ba9d55186
3 changed files with 14 additions and 10 deletions
|
|
@ -25,7 +25,7 @@ from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder
|
|||
from ytdl_sub.downloaders.ytdlp import YTDLP
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.entry_parent import EntryParent
|
||||
from ytdl_sub.entries.variables.kwargs import COLLECTION_URL, YTDL_SUB_MATCH_FILTER_REJECT
|
||||
from ytdl_sub.entries.variables.kwargs import COLLECTION_URL
|
||||
from ytdl_sub.entries.variables.kwargs import COMMENTS
|
||||
from ytdl_sub.entries.variables.kwargs import DOWNLOAD_INDEX
|
||||
from ytdl_sub.entries.variables.kwargs import PLAYLIST_ENTRY
|
||||
|
|
@ -33,6 +33,7 @@ from ytdl_sub.entries.variables.kwargs import REQUESTED_SUBTITLES
|
|||
from ytdl_sub.entries.variables.kwargs import SOURCE_ENTRY
|
||||
from ytdl_sub.entries.variables.kwargs import SPONSORBLOCK_CHAPTERS
|
||||
from ytdl_sub.entries.variables.kwargs import UPLOAD_DATE_INDEX
|
||||
from ytdl_sub.entries.variables.kwargs import YTDL_SUB_MATCH_FILTER_REJECT
|
||||
from ytdl_sub.plugins.plugin import Plugin
|
||||
from ytdl_sub.utils.file_handler import FileHandler
|
||||
from ytdl_sub.utils.logger import Logger
|
||||
|
|
@ -525,6 +526,11 @@ class BaseUrlDownloader(BaseDownloader[BaseDownloaderOptionsT], ABC):
|
|||
Returns
|
||||
-------
|
||||
The entry that was downloaded successfully
|
||||
|
||||
Raises
|
||||
------
|
||||
RejectedVideoReached
|
||||
If a video was rejected and was not from match_filter
|
||||
"""
|
||||
download_logger.info(
|
||||
"Downloading entry %d/%d: %s",
|
||||
|
|
@ -539,7 +545,7 @@ class BaseUrlDownloader(BaseDownloader[BaseDownloaderOptionsT], ABC):
|
|||
try:
|
||||
download_entry = self._extract_entry_info_with_retry(entry=entry)
|
||||
except RejectedVideoReached:
|
||||
if 'match_filter' in self.download_ytdl_options:
|
||||
if "match_filter" in self.download_ytdl_options:
|
||||
entry.add_kwargs({YTDL_SUB_MATCH_FILTER_REJECT: True})
|
||||
return entry
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ from yt_dlp import match_filter_func
|
|||
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.variables.kwargs import YTDL_SUB_MATCH_FILTER_REJECT
|
||||
from ytdl_sub.plugins.plugin import Plugin, PluginPriority
|
||||
from ytdl_sub.plugins.plugin import Plugin
|
||||
from ytdl_sub.plugins.plugin import PluginOptions
|
||||
from ytdl_sub.plugins.plugin import PluginPriority
|
||||
from ytdl_sub.utils.logger import Logger
|
||||
from ytdl_sub.validators.validators import StringListValidator
|
||||
|
||||
|
|
@ -65,9 +66,7 @@ class MatchFiltersOptions(PluginOptions):
|
|||
|
||||
class MatchFiltersPlugin(Plugin[MatchFiltersOptions]):
|
||||
plugin_options_type = MatchFiltersOptions
|
||||
priority = PluginPriority(
|
||||
modify_entry=PluginPriority.MODIFY_ENTRY_FIRST
|
||||
)
|
||||
priority = PluginPriority(modify_entry=PluginPriority.MODIFY_ENTRY_FIRST)
|
||||
|
||||
def ytdl_options(self) -> Optional[Dict]:
|
||||
"""
|
||||
|
|
@ -86,6 +85,7 @@ class MatchFiltersPlugin(Plugin[MatchFiltersOptions]):
|
|||
|
||||
def modify_entry(self, entry: Entry) -> Optional[Entry]:
|
||||
if entry.kwargs_get(YTDL_SUB_MATCH_FILTER_REJECT, False):
|
||||
logger.info("Entry rejected by match-filter, skipping ..")
|
||||
return None
|
||||
|
||||
return entry
|
||||
|
|
|
|||
|
|
@ -80,9 +80,7 @@ class SubscriptionYTDLOptions:
|
|||
|
||||
@property
|
||||
def _download_only_options(self) -> Dict:
|
||||
return {
|
||||
"break_on_reject": True
|
||||
}
|
||||
return {"break_on_reject": True}
|
||||
|
||||
@property
|
||||
def _output_options(self) -> Dict:
|
||||
|
|
@ -116,7 +114,6 @@ class SubscriptionYTDLOptions:
|
|||
self._global_options,
|
||||
self._output_options,
|
||||
self._plugin_ytdl_options(DateRangePlugin),
|
||||
self._plugin_ytdl_options(MatchFiltersPlugin),
|
||||
self._user_ytdl_options, # user ytdl options...
|
||||
self._info_json_only_options, # then info_json_only options
|
||||
)
|
||||
|
|
@ -131,6 +128,7 @@ class SubscriptionYTDLOptions:
|
|||
ytdl_options_builder = YTDLOptionsBuilder().add(
|
||||
self._global_options,
|
||||
self._output_options,
|
||||
self._plugin_ytdl_options(MatchFiltersPlugin),
|
||||
self._plugin_ytdl_options(FileConvertPlugin),
|
||||
self._plugin_ytdl_options(SubtitlesPlugin),
|
||||
self._plugin_ytdl_options(ChaptersPlugin),
|
||||
|
|
|
|||
Loading…
Reference in a new issue