[REFACTOR] Rename generic download source to download (#309)

* [REFACTOR] Rename `generic` download source to `download`

* no change to download strategy
This commit is contained in:
Jesse Bannon 2022-11-06 16:24:06 -08:00 committed by GitHub
parent 6280ea562a
commit da22c9a608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 24 deletions

View file

@ -39,7 +39,7 @@ class DownloadStrategyMapping:
"soundcloud": {
"albums_and_singles": SoundcloudAlbumsAndSinglesDownloader,
},
"generic": {
"download": {
"collection": CollectionDownloader,
"source": SourceDownloader,
},

View file

@ -14,7 +14,7 @@ class CollectionDownloadOptions(CollectionValidator, DownloaderValidator):
presets:
my_example_preset:
generic:
download:
# required
download_strategy: "collection"
urls:

View file

@ -162,7 +162,7 @@ class CollectionValidator(StrictDictValidator, AddsVariablesMixin):
@classmethod
def partial_validate(cls, name: str, value: Any) -> None:
"""
Partially validate a generic collection
Partially validate a collection
"""
if isinstance(value, dict):
value["urls"] = value.get("urls", [{"url": "placeholder"}])

View file

@ -14,9 +14,9 @@ class SourceDownloadOptions(CollectionUrlValidator, DownloaderValidator):
presets:
my_example_preset:
generic:
download:
# required
download_strategy: "source"
download_strategy: "url"
url: "youtube.com/channel/UCsvn_Po0SmunchJYtttWpOxMg"
# optional
playlist_thumbnails:

View file

@ -1,7 +1,7 @@
presets:
kodi_music_video:
generic:
download:
download_strategy: "source"
url: "{music_video_url}"

View file

@ -28,7 +28,7 @@ presets:
# TV show from any single source. Uses latest entry's thumbnail as tv show poster
_tv_show_by_date:
generic:
download:
download_strategy: "source"
url: "{url}"
playlist_thumbnails:
@ -42,7 +42,7 @@ 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:
generic:
download:
download_strategy: "collection"
overrides:

View file

@ -17,7 +17,7 @@ presets:
- "_tv_show_collection"
collection_season_1:
generic:
download:
download_strategy: "collection"
urls:
- url: "{collection_season_1_url}"
@ -42,7 +42,7 @@ presets:
number: "1"
collection_season_2:
generic:
download:
download_strategy: "collection"
urls:
- url: "{collection_season_2_url}"
@ -61,7 +61,7 @@ presets:
number: "2"
collection_season_3:
generic:
download:
download_strategy: "collection"
urls:
- url: "{collection_season_3_url}"
@ -80,7 +80,7 @@ presets:
number: "3"
collection_season_4:
generic:
download:
download_strategy: "collection"
urls:
- url: "{collection_season_4_url}"
@ -99,7 +99,7 @@ presets:
number: "4"
collection_season_5:
generic:
download:
download_strategy: "collection"
urls:
- url: "{collection_season_5_url}"

View file

@ -68,31 +68,31 @@ class TestConfigFilePartiallyValidatesPresets:
def test_error__multiple_sources(self):
self._partial_validate(
preset_dict={"youtube": {}, "generic": {}},
preset_dict={"youtube": {}, "download": {}},
expected_error_message="Validation error in partial_preset: "
"Contains the sources generic, youtube but can only have one",
"Contains the sources download, youtube but can only have one",
)
def test_error__no_download_strategy(self):
self._partial_validate(
preset_dict={"generic": {}},
expected_error_message="Validation error in partial_preset.generic: "
preset_dict={"download": {}},
expected_error_message="Validation error in partial_preset.download: "
"missing the required field 'download_strategy'",
)
def test_error__bad_download_strategy(self):
self._partial_validate(
preset_dict={"generic": {"download_strategy": "fail"}},
expected_error_message="Validation error in partial_preset.generic: "
"Tried to use download strategy 'fail' with source 'generic', "
preset_dict={"download": {"download_strategy": "fail"}},
expected_error_message="Validation error in partial_preset.download: "
"Tried to use download strategy 'fail' with source 'download', "
"which does not exist. Available download strategies: collection, source",
)
def test_error__bad_download_strategy_args(self):
self._partial_validate(
preset_dict={"generic": {"download_strategy": "collection", "bad_key": "nope"}},
expected_error_message="Validation error in partial_preset.generic: "
"'partial_preset.generic' contains the field 'bad_key' which is not allowed. "
preset_dict={"download": {"download_strategy": "collection", "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: urls",
)
@ -100,7 +100,7 @@ class TestConfigFilePartiallyValidatesPresets:
"preset_dict",
[
{"nfo_tags": {"tags": {"key-1": {"attributes": {"test": "2"}}}}},
{"generic": {"urls": [{"variables_to_set": {"name": "value"}}]}},
{"download": {"urls": [{"variables_to_set": {"name": "value"}}]}},
],
)
def test_partial_validate__incomplete_list_item(self, preset_dict):