subtitles working
This commit is contained in:
parent
38960a205d
commit
87303ac5be
2 changed files with 6 additions and 15 deletions
|
|
@ -150,7 +150,7 @@ ENTRY_INJECTED_VARIABLES: Dict[Variable, str] = {
|
|||
v.download_index: "{%int(1)}",
|
||||
v.upload_date_index: "{%int(1)}",
|
||||
v.comments: "",
|
||||
v.requested_subtitles: "",
|
||||
v.requested_subtitles: "{ {} }",
|
||||
v.sponsorblock_chapters: "",
|
||||
v.ytdl_sub_input_url: f"{{{v.source_webpage_url.variable_name}}}",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from ytdl_sub.config.preset_options import OptionsDictValidator
|
|||
from ytdl_sub.config.preset_options import PluginOperation
|
||||
from ytdl_sub.downloaders.ytdl_options_builder import YTDLOptionsBuilder
|
||||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.script.variable_definitions import VARIABLES as v
|
||||
from ytdl_sub.utils.file_handler import FileHandler
|
||||
from ytdl_sub.utils.file_handler import FileMetadata
|
||||
from ytdl_sub.utils.logger import Logger
|
||||
|
|
@ -123,7 +124,7 @@ class SubtitleOptions(OptionsDictValidator):
|
|||
-------
|
||||
List of new source variables created by using the subtitles plugin
|
||||
"""
|
||||
return {PluginOperation.MODIFY_ENTRY: {"lang", "subtitles_ext"}}
|
||||
return {PluginOperation.MODIFY_ENTRY_METADATA: {"lang", "subtitles_ext"}}
|
||||
|
||||
|
||||
class SubtitlesPlugin(Plugin[SubtitleOptions]):
|
||||
|
|
@ -162,18 +163,8 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]):
|
|||
|
||||
return builder.to_dict()
|
||||
|
||||
def modify_entry(self, entry: Entry) -> Optional[Entry]:
|
||||
if not (requested_subtitles := entry.kwargs_get("requested_subtitles", None)):
|
||||
return entry
|
||||
|
||||
languages = sorted(requested_subtitles.keys())
|
||||
entry.add_variables(
|
||||
variables_to_add={
|
||||
"subtitles_ext": self.plugin_options.subtitles_type,
|
||||
"lang": ",".join(languages),
|
||||
}
|
||||
)
|
||||
|
||||
def modify_entry_metadata(self, entry: Entry) -> Optional[Entry]:
|
||||
entry.add({"subtitles_ext": self.plugin_options.subtitles_type, "lang": ""})
|
||||
return entry
|
||||
|
||||
def post_process_entry(self, entry: Entry) -> Optional[FileMetadata]:
|
||||
|
|
@ -185,7 +176,7 @@ class SubtitlesPlugin(Plugin[SubtitleOptions]):
|
|||
entry:
|
||||
Entry to create subtitles for
|
||||
"""
|
||||
requested_subtitles = entry.kwargs("requested_subtitles")
|
||||
requested_subtitles = entry.get(v.requested_subtitles, expected_type=dict)
|
||||
if not requested_subtitles:
|
||||
logger.debug("subtitles not found for %s", entry.title)
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue