-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[utils] Small fixes to utils, make tests pass in Py2 #29845
Conversation
bd96faf
to
bc6ad58
Compare
81b2a9d
to
1972157
Compare
625666f
to
1e22200
Compare
e96bfce
to
f798b40
Compare
Code taken from: ytdl-org/youtube-dl#29845 Fixes: ytdl-org/youtube-dl#29948 Authored by: dirkf
* 'master' of https://github.com/yt-dlp/yt-dlp: [CBC] Fix CBC Gem extractors (#1013) [Peertube] Add channel extractor (#1023) [youtube] Warn when trying to download clips [test/cookies] Improve logging [Nuvid] Fix extractor (#1022) [aes] Add `aes_gcm_decrypt_and_verify` (#1020) [CGTN] Add extractor (#981) [utils] Improve `extract_timezone` Code taken from: ytdl-org/youtube-dl#29845 Fixes: ytdl-org/youtube-dl#29948 Authored by: dirkf
If we're going to support the extended parameter syntax in RFCs 6266/5987 (the latter has been updated by RFC 8187, but it's the normative reference for 6266), we'd better do it properly. Apparently, there is either the normal parameter syntax ("" around value optional) In the latter case we would need to decode the value appropriately, but I guess any language code can be ignored. In RFC 6266 section 5, we have a set of examples, showing that we can actually have both (or according to the grammar, 0 or more filename/filename* parameters), although we
As in the first example, the keywords Obviously one could ask whether anyone's download has ever failed as a result of its mimetype not having been detected according to a |
If the regex finds nothing, the function falls back to (for a "docx" file like in my example the MIME type is |
Thanks for researching this in such detail, of course this makes it a bit more complicated. I would keep it as simple as possible as it is only about the file extension and not the filename. |
We could also use the cgi lib
Exists only since python 2.7 not since 2.6 :( |
This fragment (as updated) could do the trick
replacing
|
Thank you very much! Here is the working version with rstrip:
|
f54575f
to
f33e312
Compare
Ah, I missed that. It's the non-recommended ordering with the extended syntax first. Instead of |
f33e312
to
74b5310
Compare
Works perfectly! Thank you very much! You are the best :) |
Code taken from: ytdl-org/youtube-dl#29845 Fixes: ytdl-org/youtube-dl#29948 Authored by: dirkf
16b1fe3
to
d7d8e0c
Compare
d7d8e0c
to
51d3d0c
Compare
e456d46
to
05aa2ad
Compare
05aa2ad
to
2192474
Compare
[utils] Small fixes to utils, make tests pass in Py2
Please follow the guide below
Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Tweaks:
enumerate()
instead ofzip(..., itertools.count())
;encodeFilename()
test in Py2 by encoding with'backslashreplace'
and decoding with'unicode_escape'
when filesystem encoding isn't Unicode;shell_quote()
;compat_setenv()
,compat_getenv()
;compat_expanduser()
test pass;('nt', 'ce')
(ha!);urlhandle_detect_ext()
where non-ASCII character couldn't be coerced to Unicode in Py2 (resolves Soundcloud 'ascii' codec can't decode byte ... #29417);extract_timezone()
could be confused by a date-time string ending in a 4-digit year (check was added, then apparently removed withunified_timestamp()
), add some more date formats and tests (resolves [utils] extract_timezone() removes trailing year from time+date-type date-time string #29948)urlhandle_detect_ext()
for all the filename parameter syntaxes specified in RFC6266get_elements_by_classname()
matching elements with classname (eg)plist-info
when searching for classinfo
, as noted here.