mirror of
https://github.com/ytdl-org/ytdl-nightly.git
synced 2025-06-05 21:49:13 +02:00
Improve output template internal formatting
* Allow slicing lists/strings using `field.start🔚step`
* A field can also be used as offset like `field1+num+field2`
* A default value can be given using `field|default`
* Capture all format strings and set it to `None` if invalid. This prevents invalid fields from causing errors
This commit is contained in:
@@ -6112,11 +6112,11 @@ def traverse_dict(dictn, keys, casesense=True):
|
||||
key = key.lower()
|
||||
dictn = dictn.get(key)
|
||||
elif isinstance(dictn, (list, tuple, compat_str)):
|
||||
key, n = int_or_none(key), len(dictn)
|
||||
if key is not None and -n <= key < n:
|
||||
dictn = dictn[key]
|
||||
if ':' in key:
|
||||
key = slice(*map(int_or_none, key.split(':')))
|
||||
else:
|
||||
dictn = None
|
||||
key = int_or_none(key)
|
||||
dictn = try_get(dictn, lambda x: x[key])
|
||||
else:
|
||||
return None
|
||||
return dictn
|
||||
|
Reference in New Issue
Block a user