updated fixtures

This commit is contained in:
Jesse Bannon 2026-01-23 19:41:37 -08:00
parent dd28780030
commit 5f246b419c
5 changed files with 46 additions and 56 deletions

View file

@ -11,7 +11,6 @@ from ytdl_sub.script.types.syntax_tree import SyntaxTree
from ytdl_sub.script.utils.exceptions import RuntimeException
from ytdl_sub.script.utils.exceptions import ScriptVariableNotResolved
from ytdl_sub.script.utils.exceptions import UserException
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
from ytdl_sub.utils.exceptions import StringFormattingVariableNotFoundException
from ytdl_sub.utils.script import ScriptUtils
from ytdl_sub.validators.validators import DictValidator
@ -225,28 +224,16 @@ class UnstructuredOverridesDictFormatterValidator(UnstructuredDictFormatterValid
_key_validator = OverridesStringFormatterValidator
def to_variable_dependency_format_string(script: Script, parsed_format_string: SyntaxTree) -> str:
"""
Create a dummy format string that contains all variable deps as a string.
"""
dummy_format_string = ""
for var in parsed_format_string.variables:
dummy_format_string += f"{{ {var.name} }}"
for variable_dependency in script._variables[var.name].variables:
dummy_format_string += f"{{ {variable_dependency.name} }}"
return dummy_format_string
def _validate_formatter(
mock_script: Script,
unresolved_variables: Set[str],
unresolved_runtime_variables: Set[str],
formatter_validator: Union[StringFormatterValidator, OverridesStringFormatterValidator],
partial_resolve_entry_formatters: bool,
) -> str:
) -> Any:
parsed = formatter_validator.parsed
if resolved := parsed.maybe_resolvable:
return resolved.native
return formatter_validator.post_process(resolved.native)
is_static_formatter = isinstance(formatter_validator, OverridesStringFormatterValidator)
@ -282,11 +269,16 @@ def _validate_formatter(
try:
if is_static_formatter:
return mock_script.resolve_once_parsed(
{"tmp_var": formatter_validator.parsed},
unresolvable=unresolved_variables,
update=True,
)["tmp_var"].native
return formatter_validator.post_process(
mock_script.resolve_once_parsed(
{"tmp_var": formatter_validator.parsed},
unresolvable=unresolved_variables,
update=True,
)["tmp_var"].native
)
if maybe_resolved := parsed.maybe_resolvable:
return formatter_validator.post_process(maybe_resolved)
return ScriptUtils.to_native_script(parsed)
except RuntimeException as exc:
@ -296,12 +288,6 @@ def _validate_formatter(
"entry variables"
) from exc
raise StringFormattingVariableNotFoundException(exc) from exc
except UserThrownRuntimeError as exc:
# Errors are expected for non-static formatters due to missing entry
# data. Raise otherwise.
if not is_static_formatter:
return formatter_validator.format_string
raise exc
def validate_formatters(

View file

@ -2,17 +2,17 @@
"chapters": {
"allow_chapters_from_comments": false,
"embed_chapters": true,
"enable": "True",
"enable": true,
"force_key_frames": false
},
"date_range": {
"breaks": "True",
"enable": "True",
"breaks": true,
"enable": true,
"type": "upload_date"
},
"download": [
{
"download_reverse": "True",
"download_reverse": true,
"include_sibling_metadata": false,
"playlist_thumbnails": [
{
@ -34,7 +34,9 @@
"uid": "banner_uncropped"
}
],
"url": "https://www.youtube.com/@novapbs",
"url": [
"https://www.youtube.com/@novapbs"
],
"variables": {},
"webpage_url": "{ %map_get( entry_metadata, \"webpage_url\" ) }",
"ytdl_options": {}
@ -43,7 +45,7 @@
"file_convert": {
"convert_to": "mp4",
"convert_with": "yt-dlp",
"enable": "True"
"enable": true
},
"format": "(bv*[ext=mp4][vcodec~='^((he|a)vc|h26[45])']+ba[ext=m4a]) / (bv[ext=mp4]*+ba[ext=m4a]/b)",
"output_options": {
@ -52,7 +54,7 @@
"info_json_name": "{ %concat( %string( %sanitize( %concat( \"Season \", %string( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"year\" ) ) ) ) ) ), \"/\", %string( %sanitize( %concat( \"s\", %string( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"year\" ) ) ), \".e\", %string( %pad_zero( %int( %concat( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"month\" ) ), %string( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"day_padded\" ) ), %pad_zero( upload_date_index, 2 ) ) ), 6 ) ), \" - \", %string( %sanitize_plex_episode( %map_get_non_empty( entry_metadata, \"title\", %map_get( entry_metadata, \"id\" ) ) ) ) ) ) ) ) }.info.json",
"keep_files_date_eval": "{ %string( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"date_standardized\" ) ) }",
"maintain_download_archive": true,
"output_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmp_iqgtgmn/NOVA PBS",
"output_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmp8vzxo6z8/NOVA PBS",
"preserve_mtime": false,
"thumbnail_name": "{ %concat( %string( %sanitize( %concat( \"Season \", %string( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"year\" ) ) ) ) ) ), \"/\", %string( %sanitize( %concat( \"s\", %string( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"year\" ) ) ), \".e\", %string( %pad_zero( %int( %concat( %int( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"month\" ) ), %string( %map_get( %to_date_metadata( %map_get_non_empty( entry_metadata, \"upload_date\", %datetime_strftime( %map_get( entry_metadata, \"epoch\" ), \"%Y%m%d\" ) ) ), \"day_padded\" ) ), %pad_zero( upload_date_index, 2 ) ) ), 6 ) ), \" - \", %string( %sanitize_plex_episode( %map_get_non_empty( entry_metadata, \"title\", %map_get( entry_metadata, \"id\" ) ) ) ) ) ) ) ) }-thumb.jpg"
},
@ -110,7 +112,7 @@
"tv_show_content_rating": "TV-14",
"tv_show_content_rating_default": "TV-14",
"tv_show_date_range_type": "upload_date",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmp_iqgtgmn",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmp8vzxo6z8",
"tv_show_fanart_file_name": "fanart.jpg",
"tv_show_genre": "Documentaries",
"tv_show_genre_default": "ytdl-sub",
@ -223,16 +225,16 @@
"throttle_protection": {
"enable": true,
"sleep_per_download_s": {
"max": "28.4",
"min": "13.8"
"max": 28.4,
"min": 13.8
},
"sleep_per_request_s": {
"max": "0.75",
"min": "0.0"
"max": 0.75,
"min": 0.0
},
"sleep_per_subscription_s": {
"max": "26.1",
"min": "16.3"
"max": 26.1,
"min": 16.3
}
},
"video_tags": {

View file

@ -109,7 +109,7 @@
"tv_show_content_rating": "{subscription_indent_2}",
"tv_show_content_rating_default": "TV-14",
"tv_show_date_range_type": "{\n %if(\n %contains(tv_show_by_date_season_ordering, \"release\"),\n \"release_date\",\n \"upload_date\"\n )\n}",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmpjjbduqm_",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmpg7qxc12z",
"tv_show_fanart_file_name": "fanart.jpg",
"tv_show_genre": "{subscription_indent_1}",
"tv_show_genre_default": "ytdl-sub",

View file

@ -2,17 +2,17 @@
"chapters": {
"allow_chapters_from_comments": false,
"embed_chapters": true,
"enable": "True",
"enable": true,
"force_key_frames": false
},
"date_range": {
"breaks": "True",
"enable": "True",
"breaks": true,
"enable": true,
"type": "upload_date"
},
"download": [
{
"download_reverse": "True",
"download_reverse": true,
"include_sibling_metadata": false,
"playlist_thumbnails": [
{
@ -34,7 +34,9 @@
"uid": "banner_uncropped"
}
],
"url": "https://www.youtube.com/@novapbs",
"url": [
"https://www.youtube.com/@novapbs"
],
"variables": {},
"webpage_url": "{ webpage_url }",
"ytdl_options": {}
@ -43,7 +45,7 @@
"file_convert": {
"convert_to": "mp4",
"convert_with": "yt-dlp",
"enable": "True"
"enable": true
},
"format": "(bv*[ext=mp4][vcodec~='^((he|a)vc|h26[45])']+ba[ext=m4a]) / (bv[ext=mp4]*+ba[ext=m4a]/b)",
"output_options": {
@ -52,7 +54,7 @@
"info_json_name": "{ %concat( %string( %sanitize( %concat( \"Season \", %string( upload_year ) ) ) ), \"/\", %string( %sanitize( %concat( \"s\", %string( upload_year ), \".e\", %string( %pad_zero( %int( %concat( upload_month, upload_day_padded, upload_date_index_padded ) ), 6 ) ), \" - \", %string( title_sanitized_plex ) ) ) ) ) }.{ info_json_ext }",
"keep_files_date_eval": "{ upload_date_standardized }",
"maintain_download_archive": true,
"output_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmptcec16mv/NOVA PBS",
"output_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmpk9271nih/NOVA PBS",
"preserve_mtime": false,
"thumbnail_name": "{ %concat( %string( %sanitize( %concat( \"Season \", %string( upload_year ) ) ) ), \"/\", %string( %sanitize( %concat( \"s\", %string( upload_year ), \".e\", %string( %pad_zero( %int( %concat( upload_month, upload_day_padded, upload_date_index_padded ) ), 6 ) ), \" - \", %string( title_sanitized_plex ) ) ) ) ) }-thumb.jpg"
},
@ -110,7 +112,7 @@
"tv_show_content_rating": "TV-14",
"tv_show_content_rating_default": "TV-14",
"tv_show_date_range_type": "upload_date",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmptcec16mv",
"tv_show_directory": "/var/folders/rw/hl1xmkmj68zdl2kjx3l0dwzc0000gn/T/tmpk9271nih",
"tv_show_fanart_file_name": "fanart.jpg",
"tv_show_genre": "Documentaries",
"tv_show_genre_default": "ytdl-sub",
@ -223,16 +225,16 @@
"throttle_protection": {
"enable": true,
"sleep_per_download_s": {
"max": "28.4",
"min": "13.8"
"max": 28.4,
"min": 13.8
},
"sleep_per_request_s": {
"max": "0.75",
"min": "0.0"
"max": 0.75,
"min": 0.0
},
"sleep_per_subscription_s": {
"max": "26.1",
"min": "16.3"
"max": 26.1,
"min": 16.3
}
},
"video_tags": {

View file

@ -23,7 +23,7 @@ def _ensure_resolved_yaml(
if resolution_level > ResolutionLevel.ORIGINAL:
expected_out["output_options"]["output_directory"] = FilePathTruncater.to_native_filepath(
str(Path(output_directory) / "ass")
str(Path(output_directory) / sub.name)
)
if "tv_show_directory" in expected_out["overrides"]: