dirkf
66ab0814c4
[utils] Revert bbd3e7e
, updating docstring, test instead
1 year 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
1 year 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)
1 year 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
1 year ago
dirkf
1d8d5a93f7
[test] Fixes for old Pythons
1 year ago
dirkf
f47fdb9564
[utils] Add {expected_type} and Iterable support to traverse_obj()
1 year ago
dirkf
f24bc9272e
[Misc] Fixes for 2.6 compatibility
1 year ago
dirkf
f35b757c82
[utils] Ensure `allow_types` for `variadic()` is a tuple
2 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.
2 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>
2 years ago
dirkf
d231b56717
[jsinterp] Overhaul JSInterp to handle new YT players 4c3f79c5, 324f67b9 ( #31170 )
...
* back-port from yt-dlp 8f53dc44a0cc1c2d98c35740b9293462c080f5d0, thanks pukkandan
* also support void, improve <</>> precedence, improve expressions in comma-list
* add more tests
2 years ago
Remita Amine
e88c9ef62a
[utils] add a function to clean podcast URLs
4 years ago
Remita Amine
9dd674e1d2
[utils] accept only supported protocols in url_or_none
4 years ago
Sergey M․
fe07e788bf
[utils] Skip ! prefixed code in js_to_json
4 years ago
Kevin O'Connor
4eda10499e
[utils] Don't attempt to coerce JS strings to numbers in js_to_json ( #26851 )
...
The current logic in `js_to_json` tries to rewrite octal/hex numbers to
decimal. However, when the logic actually happens the `"` or `'` have
already been trimmed off. This causes what were originally strings, that
happen to look like octal/hex numbers, to get rewritten to decimal and
returned as a number rather than a string.
In practive something like:
```js
{
"0x40": "foo",
"040": "bar",
}
```
would get rewritten as:
```json
{
64: "foo",
32: "bar
}
```
This is problematic since this isn't valid JSON as you cannot have
non-string keys.
4 years ago
Sergey M․
1d9bf655e6
[utils] Recognize wav mimetype ( closes #26463 )
4 years ago
Sergey M․
42db58ec73
[utils] Improve str_to_int
5 years ago
Remita Amine
348c6bf1c1
[utils] handle int values passed to str_to_int
5 years ago
Sergey M․
1ced222120
[utils] Add generic caesar cipher and rot47
5 years ago
InfernalUnderling
9d30c2132a
[utils] Handle rd-suffixed day parts in unified_strdate ( #23199 )
5 years ago
Sergey M․
824fa51165
[utils] Improve subtitles_filename ( closes #22753 )
5 years ago
Sergey M․
28cc2241e4
[utils] Restrict parse_codecs and add theora as known vcodec ( #21381 )
5 years ago
Sergey M․
53cd37bac5
[utils] Improve strip_or_none
6 years ago
Jakub Wilk
fd35d8cdfd
[utils] Transliterate "þ" as "th" ( #20897 )
...
Despite visual similarity "þ" is unrelated to "p".
It is normally transliterated as "th":
$ echo þ-Þ | iconv -t ASCII//TRANSLIT
th-TH
6 years ago
Sergey M․
5e1271c56d
[utils] Improve int_or_none and float_or_none ( #20403 )
6 years ago
Sergey M․
0dc41787af
[utils] Introduce parse_bitrate
6 years ago
Sergey M․
fad4ceb534
[utils] Fix urljoin for paths with non-http(s) schemes
6 years ago
Sergey M․
25d110be30
[utils] Properly recognize AV1 codec ( closes #17506 )
6 years ago
Sergey M․
af03000ad5
[utils] Introduce url_or_none
6 years ago
Sergey M․
e9c671d5e8
[utils] Allow JSONP with empty func name ( closes #17028 )
6 years ago
Enes
85750f8972
[openload] Improve ext extraction
7 years ago
Remita Amine
3bb3ff38a1
[test_utils] add tests for b836118724
7 years ago
Sergey M․
6cc622327f
[utils] Introduce merge_dicts
7 years ago
Sergey M․
1cc47c6674
[utils] Fix match_str for boolean meta fields
7 years ago
Philipp Hagemeister
f226880c6d
[tennistv] Add support for tennistv.com
7 years ago
Sergey M․
b871d7e954
[utils] Add parse_resolution
7 years ago
Sergey M․
befa4708fd
[utils] Fixup some common URL's typos in sanitize_url ( closes #15649 )
7 years ago
Sergey M․
c707b1d828
[test_utils] Add tests for malformed JSON handling in js_to_json
7 years ago
Mike Fährmann
c384d537f8
[util] Improve scientific notation handling in js_to_json ( closes #14789 )
7 years ago
Sergey M․
b555ae9bf1
[utils] Add another date format pattern ( #14999 )
7 years ago
Sergey M․
056653bbb1
[utils] Add support for zero years and months in parse_duration
7 years ago
Yen Chi Hsuan
3869028ffb
[utils] Use bytes-like objects in dfxp2srt
...
This fixes handling of non-UTF8 TTML subtitles
Closes #14191
7 years ago
Yen Chi Hsuan
95f3f7c20a
[utils] Fix unescapeHTML for misformed string like "&a"" ( #13935 )
7 years ago
Sergey M․
5b232f46dc
[utils] Skip missing params in cli_bool_option ( closes #13865 )
7 years ago
Sergey M․
dee2ff1d81
[test_utils] Fix tests under Windows
7 years ago
Yen Chi Hsuan
609ff8ca19
[utils] Support attributes with no values in get_elements_by_attribute()
7 years ago
Sergey M․
b4a3d461e4
[utils] Handle HTMLParseError in extract_attributes ( closes #13349 )
7 years ago
Sergey M․
2ae2ffda5e
[utils] Improve unified_timestamp
7 years ago
Yen Chi Hsuan
5552c9eb0f
[utils] Recognize more patterns in strip_jsonp()
...
Used in Youku Show pages
8 years ago
Yen Chi Hsuan
0c26548601
[cda] Implement birthday verification ( closes #12789 )
8 years ago