From fa6eae74231b78e9662afb07a09c6d30be658f96 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Fri, 31 Mar 2023 15:37:06 -0700 Subject: [PATCH] [FEATURE] `creator` source variable (#572) --- src/ytdl_sub/entries/variables/entry_variables.py | 11 +++++++++++ src/ytdl_sub/entries/variables/kwargs.py | 1 + tests/unit/entries/conftest.py | 1 + 3 files changed, 13 insertions(+) diff --git a/src/ytdl_sub/entries/variables/entry_variables.py b/src/ytdl_sub/entries/variables/entry_variables.py index 91762245..5e915477 100644 --- a/src/ytdl_sub/entries/variables/entry_variables.py +++ b/src/ytdl_sub/entries/variables/entry_variables.py @@ -6,6 +6,7 @@ from yt_dlp.utils import sanitize_filename from ytdl_sub.entries.base_entry import BaseEntry from ytdl_sub.entries.base_entry import BaseEntryVariables from ytdl_sub.entries.variables.kwargs import CHANNEL +from ytdl_sub.entries.variables.kwargs import CREATOR from ytdl_sub.entries.variables.kwargs import DOWNLOAD_INDEX from ytdl_sub.entries.variables.kwargs import EXT from ytdl_sub.entries.variables.kwargs import PLAYLIST_COUNT @@ -350,6 +351,16 @@ class EntryVariables(BaseEntryVariables): """ return self.kwargs_get(SOURCE_UPLOADER_URL, self.source_webpage_url) + @property + def creator(self: Self) -> str: + """ + Returns + ------- + str + The creator name if it exists, otherwise returns the channel. + """ + return self.kwargs_get(CREATOR, self.channel) + @property def channel(self: Self) -> str: """ diff --git a/src/ytdl_sub/entries/variables/kwargs.py b/src/ytdl_sub/entries/variables/kwargs.py index 65746ee4..0889f52f 100644 --- a/src/ytdl_sub/entries/variables/kwargs.py +++ b/src/ytdl_sub/entries/variables/kwargs.py @@ -54,6 +54,7 @@ EXTRACTOR = _("extractor") IE_KEY = _("ie_key") EPOCH = _("epoch") CHANNEL = _("channel") +CREATOR = _("creator") EXT = _("ext") TITLE = _("title") DESCRIPTION = _("description") diff --git a/tests/unit/entries/conftest.py b/tests/unit/entries/conftest.py index 0f5c83bb..096793af 100644 --- a/tests/unit/entries/conftest.py +++ b/tests/unit/entries/conftest.py @@ -69,6 +69,7 @@ def mock_entry_to_dict( "title_sanitized": "entry {title}", "ext": ext, "description": "", + "creator": "abc123", "channel": "abc123", "channel_sanitized": "abc123", "extractor": extractor,