[FEATURE] Add subscription_name override variable by default
This commit is contained in:
parent
d5d9978cdb
commit
6aea62fcc1
7 changed files with 62 additions and 15 deletions
|
|
@ -110,9 +110,45 @@ class YTDLOptions(LiteralDictValidator):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class OverridesVariables(DictFormatterValidator):
|
||||||
|
"""
|
||||||
|
Override variables that are automatically added to every subscription.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _add_override_variable(self, key_name: str, format_string: str, sanitize: bool = False):
|
||||||
|
if sanitize:
|
||||||
|
key_name = f"{key_name}_sanitized"
|
||||||
|
format_string = sanitize_filename(format_string)
|
||||||
|
|
||||||
|
self._value[key_name] = StringFormatterValidator(
|
||||||
|
name="__should_never_fail__",
|
||||||
|
value=format_string,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, name, value):
|
||||||
|
super().__init__(name, value)
|
||||||
|
|
||||||
|
# Add sanitized and non-sanitized override variables
|
||||||
|
for sanitize in [True, False]:
|
||||||
|
self._add_override_variable(
|
||||||
|
key_name="subscription_name",
|
||||||
|
format_string=self.subscription_name,
|
||||||
|
sanitize=sanitize
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription_name(self) -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
Name of the subscription
|
||||||
|
"""
|
||||||
|
return self._root_name
|
||||||
|
|
||||||
|
|
||||||
# Disable for proper docstring formatting
|
# Disable for proper docstring formatting
|
||||||
# pylint: disable=line-too-long
|
# pylint: disable=line-too-long
|
||||||
class Overrides(DictFormatterValidator):
|
class Overrides(OverridesVariables):
|
||||||
"""
|
"""
|
||||||
Optional. This section allows you to define variables that can be used in any string formatter.
|
Optional. This section allows you to define variables that can be used in any string formatter.
|
||||||
For example, if you want your file and thumbnail files to match without copy-pasting a large
|
For example, if you want your file and thumbnail files to match without copy-pasting a large
|
||||||
|
|
@ -142,16 +178,6 @@ class Overrides(DictFormatterValidator):
|
||||||
|
|
||||||
# pylint: enable=line-too-long
|
# pylint: enable=line-too-long
|
||||||
|
|
||||||
def _add_override_variable(self, key_name: str, format_string: str, sanitize: bool = False):
|
|
||||||
if sanitize:
|
|
||||||
key_name = f"{key_name}_sanitized"
|
|
||||||
format_string = sanitize_filename(format_string)
|
|
||||||
|
|
||||||
self._value[key_name] = StringFormatterValidator(
|
|
||||||
name="__should_never_fail__",
|
|
||||||
value=format_string,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, name, value):
|
def __init__(self, name, value):
|
||||||
super().__init__(name, value)
|
super().__init__(name, value)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,16 @@ class DictValidator(Validator):
|
||||||
super().__init__(name, value)
|
super().__init__(name, value)
|
||||||
self.__validator_dict: Dict[str, Validator] = {}
|
self.__validator_dict: Dict[str, Validator] = {}
|
||||||
|
|
||||||
|
@final
|
||||||
|
@property
|
||||||
|
def _root_name(self) -> str:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
"first" from the first.element.of.the.name
|
||||||
|
"""
|
||||||
|
return self._name.split(".")[0]
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@property
|
@property
|
||||||
def _dict(self) -> dict:
|
def _dict(self) -> dict:
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@ def single_video_preset_dict(output_directory):
|
||||||
"ytdl_options": {
|
"ytdl_options": {
|
||||||
"format": "worst[ext=mp4]",
|
"format": "worst[ext=mp4]",
|
||||||
},
|
},
|
||||||
|
# test override variables added by ytdl-sub
|
||||||
|
"nfo_tags": {
|
||||||
|
"tags": {
|
||||||
|
"subscription_name": "{subscription_name}",
|
||||||
|
"subscription_name_sanitized": "{subscription_name_sanitized}",
|
||||||
|
}
|
||||||
|
},
|
||||||
# also test video tags
|
# also test video tags
|
||||||
"video_tags": {
|
"video_tags": {
|
||||||
"tags": {
|
"tags": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.info.json": "e4eb0e33920f9b4dce1fcba0561614c9",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.info.json": "1b12a13b9db6d37b350a57c7e6f37026",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.mp4": "3744c49f2e447bd7712a5aad5ed36be2",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.mp4": "3744c49f2e447bd7712a5aad5ed36be2",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.nfo": "24cc4e17d2bebc89b2759ce5471d403e"
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.nfo": "22e9d46ea7c243ac1f255adfd6c131ec"
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.info.json": "62101bc3899f69860004ddcfc061a28b",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.info.json": "57de511c9a97b1605165486875e73bc2",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.mp4": "3744c49f2e447bd7712a5aad5ed36be2",
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.mp4": "3744c49f2e447bd7712a5aad5ed36be2",
|
||||||
"JMC/JMC - Oblivion Mod "Falcor" p.1.nfo": "24cc4e17d2bebc89b2759ce5471d403e"
|
"JMC/JMC - Oblivion Mod "Falcor" p.1.nfo": "d5cc3019c647f77ca42eb1ad1e777f6d"
|
||||||
}
|
}
|
||||||
|
|
@ -11,5 +11,7 @@ Files created:
|
||||||
musicvideo:
|
musicvideo:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: JMC
|
artist: JMC
|
||||||
|
subscription_name: music_video_single_video_test
|
||||||
|
subscription_name_sanitized: music_video_single_video_test
|
||||||
title: Oblivion Mod "Falcor" p.1
|
title: Oblivion Mod "Falcor" p.1
|
||||||
year: 2010
|
year: 2010
|
||||||
|
|
@ -11,5 +11,7 @@ Files created:
|
||||||
musicvideo:
|
musicvideo:
|
||||||
album: Music Videos
|
album: Music Videos
|
||||||
artist: JMC
|
artist: JMC
|
||||||
|
subscription_name: cli-dl-0302c976
|
||||||
|
subscription_name_sanitized: cli-dl-0302c976
|
||||||
title: Oblivion Mod "Falcor" p.1
|
title: Oblivion Mod "Falcor" p.1
|
||||||
year: 2010
|
year: 2010
|
||||||
Loading…
Reference in a new issue