mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-27 07:38:30 +00:00
[utils] urlhandle_detect_ext
: Use x-amz-meta-file-type
headers (#13749)
Authored by: bashonly
This commit is contained in:
parent
b8abd255e4
commit
28bf46b7da
@ -3106,21 +3106,15 @@ def get_compatible_ext(*, vcodecs, acodecs, vexts, aexts, preferences=None):
|
|||||||
def urlhandle_detect_ext(url_handle, default=NO_DEFAULT):
|
def urlhandle_detect_ext(url_handle, default=NO_DEFAULT):
|
||||||
getheader = url_handle.headers.get
|
getheader = url_handle.headers.get
|
||||||
|
|
||||||
cd = getheader('Content-Disposition')
|
if cd := getheader('Content-Disposition'):
|
||||||
if cd:
|
if m := re.match(r'attachment;\s*filename="(?P<filename>[^"]+)"', cd):
|
||||||
m = re.match(r'attachment;\s*filename="(?P<filename>[^"]+)"', cd)
|
if ext := determine_ext(m.group('filename'), default_ext=None):
|
||||||
if m:
|
return ext
|
||||||
e = determine_ext(m.group('filename'), default_ext=None)
|
|
||||||
if e:
|
|
||||||
return e
|
|
||||||
|
|
||||||
meta_ext = getheader('x-amz-meta-name')
|
return (
|
||||||
if meta_ext:
|
determine_ext(getheader('x-amz-meta-name'), default_ext=None)
|
||||||
e = meta_ext.rpartition('.')[2]
|
or getheader('x-amz-meta-file-type')
|
||||||
if e:
|
or mimetype2ext(getheader('Content-Type'), default=default))
|
||||||
return e
|
|
||||||
|
|
||||||
return mimetype2ext(getheader('Content-Type'), default=default)
|
|
||||||
|
|
||||||
|
|
||||||
def encode_data_uri(data, mime_type):
|
def encode_data_uri(data, mime_type):
|
||||||
|
Loading…
Reference in New Issue
Block a user