diff options
author | Felix S <felix.von.s@posteo.de> | 2021-10-02 18:43:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-03 00:13:42 +0530 |
commit | 9359f3d4f02856128f5626e754c7f64e2232b02f (patch) | |
tree | 601dd118dfa2c5b8226086bf5f303656986dc735 /yt_dlp/utils.py | |
parent | 0eaec13ba6abe18d6ddf35f2ebffdcaf3937e485 (diff) | |
download | hypervideo-pre-9359f3d4f02856128f5626e754c7f64e2232b02f.tar.lz hypervideo-pre-9359f3d4f02856128f5626e754c7f64e2232b02f.tar.xz hypervideo-pre-9359f3d4f02856128f5626e754c7f64e2232b02f.zip |
[extractor] Extract storyboards from SMIL manifests (#1128)
Authored by: fstirlitz
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 1bc0ac767..7a77edf4c 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -4546,20 +4546,24 @@ def mimetype2ext(mt): if mt is None: return None - ext = { + mt, _, params = mt.partition(';') + mt = mt.strip() + + FULL_MAP = { 'audio/mp4': 'm4a', # Per RFC 3003, audio/mpeg can be .mp1, .mp2 or .mp3. Here use .mp3 as # it's the most popular one 'audio/mpeg': 'mp3', 'audio/x-wav': 'wav', - }.get(mt) + 'audio/wav': 'wav', + 'audio/wave': 'wav', + } + + ext = FULL_MAP.get(mt) if ext is not None: return ext - _, _, res = mt.rpartition('/') - res = res.split(';')[0].strip().lower() - - return { + SUBTYPE_MAP = { '3gpp': '3gp', 'smptett+xml': 'tt', 'ttaf+xml': 'dfxp', @@ -4578,7 +4582,28 @@ def mimetype2ext(mt): 'quicktime': 'mov', 'mp2t': 'ts', 'x-wav': 'wav', - }.get(res, res) + 'filmstrip+json': 'fs', + 'svg+xml': 'svg', + } + + _, _, subtype = mt.rpartition('/') + ext = SUBTYPE_MAP.get(subtype.lower()) + if ext is not None: + return ext + + SUFFIX_MAP = { + 'json': 'json', + 'xml': 'xml', + 'zip': 'zip', + 'gzip': 'gz', + } + + _, _, suffix = subtype.partition('+') + ext = SUFFIX_MAP.get(suffix) + if ext is not None: + return ext + + return subtype.replace('+', '.') def parse_codecs(codecs_str): |