chapters working
This commit is contained in:
parent
67a6972b0a
commit
f97ab6aaa8
3 changed files with 4 additions and 9 deletions
|
|
@ -18,7 +18,6 @@ def _(key: str, backend: bool = False) -> str:
|
|||
|
||||
CHAPTERS = _("chapters", backend=True)
|
||||
YTDL_SUB_CUSTOM_CHAPTERS = _("ytdl_sub_custom_chapters", backend=True)
|
||||
SPONSORBLOCK_CHAPTERS = _("sponsorblock_chapters", backend=True)
|
||||
SPLIT_BY_CHAPTERS_PARENT_ENTRY = _("split_by_chapters_parent_entry", backend=True)
|
||||
COMMENTS = _("comments", backend=True)
|
||||
UID = _("id")
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from ytdl_sub.config.plugin import Plugin
|
|||
from ytdl_sub.config.preset_options import OptionsDictValidator
|
||||
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
|
||||
from ytdl_sub.entries.script.variable_definitions import VARIABLES as v
|
||||
from ytdl_sub.entries.variables.kwargs import YTDL_SUB_CUSTOM_CHAPTERS
|
||||
from ytdl_sub.utils.chapters import Chapters
|
||||
|
|
@ -39,9 +40,7 @@ def _chapters(entry: Entry) -> List[Dict]:
|
|||
|
||||
|
||||
def _sponsorblock_chapters(entry: Entry) -> List[Dict]:
|
||||
if entry.kwargs_contains("sponsorblock_chapters"):
|
||||
return entry.kwargs("sponsorblock_chapters") or []
|
||||
return []
|
||||
return entry.get(v.sponsorblock_chapters, list)
|
||||
|
||||
|
||||
def _contains_any_chapters(entry: Entry) -> bool:
|
||||
|
|
@ -300,10 +299,10 @@ class ChaptersPlugin(Plugin[ChaptersOptions]):
|
|||
-------
|
||||
entry
|
||||
"""
|
||||
chapters = Chapters.from_empty()
|
||||
|
||||
# If there are no embedded chapters, and comment chapters are allowed...
|
||||
if not _contains_any_chapters(entry) and self.plugin_options.allow_chapters_from_comments:
|
||||
chapters = Chapters.from_empty()
|
||||
|
||||
# Try to get chapters from comments
|
||||
for comment in entry.get(v.comments, list):
|
||||
chapters = Chapters.from_string(comment.get("text", ""))
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from ytdl_sub.config.preset_options import PluginOperation
|
|||
from ytdl_sub.entries.entry import Entry
|
||||
from ytdl_sub.entries.variables.kwargs import CHAPTERS
|
||||
from ytdl_sub.entries.variables.kwargs import SPLIT_BY_CHAPTERS_PARENT_ENTRY
|
||||
from ytdl_sub.entries.variables.kwargs import SPONSORBLOCK_CHAPTERS
|
||||
from ytdl_sub.entries.variables.kwargs import UID
|
||||
from ytdl_sub.utils.chapters import Chapters
|
||||
from ytdl_sub.utils.chapters import Timestamp
|
||||
|
|
@ -137,8 +136,6 @@ class SplitByChaptersPlugin(SplitPlugin[SplitByChaptersOptions]):
|
|||
|
||||
if entry.kwargs_contains(CHAPTERS):
|
||||
del entry._kwargs[CHAPTERS]
|
||||
if entry.kwargs_contains(SPONSORBLOCK_CHAPTERS):
|
||||
del entry._kwargs[SPONSORBLOCK_CHAPTERS]
|
||||
# pylint: enable=protected-access
|
||||
|
||||
timestamp_begin = chapters.timestamps[idx].readable_str
|
||||
|
|
|
|||
Loading…
Reference in a new issue