[REFACTOR] Purge download_strategy from configs + tests (#670)
This commit is contained in:
parent
d24048bb01
commit
598b1da8a4
13 changed files with 11 additions and 111 deletions
|
|
@ -17,9 +17,6 @@ configuration:
|
|||
presets:
|
||||
|
||||
video:
|
||||
download:
|
||||
download_strategy: "url"
|
||||
|
||||
output_options:
|
||||
output_directory: "/tmp/ytdl-sub-output"
|
||||
file_name: "{uid}.{ext}"
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ presets:
|
|||
preset: "base"
|
||||
|
||||
download:
|
||||
download_strategy: "url"
|
||||
url: "{url}"
|
||||
|
||||
####################################################################################################
|
||||
|
|
@ -166,7 +165,6 @@ presets:
|
|||
|
||||
# Download using the multi_url strategy
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
# The first URL will be all the artist's tracks.
|
||||
# Treat these as singles - an album with a single track
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ presets:
|
|||
download:
|
||||
# We will only use a single URL to download music video(s).
|
||||
# Make {url} an override variable to set later.
|
||||
download_strategy: "url"
|
||||
url: "{url}"
|
||||
|
||||
# For advanced YTDL users only; any YTDL parameter can be set here.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class MultiUrlDownloadOptions(MultiUrlValidator):
|
|||
my_example_preset:
|
||||
download:
|
||||
# required
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "youtube.com/channel/UCsvn_Po0SmunchJYtttWpOxMg"
|
||||
variables:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class UrlDownloadOptions(UrlValidator):
|
|||
my_example_preset:
|
||||
download:
|
||||
# required
|
||||
download_strategy: "url"
|
||||
url: "youtube.com/channel/UCsvn_Po0SmunchJYtttWpOxMg"
|
||||
# optional
|
||||
playlist_thumbnails:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ presets:
|
|||
|
||||
_view:
|
||||
download:
|
||||
download_strategy: "url"
|
||||
url: "{url}"
|
||||
output_options:
|
||||
output_directory: "/tmp/ytdl-sub-view"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ presets:
|
|||
# TODO: Update this
|
||||
kodi_music_video:
|
||||
download:
|
||||
download_strategy: "url"
|
||||
url: "{music_video_url}"
|
||||
|
||||
output_options:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ presets:
|
|||
# TV show from one or more sources. Uses {url}'s avatar and banner as poster and fanart
|
||||
_tv_show_by_date:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{url}"
|
||||
playlist_thumbnails:
|
||||
|
|
@ -87,9 +86,6 @@ presets:
|
|||
# TV show from a collection. Must specify additional `tv_show_collection_season` presets in
|
||||
# addition. Each season sets its own `collection_season_number/_padded`
|
||||
_tv_show_collection:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
|
||||
overrides:
|
||||
season_number: "{collection_season_number}"
|
||||
season_number_padded: "{collection_season_number_padded}"
|
||||
|
|
@ -21,7 +21,6 @@ presets:
|
|||
|
||||
collection_season_1:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_1_url}"
|
||||
variables:
|
||||
|
|
@ -46,7 +45,6 @@ presets:
|
|||
|
||||
collection_season_2:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_2_url}"
|
||||
variables:
|
||||
|
|
@ -65,7 +63,6 @@ presets:
|
|||
|
||||
collection_season_3:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_3_url}"
|
||||
variables:
|
||||
|
|
@ -84,7 +81,6 @@ presets:
|
|||
|
||||
collection_season_4:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_4_url}"
|
||||
variables:
|
||||
|
|
@ -103,7 +99,6 @@ presets:
|
|||
|
||||
collection_season_5:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_5_url}"
|
||||
variables:
|
||||
|
|
@ -122,7 +117,6 @@ presets:
|
|||
|
||||
collection_season_6:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_6_url}"
|
||||
variables:
|
||||
|
|
@ -141,7 +135,6 @@ presets:
|
|||
|
||||
collection_season_7:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_7_url}"
|
||||
variables:
|
||||
|
|
@ -160,7 +153,6 @@ presets:
|
|||
|
||||
collection_season_8:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_8_url}"
|
||||
variables:
|
||||
|
|
@ -179,7 +171,6 @@ presets:
|
|||
|
||||
collection_season_9:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_9_url}"
|
||||
variables:
|
||||
|
|
@ -198,7 +189,6 @@ presets:
|
|||
|
||||
collection_season_10:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_10_url}"
|
||||
variables:
|
||||
|
|
@ -217,7 +207,6 @@ presets:
|
|||
|
||||
collection_season_11:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_11_url}"
|
||||
variables:
|
||||
|
|
@ -236,7 +225,6 @@ presets:
|
|||
|
||||
collection_season_12:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_12_url}"
|
||||
variables:
|
||||
|
|
@ -255,7 +243,6 @@ presets:
|
|||
|
||||
collection_season_13:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_13_url}"
|
||||
variables:
|
||||
|
|
@ -274,7 +261,6 @@ presets:
|
|||
|
||||
collection_season_14:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_14_url}"
|
||||
variables:
|
||||
|
|
@ -293,7 +279,6 @@ presets:
|
|||
|
||||
collection_season_15:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_15_url}"
|
||||
variables:
|
||||
|
|
@ -312,7 +297,6 @@ presets:
|
|||
|
||||
collection_season_16:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_16_url}"
|
||||
variables:
|
||||
|
|
@ -331,7 +315,6 @@ presets:
|
|||
|
||||
collection_season_17:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_17_url}"
|
||||
variables:
|
||||
|
|
@ -350,7 +333,6 @@ presets:
|
|||
|
||||
collection_season_18:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_18_url}"
|
||||
variables:
|
||||
|
|
@ -369,7 +351,6 @@ presets:
|
|||
|
||||
collection_season_19:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_19_url}"
|
||||
variables:
|
||||
|
|
@ -388,7 +369,6 @@ presets:
|
|||
|
||||
collection_season_20:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_20_url}"
|
||||
variables:
|
||||
|
|
@ -407,7 +387,6 @@ presets:
|
|||
|
||||
collection_season_21:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_21_url}"
|
||||
variables:
|
||||
|
|
@ -426,7 +405,6 @@ presets:
|
|||
|
||||
collection_season_22:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_22_url}"
|
||||
variables:
|
||||
|
|
@ -445,7 +423,6 @@ presets:
|
|||
|
||||
collection_season_23:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_23_url}"
|
||||
variables:
|
||||
|
|
@ -464,7 +441,6 @@ presets:
|
|||
|
||||
collection_season_24:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_24_url}"
|
||||
variables:
|
||||
|
|
@ -483,7 +459,6 @@ presets:
|
|||
|
||||
collection_season_25:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_25_url}"
|
||||
variables:
|
||||
|
|
@ -502,7 +477,6 @@ presets:
|
|||
|
||||
collection_season_26:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_26_url}"
|
||||
variables:
|
||||
|
|
@ -521,7 +495,6 @@ presets:
|
|||
|
||||
collection_season_27:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_27_url}"
|
||||
variables:
|
||||
|
|
@ -540,7 +513,6 @@ presets:
|
|||
|
||||
collection_season_28:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_28_url}"
|
||||
variables:
|
||||
|
|
@ -559,7 +531,6 @@ presets:
|
|||
|
||||
collection_season_29:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_29_url}"
|
||||
variables:
|
||||
|
|
@ -578,7 +549,6 @@ presets:
|
|||
|
||||
collection_season_30:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_30_url}"
|
||||
variables:
|
||||
|
|
@ -597,7 +567,6 @@ presets:
|
|||
|
||||
collection_season_31:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_31_url}"
|
||||
variables:
|
||||
|
|
@ -616,7 +585,6 @@ presets:
|
|||
|
||||
collection_season_32:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_32_url}"
|
||||
variables:
|
||||
|
|
@ -635,7 +603,6 @@ presets:
|
|||
|
||||
collection_season_33:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_33_url}"
|
||||
variables:
|
||||
|
|
@ -654,7 +621,6 @@ presets:
|
|||
|
||||
collection_season_34:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_34_url}"
|
||||
variables:
|
||||
|
|
@ -673,7 +639,6 @@ presets:
|
|||
|
||||
collection_season_35:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_35_url}"
|
||||
variables:
|
||||
|
|
@ -692,7 +657,6 @@ presets:
|
|||
|
||||
collection_season_36:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_36_url}"
|
||||
variables:
|
||||
|
|
@ -711,7 +675,6 @@ presets:
|
|||
|
||||
collection_season_37:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_37_url}"
|
||||
variables:
|
||||
|
|
@ -730,7 +693,6 @@ presets:
|
|||
|
||||
collection_season_38:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_38_url}"
|
||||
variables:
|
||||
|
|
@ -749,7 +711,6 @@ presets:
|
|||
|
||||
collection_season_39:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_39_url}"
|
||||
variables:
|
||||
|
|
@ -768,7 +729,6 @@ presets:
|
|||
|
||||
collection_season_40:
|
||||
download:
|
||||
download_strategy: "multi_url"
|
||||
urls:
|
||||
- url: "{collection_season_40_url}"
|
||||
variables:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ from ytdl_sub.utils.exceptions import ValidationException
|
|||
def single_song_video_dict(output_directory):
|
||||
return {
|
||||
"download": {
|
||||
"download_strategy": "url",
|
||||
"url": "https://www.youtube.com/watch?v=2lAe1cqCOXo",
|
||||
},
|
||||
"output_options": {"output_directory": output_directory, "file_name": "will_error.mp4"},
|
||||
|
|
|
|||
|
|
@ -48,6 +48,5 @@ def output_options() -> Dict:
|
|||
@pytest.fixture
|
||||
def youtube_video() -> Dict:
|
||||
return {
|
||||
"download_strategy": "url",
|
||||
"url": "youtube.com/watch?v=123abc",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,17 +64,9 @@ class TestConfigFilePartiallyValidatesPresets:
|
|||
f"Allowed fields: {', '.join(sorted(PRESET_KEYS))}",
|
||||
)
|
||||
|
||||
# TODO: Update with future source
|
||||
# def test_error__multiple_sources(self):
|
||||
# self._partial_validate(
|
||||
# preset_dict={"youtube": {}, "download": {}},
|
||||
# expected_error_message="Validation error in partial_preset: "
|
||||
# "Contains the sources download, youtube but can only have one",
|
||||
# )
|
||||
|
||||
def test_error__bad_download_strategy_args(self):
|
||||
def test_error__download_args(self):
|
||||
self._partial_validate(
|
||||
preset_dict={"download": {"download_strategy": "multi_url", "bad_key": "nope"}},
|
||||
preset_dict={"download": {"bad_key": "nope"}},
|
||||
expected_error_message="Validation error in partial_preset.download: "
|
||||
"'partial_preset.download' contains the field 'bad_key' which is not allowed. "
|
||||
"Allowed fields: download_reverse, playlist_thumbnails, source_thumbnails, url, "
|
||||
|
|
@ -138,30 +130,3 @@ class TestConfigFilePartiallyValidatesPresets:
|
|||
expected_error_message="Validation error in partial_preset: "
|
||||
"preset 'DNE' does not exist in the provided config.",
|
||||
)
|
||||
|
||||
def test_partial_validate_partial_download_strategy(self):
|
||||
_ = ConfigFile(
|
||||
name="test_partial_validate",
|
||||
value={
|
||||
"configuration": {"working_directory": "."},
|
||||
"presets": {
|
||||
"parent": {"download": {"download_strategy": "url"}},
|
||||
"child": {"preset": "parent", "download": {"url": "should work"}},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def test_partial_validate_partial_download_strategies(self):
|
||||
_ = ConfigFile(
|
||||
name="test_partial_validate",
|
||||
value={
|
||||
"configuration": {"working_directory": "."},
|
||||
"presets": {
|
||||
"parent": {"download": {"download_strategy": "url"}},
|
||||
"child": {
|
||||
"preset": "parent",
|
||||
"download": {"download_strategy": "url", "url": "should work"},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,28 +10,21 @@ from ytdl_sub.utils.exceptions import ValidationException
|
|||
|
||||
class TestPreset:
|
||||
@pytest.mark.parametrize(
|
||||
"source, download_strategy",
|
||||
"download_value",
|
||||
[
|
||||
("download", {"download_strategy": "url", "url": "youtube.com/watch?v=123abc"}),
|
||||
(
|
||||
"download",
|
||||
{
|
||||
"download_strategy": "url",
|
||||
"url": "youtube.com/playlist?list=123abc",
|
||||
},
|
||||
),
|
||||
("download", {"download_strategy": "url", "url": "youtube.com/c/123abc"}),
|
||||
(
|
||||
"download",
|
||||
{"download_strategy": "url", "url": "soundcloud.com/123abc"},
|
||||
),
|
||||
{"url": "youtube.com/watch?v=123abc"},
|
||||
{"urls": [{"url": "youtube.com/watch?v=123abc"}]},
|
||||
###########################################################
|
||||
##### OLD download_strategy format
|
||||
{"download_strategy": "url", "url": "youtube.com/watch?v=123abc"},
|
||||
{"download_strategy": "multi-url", "urls": [{"url": "youtube.com/watch?v=123abc"}]},
|
||||
],
|
||||
)
|
||||
def test_bare_minimum_preset(self, config_file, output_options, source, download_strategy):
|
||||
def test_bare_minimum_preset(self, config_file, output_options, download_value):
|
||||
_ = Preset(
|
||||
config=config_file,
|
||||
name="test",
|
||||
value={source: download_strategy, "output_options": output_options},
|
||||
value={"download": download_value, "output_options": output_options},
|
||||
)
|
||||
|
||||
def test_preset_with_override_variable(self, config_file, output_options, youtube_video):
|
||||
|
|
@ -209,7 +202,6 @@ class TestPreset:
|
|||
name="test",
|
||||
value={
|
||||
"download": {
|
||||
"download_strategy": "multi_url",
|
||||
"urls": [{"url": "non-empty url"}, {"url": ""}], # empty url
|
||||
},
|
||||
"output_options": output_options,
|
||||
|
|
@ -231,7 +223,6 @@ class TestPreset:
|
|||
name="test",
|
||||
value={
|
||||
"download": {
|
||||
"download_strategy": "multi_url",
|
||||
"urls": [{"url": "{url}"}, {"url": "{url2}"}],
|
||||
},
|
||||
"output_options": output_options,
|
||||
|
|
|
|||
Loading…
Reference in a new issue