[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": { "soundcloud": {
"albums_and_singles": SoundcloudAlbumsAndSinglesDownloader, "albums_and_singles": SoundcloudAlbumsAndSinglesDownloader,
}, },
"generic": { "download": {
"collection": CollectionDownloader, "collection": CollectionDownloader,
"source": SourceDownloader, "source": SourceDownloader,
}, },

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
presets: presets:
kodi_music_video: kodi_music_video:
generic: download:
download_strategy: "source" download_strategy: "source"
url: "{music_video_url}" 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 from any single source. Uses latest entry's thumbnail as tv show poster
_tv_show_by_date: _tv_show_by_date:
generic: download:
download_strategy: "source" download_strategy: "source"
url: "{url}" url: "{url}"
playlist_thumbnails: playlist_thumbnails:
@ -42,7 +42,7 @@ presets:
# TV show from a collection. Must specify additional `tv_show_collection_season` presets in # TV show from a collection. Must specify additional `tv_show_collection_season` presets in
# addition. Each season sets its own `collection_season_number/_padded` # addition. Each season sets its own `collection_season_number/_padded`
_tv_show_collection: _tv_show_collection:
generic: download:
download_strategy: "collection" download_strategy: "collection"
overrides: overrides:

View file

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

View file

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