mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-17 18:58:35 +00:00
[utils] urlhandle_detect_ext
: Use x-amz-meta-file-type
headers
Authored by: bashonly
This commit is contained in:
parent
3a84be9d16
commit
ad2fddfcb4
@ -3105,19 +3105,16 @@ def get_compatible_ext(*, vcodecs, acodecs, vexts, aexts, preferences=None):
|
||||
def urlhandle_detect_ext(url_handle, default=NO_DEFAULT):
|
||||
getheader = url_handle.headers.get
|
||||
|
||||
cd = getheader('Content-Disposition')
|
||||
if cd:
|
||||
m = re.match(r'attachment;\s*filename="(?P<filename>[^"]+)"', cd)
|
||||
if m:
|
||||
e = determine_ext(m.group('filename'), default_ext=None)
|
||||
if e:
|
||||
return e
|
||||
if cd := getheader('Content-Disposition'):
|
||||
if m := re.match(r'attachment;\s*filename="(?P<filename>[^"]+)"', cd):
|
||||
if ext := determine_ext(m.group('filename'), default_ext=None):
|
||||
return ext
|
||||
|
||||
meta_ext = getheader('x-amz-meta-name')
|
||||
if meta_ext:
|
||||
e = meta_ext.rpartition('.')[2]
|
||||
if e:
|
||||
return e
|
||||
if ext := determine_ext(getheader('x-amz-meta-name'), default_ext=None):
|
||||
return ext
|
||||
|
||||
if ext := getheader('x-amz-meta-file-type'):
|
||||
return ext
|
||||
|
||||
return mimetype2ext(getheader('Content-Type'), default=default)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user