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