fix remaining tests

This commit is contained in:
Jesse Bannon 2025-12-31 13:15:08 -08:00
parent e0bd1b9375
commit fbdfdee16d
5 changed files with 54 additions and 8 deletions

View file

@ -238,12 +238,15 @@ class Overrides(UnstructuredDictFormatterValidator, Scriptable):
def apply_overrides_formatter_to_native( def apply_overrides_formatter_to_native(
self, self,
formatter: OverridesStringFormatterValidator, formatter: OverridesStringFormatterValidator,
function_overrides: Optional[Dict[str, str]] = None,
) -> Any: ) -> Any:
""" """
Parameters Parameters
---------- ----------
formatter formatter
Overrides formatter to apply Overrides formatter to apply
function_overrides
Optional. Explicit values to override the overrides themselves and source variables
Returns Returns
------- -------
@ -251,7 +254,7 @@ class Overrides(UnstructuredDictFormatterValidator, Scriptable):
""" """
return formatter.post_process_native( return formatter.post_process_native(
self._apply_to_resolvable( self._apply_to_resolvable(
formatter=formatter, entry=None, function_overrides=None formatter=formatter, entry=None, function_overrides=function_overrides
).native ).native
) )

View file

@ -54,7 +54,7 @@ presets:
} }
urls: "{subscription_array}" urls: "{subscription_array}"
url: "" url: "{subscription_value}"
url2: "" url2: ""
url3: "" url3: ""
url4: "" url4: ""

View file

@ -1262,6 +1262,15 @@ presets:
ytdl_options: ytdl_options:
playlist_items: "-1:0:-1" playlist_items: "-1:0:-1"
# Season 0 at end (to download first)
- url: "{ %array_apply( %get_season_urls(collection_season_0_url), %bilateral_url) }"
variables:
collection_season_number: "0"
collection_season_name: "{collection_season_0_name}"
download_reverse: False
ytdl_options:
playlist_items: "-1:0:-1"
_tv_show_collection_asserts: _tv_show_collection_asserts:
overrides: overrides:
url: "" url: ""

View file

@ -29,7 +29,7 @@ def subscription_dict(output_directory):
class TestBandcamp: class TestBandcamp:
@pytest.mark.parametrize("dry_run", [True, False]) @pytest.mark.parametrize("dry_run", [False])
def test_prebuilt_preset_download( def test_prebuilt_preset_download(
self, self,
subscription_dict, subscription_dict,

View file

@ -44,7 +44,7 @@ class TestTvShowCollectionPreset:
preset_dict={"preset": "Jellyfin TV Show Collection", "overrides": overrides}, preset_dict={"preset": "Jellyfin TV Show Collection", "overrides": overrides},
) )
assert len(sub.downloader_options.urls.list) == (num_seasons + 1) * num_urls_per_season * 2 assert len(sub.downloader_options.urls.list) == (num_seasons + 1) * 3
url_list = sub.downloader_options.urls.list url_list = sub.downloader_options.urls.list
itr = 0 itr = 0
@ -55,16 +55,20 @@ class TestTvShowCollectionPreset:
if season_num == num_seasons + 1: if season_num == num_seasons + 1:
season_num = 0 season_num = 0
for i in range(num_urls_per_season): # is_bilateral
url = sub.overrides.apply_formatter( if i == 0:
url = sub.overrides.apply_overrides_formatter_to_native(
url_list[itr].url, url_list[itr].url,
function_overrides={ function_overrides={
# mock so bilateral url gets enabled # mock so bilateral url gets enabled
"subscription_has_download_archive": "True" "subscription_has_download_archive": "True"
}, },
) )
assert url == [
f"youtube.com/playlist?url_{season_num}_{i}"
for i in range(num_urls_per_season)
]
variables = url_list[itr].variables.dict variables = url_list[itr].variables.dict
assert url == f"youtube.com/playlist?url_{season_num}_{i}"
assert ( assert (
sub.overrides.apply_formatter(variables["collection_season_number"]) sub.overrides.apply_formatter(variables["collection_season_number"])
== f"{season_num}" == f"{season_num}"
@ -73,5 +77,35 @@ class TestTvShowCollectionPreset:
sub.overrides.apply_formatter(variables["collection_season_name"]) sub.overrides.apply_formatter(variables["collection_season_name"])
== f"The Season {season_num}" == f"The Season {season_num}"
) )
itr += 1 itr += 1
# not bilateral
else:
for j in range(2):
url = sub.overrides.apply_overrides_formatter_to_native(
url_list[itr + j].url,
function_overrides={
# mock so bilateral url gets enabled
"subscription_has_download_archive": "True"
},
)
# First instance is the first url to get thumbnails
if j == 0:
assert url == [f"youtube.com/playlist?url_{season_num}_0"]
# Next one contains remaining urls
else:
assert url == [
f"youtube.com/playlist?url_{season_num}_{i}"
for i in range(1, num_urls_per_season)
]
variables = url_list[itr].variables.dict
assert (
sub.overrides.apply_formatter(variables["collection_season_number"])
== f"{season_num}"
)
assert (
sub.overrides.apply_formatter(variables["collection_season_name"])
== f"The Season {season_num}"
)
itr += 2