ability to disable with empty string
This commit is contained in:
parent
761d01530d
commit
150ab69da2
5 changed files with 107 additions and 12 deletions
|
|
@ -642,6 +642,10 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC):
|
||||||
Downloads and moves channel avatar and banner images to the output directory.
|
Downloads and moves channel avatar and banner images to the output directory.
|
||||||
"""
|
"""
|
||||||
for thumbnail_info in thumbnail_list_info.list:
|
for thumbnail_info in thumbnail_list_info.list:
|
||||||
|
# If thumbnail name was set to empty, do nothing
|
||||||
|
if thumbnail_info.name is None:
|
||||||
|
continue
|
||||||
|
|
||||||
thumbnail_name = self.overrides.apply_formatter(thumbnail_info.name, entry=entry)
|
thumbnail_name = self.overrides.apply_formatter(thumbnail_info.name, entry=entry)
|
||||||
thumbnail_id = self.overrides.apply_formatter(thumbnail_info.uid)
|
thumbnail_id = self.overrides.apply_formatter(thumbnail_info.uid)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,8 +260,12 @@ class DictValidator(Validator):
|
||||||
-------
|
-------
|
||||||
An instance of the specified validator
|
An instance of the specified validator
|
||||||
"""
|
"""
|
||||||
|
# If the key does not exist and default is None, return None
|
||||||
if key not in self._dict and default is None:
|
if key not in self._dict and default is None:
|
||||||
return None
|
return None
|
||||||
|
# If the key exists but is None (null in YAML) or empty string, return None
|
||||||
|
if key in self._dict and self._dict[key] in (None, ""):
|
||||||
|
return None
|
||||||
|
|
||||||
return self._validate_key(key=key, validator=validator, default=default)
|
return self._validate_key(key=key, validator=validator, default=default)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import pytest
|
import pytest
|
||||||
from mergedeep import mergedeep
|
|
||||||
|
|
||||||
from conftest import preset_dict_to_dl_args
|
from conftest import preset_dict_to_dl_args
|
||||||
from e2e.conftest import mock_run_from_cli
|
from e2e.conftest import mock_run_from_cli
|
||||||
from expected_download import assert_expected_downloads
|
from expected_download import assert_expected_downloads
|
||||||
from expected_transaction_log import assert_transaction_log_matches
|
from expected_transaction_log import assert_transaction_log_matches
|
||||||
|
from mergedeep import mergedeep
|
||||||
|
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
|
|
||||||
|
|
@ -32,24 +31,24 @@ def single_video_preset_dict(output_directory):
|
||||||
"overrides": {"artist": "JMC"},
|
"overrides": {"artist": "JMC"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def single_tv_show_video_nulled_values_preset_dict(output_directory):
|
def single_tv_show_video_nulled_values_preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": [
|
"preset": [
|
||||||
"jellyfin_tv_show_by_date",
|
"jellyfin_tv_show_by_date",
|
||||||
"season_by_year__episode_by_download_index",
|
"season_by_year__episode_by_download_index",
|
||||||
|
"chunk_initial_download",
|
||||||
],
|
],
|
||||||
"download": {"url": "https://www.youtube.com/@ProjectZombie603"},
|
"download": {"url": "https://www.youtube.com/@ProjectZombie603"},
|
||||||
# set file output fields to None
|
# set file output fields to None
|
||||||
"output_options": {
|
"output_options": {
|
||||||
"thumbnail_name": None,
|
"thumbnail_name": "",
|
||||||
"info_json_name": None,
|
"info_json_name": "",
|
||||||
},
|
|
||||||
"nfo_tags": {
|
|
||||||
"nfo_name": None,
|
|
||||||
},
|
},
|
||||||
"ytdl_options": {
|
"ytdl_options": {
|
||||||
"format": "worst[ext=mp4]",
|
"format": "worst[ext=mp4]",
|
||||||
|
"max_downloads": 2,
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"tv_show_name": "Project Zombie",
|
"tv_show_name": "Project Zombie",
|
||||||
|
|
@ -117,12 +116,11 @@ class TestYoutubeVideo:
|
||||||
expected_download_summary_file_name="youtube/test_video_cli.json",
|
expected_download_summary_file_name="youtube/test_video_cli.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_single_video_nulled_values(
|
def test_single_video_nulled_values(
|
||||||
self,
|
self,
|
||||||
channel_as_tv_show_config,
|
channel_as_tv_show_config,
|
||||||
single_tv_show_video_nulled_values_preset_dict,
|
single_tv_show_video_nulled_values_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
):
|
):
|
||||||
single_video_subscription = Subscription.from_dict(
|
single_video_subscription = Subscription.from_dict(
|
||||||
config=channel_as_tv_show_config,
|
config=channel_as_tv_show_config,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
Files created:
|
||||||
|
----------------------------------------
|
||||||
|
{output_directory}
|
||||||
|
.ytdl-sub-tv_video_nulled_values-download-archive.json
|
||||||
|
fanart.jpg
|
||||||
|
poster.jpg
|
||||||
|
tvshow.nfo
|
||||||
|
NFO tags:
|
||||||
|
tvshow:
|
||||||
|
genre: ytdl-sub
|
||||||
|
title: Project Zombie
|
||||||
|
{output_directory}/Season 2010
|
||||||
|
s2010.e000001 - Oblivion Mod "Falcor" p.1.mp4
|
||||||
|
Video Tags:
|
||||||
|
date: 2010-08-13
|
||||||
|
episode_id: 1
|
||||||
|
genre: ytdl-sub
|
||||||
|
show: Project Zombie
|
||||||
|
synopsis:
|
||||||
|
https://www.youtube.com/watch?v=HKTNxEqsN3Q
|
||||||
|
|
||||||
|
PLEASE WATCH IN HD!
|
||||||
|
|
||||||
|
This is the castle in the mod "Falcor" which we are currently working on.
|
||||||
|
You can find some more information about the mod @ http://www.oblivionfalcormod.webs.com/
|
||||||
|
|
||||||
|
This is the first time I've really used the editor, and the beginning of our first mod. Hope you enjoy.
|
||||||
|
title: 2010-08-13 - Oblivion Mod "Falcor" p.1
|
||||||
|
year: 2010
|
||||||
|
s2010.e000001 - Oblivion Mod "Falcor" p.1.nfo
|
||||||
|
NFO tags:
|
||||||
|
episodedetails:
|
||||||
|
aired: 2010-08-13
|
||||||
|
episode: 1
|
||||||
|
genre: ytdl-sub
|
||||||
|
plot:
|
||||||
|
https://www.youtube.com/watch?v=HKTNxEqsN3Q
|
||||||
|
|
||||||
|
PLEASE WATCH IN HD!
|
||||||
|
|
||||||
|
This is the castle in the mod "Falcor" which we are currently working on.
|
||||||
|
You can find some more information about the mod @ http://www.oblivionfalcormod.webs.com/
|
||||||
|
|
||||||
|
This is the first time I've really used the editor, and the beginning of our first mod. Hope you enjoy.
|
||||||
|
season: 2010
|
||||||
|
title: 2010-08-13 - Oblivion Mod "Falcor" p.1
|
||||||
|
year: 2010
|
||||||
|
s2010.e000002 - Oblivion Mod "Falcor" p.2.mp4
|
||||||
|
Video Tags:
|
||||||
|
date: 2010-12-02
|
||||||
|
episode_id: 2
|
||||||
|
genre: ytdl-sub
|
||||||
|
show: Project Zombie
|
||||||
|
synopsis:
|
||||||
|
https://www.youtube.com/watch?v=IV9Z4wcA-z8
|
||||||
|
|
||||||
|
PLEASE WATCH IN HD.
|
||||||
|
|
||||||
|
Download Link:
|
||||||
|
http://www.tesnexus.com/downloads/file.php?id=36306
|
||||||
|
|
||||||
|
Please keep in mind that the mod is not complete, so you'll see some blank areas during the video. I haven't made LOD (Level of Distance) yet either, so areas far away will not appear.
|
||||||
|
title: 2010-12-02 - Oblivion Mod "Falcor" p.2
|
||||||
|
year: 2010
|
||||||
|
s2010.e000002 - Oblivion Mod "Falcor" p.2.nfo
|
||||||
|
NFO tags:
|
||||||
|
episodedetails:
|
||||||
|
aired: 2010-12-02
|
||||||
|
episode: 2
|
||||||
|
genre: ytdl-sub
|
||||||
|
plot:
|
||||||
|
https://www.youtube.com/watch?v=IV9Z4wcA-z8
|
||||||
|
|
||||||
|
PLEASE WATCH IN HD.
|
||||||
|
|
||||||
|
Download Link:
|
||||||
|
http://www.tesnexus.com/downloads/file.php?id=36306
|
||||||
|
|
||||||
|
Please keep in mind that the mod is not complete, so you'll see some blank areas during the video. I haven't made LOD (Level of Distance) yet either, so areas far away will not appear.
|
||||||
|
season: 2010
|
||||||
|
title: 2010-12-02 - Oblivion Mod "Falcor" p.2
|
||||||
|
year: 2010
|
||||||
|
|
@ -80,6 +80,13 @@ class TestDictValidator:
|
||||||
assert isinstance(out, StringValidator)
|
assert isinstance(out, StringValidator)
|
||||||
assert out.value == "default"
|
assert out.value == "default"
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("empty_value", [None, ""])
|
||||||
|
def test_dict_validator_validate_key_if_present_has_empty_value(self, empty_value):
|
||||||
|
dict_validator = DictValidator(name="validate_key", value={"key_name": empty_value})
|
||||||
|
out = dict_validator._validate_key_if_present(key="key_name", validator=StringValidator)
|
||||||
|
|
||||||
|
assert out is None
|
||||||
|
|
||||||
@pytest.mark.parametrize("bad_value", [True, None, {}])
|
@pytest.mark.parametrize("bad_value", [True, None, {}])
|
||||||
def test_dict_validator_validate_key_errors_none_bad_validation(self, bad_value):
|
def test_dict_validator_validate_key_errors_none_bad_validation(self, bad_value):
|
||||||
dict_validator = DictValidator(name="parent", value={"child": bad_value})
|
dict_validator = DictValidator(name="parent", value={"child": bad_value})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue