dirkf
6315f4b1df
[utils] Support additional codecs and dynamic_range
2 weeks ago
dirkf
43e3121020
[utils] Align `parse_duration()` behaviour with yt-dlp
...
* handle comma-separated long-form durations
* support : as millisecond separator.
2 weeks ago
dirkf
7a488f7fae
[utils] Stabilise traversal results using `compat_dict`
...
In `traverse_obj()`, use `compat_dict` to construct dicts,
ensuring insertion order sort, but`compat_builtin_dict`
to test for dict-iness...
2 weeks ago
dirkf
70b40dd1ef
[utils] Add `subs_list_to_dict()` traversal helper
...
Thx: yt-dlp/yt-dlp#10653 , etc
2 weeks ago
dirkf
a9b4649d92
[utils] Apply `partial_application` decorator to existing functions
...
Thx: yt-dlp/yt-dlp#10653 (etc)
2 weeks ago
dirkf
23a848c314
[utils] Add `partial_application` decorator function
...
Thx: yt-dlp/yt-dlp#10653
2 weeks ago
dirkf
68fe8c1781
[utils] Support traversal helper functions `require`, `value`, `unpack`
...
Thx: yt-dlp/yt-dlp#10653
2 weeks ago
dirkf
96419fa706
[utils] Support `filter` traversal key
...
Thx yt-dlp/yt-dlp#10653
2 weeks ago
dirkf
2190e89260
[utils] Support optional `safe` argument for `escape_rfc3986()`
8 months ago
bashonly
43a74c5fa5
[core] Address gaps in allowed extensions
...
Adds some extensions missing in 4652109643
(from yt-dlp/yt-dlp#10362 )
Authored by: bashonly
Co-authored by: dirkf
1 year ago
dirkf
37cea84f77
[core,utils] Support unpublicised `--no-check-extensions`
1 year ago
dirkf
4652109643
[core,utils] Implement unsafe file extension mitigation
...
* from https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-79w7-vh3h-8g4 , thx grub4k
1 year ago
dirkf
3c466186a8
[utils] Back-port Namespace and MEDIA_EXTENSIONS from yt-dlp
...
Thx pukkandan
* Namespace: https://github.com/yt-dlp/yt-dlp/commit/591bb9d355
* MEDIA_EXTENSIONS: https://github.com/yt-dlp/yt-dlp/commit/8dc5930511
1 year ago
dirkf
2eac0fa379
[utils] Save `orig_msg` in `ExtractorError`
1 year ago
dirkf
06da64ee51
[utils] Update traverse_obj() from yt-dlp
...
* remove `is_user_input` option per https://github.com/yt-dlp/yt-dlp/pull/8673
* support traversal of compat_xml_etree_ElementTree_Element per https://github.com/yt-dlp/yt-dlp/pull/8911
* allow un/branching using all and any per https://github.com/yt-dlp/yt-dlp/pull/9571
* support traversal of compat_cookies.Morsel and multiple types in `set()` keys per https://github.com/yt-dlp/yt-dlp/pull/9577
thx Grub4k for these
* also, move traversal tests to a separate class
* allow for unordered dicts in tests for Py<3.7
2 years ago
Ori Avtalion
4ea59c6107
[utils] Fix crash in _report_ignoring_subs from c58b655 ( #32762 )
...
Align `utils.bug_reports_message()` with yt-dlp https://github.com/yt-dlp/yt-dlp/commit/5873d4ccdd , thanks fstirlitz
---------
Co-authored-by: dirkf <fieldhouse@gmx.net>
2 years ago
dirkf
19dc10b986
[utils] Apply compat_contextlib_suppress
2 years ago
dirkf
acc383b9e3
[utils] Let int_or_none() accept a base, like int()
2 years ago
Hubert Hirtz
f0812d7848
[utils] Handle user:pass in URLs ( #28801 )
...
* Handle user:pass in URLs
Fixes "nonnumeric port" errors when youtube-dl is given URLs with
usernames and passwords such as:
http://username:password@example.com/myvideo.mp4
Refs:
- https://en.wikipedia.org/wiki/Basic_access_authentication
- https://tools.ietf.org/html/rfc1738#section-3.1
- https://docs.python.org/3.8/library/urllib.parse.html#urllib.parse.urlsplit
Fixes #18276 (point 4)
Fixes #20258
Fixes #26211 (see comment)
* Align code with yt-dlp
---------
Co-authored-by: dirkf <fieldhouse@gmx.net>
2 years ago
dirkf
427472351c
[utils] Make restricted filenames ignore characters in Unicode categories Mark, Other
...
Resolves #32629
2 years ago
dirkf
66ab0814c4
[utils] Revert bbd3e7e, updating docstring, test instead
2 years ago
dirkf
bbd3e7e999
[utils] Properly handle list values in update_url()
...
An actual list value in a query update could have been treated
as a list of values because of the key:list parse_qs format.
2 years ago
dirkf
2efc8de4d2
[utils] Advertise optional supported `Content-Encoding`s
2 years ago
dirkf
e4178b5af3
[utils] Add and use `filter_dict()` from yt-dlp
2 years ago
dirkf
2d2a4bc832
[utils] Revise `isinstance()` tests (especially for str/unicode/bytes) to complete Linter fix
2 years ago
dirkf
7d965e6b65
[utils] Avoid comparing `type(var)`, etc, to pass new Linter rules
2 years ago
dirkf
abef53466d
[utils] Rework URL path munging for ., .. components
...
* move processing to YoutubeDLHandler
* also process `Location` header for redirect
* use tests from https://github.com/yt-dlp/yt-dlp/pull/7662
2 years ago
dirkf
e7926ae9f4
[utils] Rework decoding of `Content-Encoding`s
...
* support nested encodings
* support optional `br` encoding, if brotli package is installed
* support optional 'compress' encoding, if ncompress package is installed
* response `Content-Encoding` has only unprocessed encodings, or removed
* response `Content-Length` is decoded length (usable for filesize metadata)
* use zlib for both deflate and gzip decompression
* some elements taken from yt-dlp: thx especially coletdjnz
2 years ago
dirkf
2b7dd3b2a2
[utils] Fix update_Request() with empty data (not None)
2 years ago
dirkf
1fa8b86f0b
[utils] Remove stray undocumented Host header in redirect (fix 46fde7c)
2 years ago
dirkf
a190b55964
[utils] Fix broken Py 3.11+ compat in `traverse_obj()`
...
* inspect.getargspec is missing despite doc claiming backward compat
* replace with emulation of `Signature.bind()`
2 years ago
dirkf
cb9366eda5
[utils] Minor updates (merge_dicts, T)
...
A couple of mods to ease yt-dlp back-ports:
* add kwargs to merge_dicts:
`unblank=True` (disallow empty string), `rev=False` (reverse the merge list)
* add `T(x)` shortcut for `{x}`, unsupported in Py2.6
2 years ago
dirkf
d9d07a9581
[utils] Improve js_to_json, align with yt-dlp
...
* support variable substitution, from https://github.com/yt-dlp/yt-dlp/pull/#521 etc,
thanks ChillingPepper, Grub4k, pukkandan
* improve escape handling, from https://github.com/yt-dlp/yt-dlp/pull/#521
thanks Grub4k
* support template strings from https://github.com/yt-dlp/yt-dlp/pull/6623
thanks Grub4k
* add limited `!` evaluation (eg, !!0 -> false, see tests)
2 years ago
dirkf
825a40744b
[utils] Align traverse_obj() with yt-dlp
...
Thanks Grub4k for these:
* traverse `Iterable`s, from https://github.com/yt-dlp/yt-dlp/pull/6902 , etc
* traverse `set` key for transformations/filters, `re.Match` group names, from
776995bc10 , etc
* traverse `re.Match`es, from https://github.com/yt-dlp/yt-dlp/pull/5174
* always return list when branching, from https://github.com/yt-dlp/yt-dlp/pull/5170
2 years ago
dirkf
1d8d5a93f7
[test] Fixes for old Pythons
2 years ago
bashonly
3801d36416
[utils] `YoutubeDLCookieJar`: Add `get_cookie_header` and `get_cookies_for_url` methods
2 years ago
dirkf
b383be9887
[core] Remove `Cookie` header on redirect to prevent leaks
...
Adated from yt-dlp/yt-dlp-ghsa-v8mc-9377-rwjj/pull/1/commits/101caac
Thx coletdjnz
2 years ago
dirkf
46fde7caee
[core] Update redirect handling from yt-dlp
...
* Thx coletdjnz: https://github.com/yt-dlp/yt-dlp/pull/7094
* add test that redirected `POST` loses its `Content-Type`
2 years ago
dirkf
f47fdb9564
[utils] Add {expected_type} and Iterable support to traverse_obj()
2 years ago
dirkf
f24bc9272e
[Misc] Fixes for 2.6 compatibility
2 years ago
dirkf
11cc3f3ad0
[utils] Fix `compiled_regex_type` in 249f2b6
3 years ago
dirkf
64d6dd64c8
[YouTube] Support Releases tab
3 years ago
dirkf
25124bd640
[devscripts] Improve hack to convert command-line options to API options
...
* define equality for DateRange
* don't show default DateRange
3 years ago
dirkf
f35b757c82
[utils] Ensure `allow_types` for `variadic()` is a tuple
3 years ago
pukkandan
1d3751c3fe
Escape URLs in `sanitized_Request`, not `sanitize_url` d2558234cf5dd12d6896eed5427b7dcdb3ab7b5a added escaping of URLs while sanitizing. However, `sanitize_url` may not always receive an actual URL. Eg: When using `youtube-dl "search query" --default-search ytsearch`, `search query` gets escaped to `search%20query` before being prefixed with `ytsearch:` which is not the intended behavior. So the escaping is moved to `sanitized_Request` instead.
3 years ago
dirkf
90c9f789d9
[utils] Add parse_qs, update_url
...
[skip ci]
3 years ago
dirkf
58988c1421
[YouTube] Bypass age-gating for certain restricted videos
...
* Use TVHTML5_SIMPLY_EMBEDDED_PLAYER client
* Also add and fix tests
* Introduce and use new utility function `update_url()`
3 years ago
Andrei Lebedev
27ed77aabb
[utils] Backport traverse_obj (etc) from yt-dlp ( #31156 )
...
* Backport traverse_obj and closely related function from yt-dlp (code by pukkandan)
* Backport LazyList, variadic(), try_call (code by pukkandan)
* Recast using yt-dlp's newer traverse_obj() implementation and tests (code by grub4k)
* Add tests for Unicode case folding support matching Py3.5+ (requires f102e3d )
* Improve/add tests for variadic, try_call, join_nonempty
Co-authored-by: dirkf <fieldhouse@gmx.net>
3 years ago
dirkf
c94a459a24
[utils] Sanitize look-alike Unicode glyphs in non-ID filename fields when --restrict-filenames
...
Implements https://github.com/ytdl-org/youtube-dl/issues/31216#issuecomment-1236102822 , which has a test.
3 years ago
dirkf
556862bc91
[utils] Ensure RFC3986 encoding result is unicode
3 years ago