mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 11:41:52 +00:00
[utils] Improve mimetype2ext
This commit is contained in:
parent
5e9e3d0f6b
commit
6562d34a8c
2 changed files with 10 additions and 1 deletions
|
@ -39,6 +39,7 @@ from youtube_dl.utils import (
|
||||||
is_html,
|
is_html,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
limit_length,
|
limit_length,
|
||||||
|
mimetype2ext,
|
||||||
ohdave_rsa_encrypt,
|
ohdave_rsa_encrypt,
|
||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
|
@ -625,6 +626,14 @@ class TestUtil(unittest.TestCase):
|
||||||
limit_length('foo bar baz asd', 12).startswith('foo bar'))
|
limit_length('foo bar baz asd', 12).startswith('foo bar'))
|
||||||
self.assertTrue('...' in limit_length('foo bar baz asd', 12))
|
self.assertTrue('...' in limit_length('foo bar baz asd', 12))
|
||||||
|
|
||||||
|
def test_mimetype2ext(self):
|
||||||
|
self.assertEqual(mimetype2ext(None), None)
|
||||||
|
self.assertEqual(mimetype2ext('video/x-flv'), 'flv')
|
||||||
|
self.assertEqual(mimetype2ext('application/x-mpegURL'), 'm3u8')
|
||||||
|
self.assertEqual(mimetype2ext('text/vtt'), 'vtt')
|
||||||
|
self.assertEqual(mimetype2ext('text/vtt;charset=utf-8'), 'vtt')
|
||||||
|
self.assertEqual(mimetype2ext('text/html; charset=utf-8'), 'html')
|
||||||
|
|
||||||
def test_parse_codecs(self):
|
def test_parse_codecs(self):
|
||||||
self.assertEqual(parse_codecs(''), {})
|
self.assertEqual(parse_codecs(''), {})
|
||||||
self.assertEqual(parse_codecs('avc1.77.30, mp4a.40.2'), {
|
self.assertEqual(parse_codecs('avc1.77.30, mp4a.40.2'), {
|
||||||
|
|
|
@ -2148,7 +2148,7 @@ def mimetype2ext(mt):
|
||||||
return ext
|
return ext
|
||||||
|
|
||||||
_, _, res = mt.rpartition('/')
|
_, _, res = mt.rpartition('/')
|
||||||
res = res.lower()
|
res = res.split(';')[0].strip().lower()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'3gpp': '3gp',
|
'3gpp': '3gp',
|
||||||
|
|
Loading…
Reference in a new issue