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`.)
|
||||
|
||||
|
||||
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
|
||||
---------------
|
||||
|
||||
|
@ -382,6 +395,7 @@ multiprocessing
|
|||
|
||||
(Contributed by Roy Hyunjin Han for :gh:`103134`)
|
||||
|
||||
|
||||
operator
|
||||
--------
|
||||
|
||||
|
|
|
@ -534,6 +534,7 @@ def _default_mime_types():
|
|||
'.ass' : 'audio/aac',
|
||||
'.au' : 'audio/basic',
|
||||
'.snd' : 'audio/basic',
|
||||
'.mka' : 'audio/matroska',
|
||||
'.mp3' : 'audio/mpeg',
|
||||
'.mp2' : 'audio/mpeg',
|
||||
'.opus' : 'audio/opus',
|
||||
|
@ -595,6 +596,8 @@ def _default_mime_types():
|
|||
'.sgml' : 'text/x-sgml',
|
||||
'.vcf' : 'text/x-vcard',
|
||||
'.xml' : 'text/xml',
|
||||
'.mkv' : 'video/matroska',
|
||||
'.mk3d' : 'video/matroska-3d',
|
||||
'.mp4' : 'video/mp4',
|
||||
'.mpeg' : 'video/mpeg',
|
||||
'.m1v' : 'video/mpeg',
|
||||
|
|
|
@ -223,26 +223,33 @@ class MimeTypesTestCase(unittest.TestCase):
|
|||
|
||||
def test_preferred_extension(self):
|
||||
def check_extensions():
|
||||
self.assertEqual(mimetypes.guess_extension('application/octet-stream'), '.bin')
|
||||
self.assertEqual(mimetypes.guess_extension('application/postscript'), '.ps')
|
||||
self.assertEqual(mimetypes.guess_extension('application/vnd.apple.mpegurl'), '.m3u')
|
||||
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-excel'), '.xls')
|
||||
self.assertEqual(mimetypes.guess_extension('application/vnd.ms-powerpoint'), '.ppt')
|
||||
self.assertEqual(mimetypes.guess_extension('application/x-texinfo'), '.texi')
|
||||
self.assertEqual(mimetypes.guess_extension('application/x-troff'), '.roff')
|
||||
self.assertEqual(mimetypes.guess_extension('application/xml'), '.xsl')
|
||||
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
|
||||
self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif')
|
||||
self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp')
|
||||
self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg')
|
||||
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
|
||||
self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml')
|
||||
self.assertEqual(mimetypes.guess_extension('text/html'), '.html')
|
||||
self.assertEqual(mimetypes.guess_extension('text/plain'), '.txt')
|
||||
self.assertEqual(mimetypes.guess_extension('text/rtf'), '.rtf')
|
||||
self.assertEqual(mimetypes.guess_extension('text/x-rst'), '.rst')
|
||||
self.assertEqual(mimetypes.guess_extension('video/mpeg'), '.mpeg')
|
||||
self.assertEqual(mimetypes.guess_extension('video/quicktime'), '.mov')
|
||||
for mime_type, ext in (
|
||||
("application/octet-stream", ".bin"),
|
||||
("application/postscript", ".ps"),
|
||||
("application/vnd.apple.mpegurl", ".m3u"),
|
||||
("application/vnd.ms-excel", ".xls"),
|
||||
("application/vnd.ms-powerpoint", ".ppt"),
|
||||
("application/x-texinfo", ".texi"),
|
||||
("application/x-troff", ".roff"),
|
||||
("application/xml", ".xsl"),
|
||||
("audio/matroska", ".mka"),
|
||||
("audio/mpeg", ".mp3"),
|
||||
("image/avif", ".avif"),
|
||||
("image/webp", ".webp"),
|
||||
("image/jpeg", ".jpg"),
|
||||
("image/tiff", ".tiff"),
|
||||
("message/rfc822", ".eml"),
|
||||
("text/html", ".html"),
|
||||
("text/plain", ".txt"),
|
||||
("text/rtf", ".rtf"),
|
||||
("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()
|
||||
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