remove more kwargs
This commit is contained in:
parent
918e2bac4b
commit
445a8a5e82
5 changed files with 17 additions and 16 deletions
|
|
@ -15,8 +15,6 @@ from ytdl_sub.entries.entry import Entry
|
|||
from ytdl_sub.entries.script.variable_definitions import VARIABLES as v
|
||||
from ytdl_sub.entries.script.variable_scripts import ENTRY_INJECTED_VARIABLES
|
||||
from ytdl_sub.entries.script.variable_scripts import VARIABLE_SCRIPTS
|
||||
from ytdl_sub.entries.variables.kwargs import DOWNLOAD_INDEX
|
||||
from ytdl_sub.entries.variables.kwargs import UPLOAD_DATE_INDEX
|
||||
from ytdl_sub.utils.exceptions import ValidationException
|
||||
from ytdl_sub.utils.file_handler import FileHandler
|
||||
from ytdl_sub.utils.file_handler import get_file_extension
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ 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.script.variable_definitions import VARIABLES as v
|
||||
from ytdl_sub.entries.variables.kwargs import COLLECTION_URL
|
||||
from ytdl_sub.entries.variables.kwargs import PLAYLIST_ENTRY
|
||||
from ytdl_sub.entries.variables.kwargs import SOURCE_ENTRY
|
||||
from ytdl_sub.utils.file_handler import FileHandler
|
||||
|
|
@ -143,9 +142,9 @@ class UrlDownloaderThumbnailPlugin(SourcePluginExtension):
|
|||
if not self.is_dry_run:
|
||||
try_convert_download_thumbnail(entry=entry)
|
||||
|
||||
if entry.kwargs_get(COLLECTION_URL) in self._collection_url_mapping:
|
||||
if (input_url := entry.get_str(v.ytdl_sub_input_url)) in self._collection_url_mapping:
|
||||
self._download_url_thumbnails(
|
||||
collection_url=self._collection_url_mapping[entry.kwargs(COLLECTION_URL)],
|
||||
collection_url=self._collection_url_mapping[input_url],
|
||||
entry=entry,
|
||||
)
|
||||
return entry
|
||||
|
|
@ -177,7 +176,7 @@ class UrlDownloaderCollectionVariablePlugin(SourcePluginExtension):
|
|||
"""
|
||||
# COLLECTION_URL is a recent variable that may not exist for old entries when updating.
|
||||
# Try to use source_webpage_url if it does not exist
|
||||
entry_collection_url = entry.kwargs_get(COLLECTION_URL, entry.get_str(v.source_webpage_url))
|
||||
entry_collection_url = entry.get_str(v.ytdl_sub_input_url)
|
||||
|
||||
# If the collection URL cannot find its mapping, use the last URL
|
||||
collection_url = (
|
||||
|
|
@ -460,13 +459,16 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
|
|||
for entry in self._iterate_entries(
|
||||
url_validator=collection_url, parents=parents, orphans=orphan_entries
|
||||
):
|
||||
# Add the collection URL to the info_dict to trace where it came from
|
||||
entry.add_kwargs(
|
||||
{COLLECTION_URL: self.overrides.apply_formatter(collection_url.url)}
|
||||
)
|
||||
yield entry.initialize_script(
|
||||
entry.initialize_script(
|
||||
override_variables=self.overrides.dict_with_format_strings
|
||||
).add(
|
||||
{
|
||||
v.ytdl_sub_input_url.variable_name: self.overrides.apply_formatter(
|
||||
collection_url.url
|
||||
)
|
||||
}
|
||||
)
|
||||
yield entry
|
||||
|
||||
def download(self, entry: Entry) -> Optional[Entry]:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -606,6 +606,10 @@ class _Variables:
|
|||
def requested_subtitles(self) -> MetadataVariable:
|
||||
return MetadataVariable("requested_subtitles", "requested_subtitles")
|
||||
|
||||
@property
|
||||
def ytdl_sub_input_url(self) -> Variable:
|
||||
return Variable("ytdl_sub_input_url")
|
||||
|
||||
@property
|
||||
def download_index(self) -> Variable:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ ENTRY_DEFAULT_VARIABLES: Dict[MetadataVariable, str] = {
|
|||
v.channel_id: entry_get(v.channel_id, v.uploader_id),
|
||||
}
|
||||
|
||||
# TODO: MARK AS UNRESOLVABLE UNTIL THEY ARE ADDED
|
||||
# MARK AS UNRESOLVABLE UNTIL THEY ARE ADDED
|
||||
ENTRY_INJECTED_VARIABLES: Dict[Variable, str] = {
|
||||
v.download_index: "{%int(1)}",
|
||||
v.upload_date_index: "{%int(1)}",
|
||||
|
|
@ -137,6 +137,7 @@ ENTRY_INJECTED_VARIABLES: Dict[Variable, str] = {
|
|||
v.comments: "",
|
||||
v.requested_subtitles: "",
|
||||
v.sponsorblock_chapters: "",
|
||||
v.ytdl_sub_input_url: f"{{{v.source_webpage_url.variable_name}}}",
|
||||
}
|
||||
|
||||
ENTRY_DERIVED_VARIABLES: Dict[Variable, str] = {
|
||||
|
|
|
|||
|
|
@ -40,10 +40,6 @@ PLAYLIST_UPLOADER = _("playlist_uploader")
|
|||
PLAYLIST_UPLOADER_ID = _("playlist_uploader_id")
|
||||
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
|
||||
|
||||
COLLECTION_URL = _("collection_url", backend=True)
|
||||
DOWNLOAD_INDEX = _("download_index", backend=True)
|
||||
UPLOAD_DATE_INDEX = _("upload_date_index", backend=True)
|
||||
REQUESTED_SUBTITLES = _("requested_subtitles", backend=True)
|
||||
CHAPTERS = _("chapters", backend=True)
|
||||
YTDL_SUB_CUSTOM_CHAPTERS = _("ytdl_sub_custom_chapters", backend=True)
|
||||
YTDL_SUB_REGEX_SOURCE_VARS = _("ytdl_sub_regex_source_vars", backend=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue