[BACKEND] Do not default when building parent kwargs (#247)

This commit is contained in:
Jesse Bannon 2022-09-27 18:39:29 -07:00 committed by GitHub
parent 32577bbad5
commit 8edca7af36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View file

@ -12,6 +12,7 @@ from yt_dlp.utils import sanitize_filename
from ytdl_sub.entries.variables.kwargs import DESCRIPTION
from ytdl_sub.entries.variables.kwargs import TITLE
from ytdl_sub.entries.variables.kwargs import UID
from ytdl_sub.entries.variables.kwargs import UPLOADER
from ytdl_sub.entries.variables.kwargs import UPLOADER_ID
from ytdl_sub.entries.variables.kwargs import UPLOADER_URL
@ -37,7 +38,7 @@ class BaseEntryVariables:
str
The entry's unique ID
"""
return self.kwargs("id")
return self.kwargs(UID)
@property
def extractor(self: "BaseEntry") -> str:

View file

@ -9,6 +9,7 @@ import mergedeep
from ytdl_sub.entries.base_entry import BaseEntry
from ytdl_sub.entries.base_entry import TBaseEntry
from ytdl_sub.entries.entry import Entry
from ytdl_sub.entries.variables.kwargs import DESCRIPTION
from ytdl_sub.entries.variables.kwargs import PLAYLIST_COUNT
from ytdl_sub.entries.variables.kwargs import PLAYLIST_DESCRIPTION
from ytdl_sub.entries.variables.kwargs import PLAYLIST_ENTRY
@ -31,6 +32,12 @@ from ytdl_sub.entries.variables.kwargs import SOURCE_UPLOADER
from ytdl_sub.entries.variables.kwargs import SOURCE_UPLOADER_ID
from ytdl_sub.entries.variables.kwargs import SOURCE_UPLOADER_URL
from ytdl_sub.entries.variables.kwargs import SOURCE_WEBPAGE_URL
from ytdl_sub.entries.variables.kwargs import TITLE
from ytdl_sub.entries.variables.kwargs import UID
from ytdl_sub.entries.variables.kwargs import UPLOADER
from ytdl_sub.entries.variables.kwargs import UPLOADER_ID
from ytdl_sub.entries.variables.kwargs import UPLOADER_URL
from ytdl_sub.entries.variables.kwargs import WEBPAGE_URL
class ParentType:
@ -77,15 +84,18 @@ class EntryParent(BaseEntry):
def _(source_key: str, playlist_key: str) -> str:
return playlist_key if parent_type == ParentType.PLAYLIST else source_key
def __(key: str) -> Optional[str]:
return self.kwargs_get(key=key)
return {
_(SOURCE_ENTRY, PLAYLIST_ENTRY): self._kwargs,
_(SOURCE_TITLE, PLAYLIST_TITLE): self.title,
_(SOURCE_WEBPAGE_URL, PLAYLIST_WEBPAGE_URL): self.webpage_url,
_(SOURCE_UID, PLAYLIST_UID): self.uid,
_(SOURCE_DESCRIPTION, PLAYLIST_DESCRIPTION): self.description,
_(SOURCE_UPLOADER, PLAYLIST_UPLOADER): self.uploader,
_(SOURCE_UPLOADER_ID, PLAYLIST_UPLOADER_ID): self.uploader_id,
_(SOURCE_UPLOADER_URL, PLAYLIST_UPLOADER_URL): self.uploader_url,
_(SOURCE_TITLE, PLAYLIST_TITLE): __(TITLE),
_(SOURCE_WEBPAGE_URL, PLAYLIST_WEBPAGE_URL): __(WEBPAGE_URL),
_(SOURCE_UID, PLAYLIST_UID): __(UID),
_(SOURCE_DESCRIPTION, PLAYLIST_DESCRIPTION): __(DESCRIPTION),
_(SOURCE_UPLOADER, PLAYLIST_UPLOADER): __(UPLOADER),
_(SOURCE_UPLOADER_ID, PLAYLIST_UPLOADER_ID): __(UPLOADER_ID),
_(SOURCE_UPLOADER_URL, PLAYLIST_UPLOADER_URL): __(UPLOADER_URL),
}
def _get_entry_children_variable_list(self, variable_name: str) -> List[str | int]:

View file

@ -40,6 +40,7 @@ PLAYLIST_UPLOADER = _("playlist_uploader")
PLAYLIST_UPLOADER_ID = _("playlist_uploader_id")
PLAYLIST_UPLOADER_URL = _("playlist_uploader_url")
UID = _("id")
EXT = _("ext")
TITLE = _("title")
DESCRIPTION = _("description")

View file

@ -8,6 +8,7 @@ from typing import Tuple
from yt_dlp.utils import sanitize_filename
from ytdl_sub.entries.entry import Entry
from ytdl_sub.entries.variables.kwargs import UID
from ytdl_sub.plugins.plugin import Plugin
from ytdl_sub.plugins.plugin import PluginOptions
from ytdl_sub.utils.chapters import Chapters
@ -113,7 +114,7 @@ class SplitByChaptersPlugin(Plugin[SplitByChaptersOptions]):
)
# pylint: disable=protected-access
entry._kwargs["id"] = _split_video_uid(source_uid=entry.uid, idx=idx)
entry._kwargs[UID] = _split_video_uid(source_uid=entry.uid, idx=idx)
if "chapters" in entry._kwargs:
del entry._kwargs["chapters"]
if "sponsorblock_chapters" in entry._kwargs: