mirror of https://github.com/python/cpython
gh-89416: Add RFC 9559 MIME types for Matroska formats (#126412)
Co-authored-by: Zachary Ware <zachary.ware@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
4f3253a0cc
commit
3c6d2d1230
|
@ -363,6 +363,19 @@ json
|
||||||
(Contributed by Trey Hunner in :gh:`122873`.)
|
(Contributed by Trey Hunner in :gh:`122873`.)
|
||||||
|
|
||||||
|
|
||||||
|
mimetypes
|
||||||
|
---------
|
||||||
|
|
||||||
|
* Add :rfc:`9559` MIME types for Matroska audiovisual data container
|
||||||
|
structures, containing:
|
||||||
|
|
||||||
|
* audio with no video: ``audio/matroska`` (``.mka``)
|
||||||
|
* video: ``video/matroska`` (``.mkv``)
|
||||||
|
* stereoscopic video: ``video/matroska-3d`` (``.mk3d``)
|
||||||
|
|
||||||
|
(Contributed by Hugo van Kemenade in :gh:`89416`.)
|
||||||
|
|
||||||
|
|
||||||
multiprocessing
|
multiprocessing
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@ -382,6 +395,7 @@ multiprocessing
|
||||||
|
|
||||||
(Contributed by Roy Hyunjin Han for :gh:`103134`)
|
(Contributed by Roy Hyunjin Han for :gh:`103134`)
|
||||||
|
|
||||||
|
|
||||||
operator
|
operator
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -534,6 +534,7 @@ def _default_mime_types():
|
||||||
'.ass' : 'audio/aac',
|
'.ass' : 'audio/aac',
|
||||||
'.au' : 'audio/basic',
|
'.au' : 'audio/basic',
|
||||||
'.snd' : 'audio/basic',
|
'.snd' : 'audio/basic',
|
||||||
|
'.mka' : 'audio/matroska',
|
||||||
'.mp3' : 'audio/mpeg',
|
'.mp3' : 'audio/mpeg',
|
||||||
'.mp2' : 'audio/mpeg',
|
'.mp2' : 'audio/mpeg',
|
||||||
'.opus' : 'audio/opus',
|
'.opus' : 'audio/opus',
|
||||||
|
@ -595,6 +596,8 @@ def _default_mime_types():
|
||||||
'.sgml' : 'text/x-sgml',
|
'.sgml' : 'text/x-sgml',
|
||||||
'.vcf' : 'text/x-vcard',
|
'.vcf' : 'text/x-vcard',
|
||||||
'.xml' : 'text/xml',
|
'.xml' : 'text/xml',
|
||||||
|
'.mkv' : 'video/matroska',
|
||||||
|
'.mk3d' : 'video/matroska-3d',
|
||||||
'.mp4' : 'video/mp4',
|
'.mp4' : 'video/mp4',
|
||||||
'.mpeg' : 'video/mpeg',
|
'.mpeg' : 'video/mpeg',
|
||||||
'.m1v' : 'video/mpeg',
|
'.m1v' : 'video/mpeg',
|
||||||
|
|
|
@ -223,26 +223,33 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_preferred_extension(self):
|
def test_preferred_extension(self):
|
||||||
def check_extensions():
|
def check_extensions():
|
||||||
self.assertEqual(mimetypes.guess_extension('application/octet-stream'), '.bin')
|
for mime_type, ext in (
|
||||||
self.assertEqual(mimetypes.guess_extension('application/postscript'), '.ps')
|
("application/octet-stream", ".bin"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/vnd.apple.mpegurl'), '.m3u')
|
("application/postscript", ".ps"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-excel'), '.xls')
|
("application/vnd.apple.mpegurl", ".m3u"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-powerpoint'), '.ppt')
|
("application/vnd.ms-excel", ".xls"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/x-texinfo'), '.texi')
|
("application/vnd.ms-powerpoint", ".ppt"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/x-troff'), '.roff')
|
("application/x-texinfo", ".texi"),
|
||||||
self.assertEqual(mimetypes.guess_extension('application/xml'), '.xsl')
|
("application/x-troff", ".roff"),
|
||||||
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
|
("application/xml", ".xsl"),
|
||||||
self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif')
|
("audio/matroska", ".mka"),
|
||||||
self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp')
|
("audio/mpeg", ".mp3"),
|
||||||
self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg')
|
("image/avif", ".avif"),
|
||||||
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
|
("image/webp", ".webp"),
|
||||||
self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml')
|
("image/jpeg", ".jpg"),
|
||||||
self.assertEqual(mimetypes.guess_extension('text/html'), '.html')
|
("image/tiff", ".tiff"),
|
||||||
self.assertEqual(mimetypes.guess_extension('text/plain'), '.txt')
|
("message/rfc822", ".eml"),
|
||||||
self.assertEqual(mimetypes.guess_extension('text/rtf'), '.rtf')
|
("text/html", ".html"),
|
||||||
self.assertEqual(mimetypes.guess_extension('text/x-rst'), '.rst')
|
("text/plain", ".txt"),
|
||||||
self.assertEqual(mimetypes.guess_extension('video/mpeg'), '.mpeg')
|
("text/rtf", ".rtf"),
|
||||||
self.assertEqual(mimetypes.guess_extension('video/quicktime'), '.mov')
|
("text/x-rst", ".rst"),
|
||||||
|
("video/matroska", ".mkv"),
|
||||||
|
("video/matroska-3d", ".mk3d"),
|
||||||
|
("video/mpeg", ".mpeg"),
|
||||||
|
("video/quicktime", ".mov"),
|
||||||
|
):
|
||||||
|
with self.subTest(mime_type=mime_type, ext=ext):
|
||||||
|
self.assertEqual(mimetypes.guess_extension(mime_type), ext)
|
||||||
|
|
||||||
check_extensions()
|
check_extensions()
|
||||||
mimetypes.init()
|
mimetypes.init()
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Add :rfc:`9559` MIME types for Matroska audiovisual container formats. Patch
|
||||||
|
by Hugo van Kemenade.
|
Loading…
Reference in New Issue