Hack to add missing extensions, which are supported, a often reported thing. See bug #724385

bzr-revno: 1378
This commit is contained in:
Mattias Põldaru 2011-03-12 09:21:10 +02:00 committed by Raoul Snyman
commit d78c84e082

View File

@ -45,6 +45,18 @@ class MediaPlugin(Plugin):
self.icon = build_icon(self.icon_path)
# passed with drag and drop messages
self.dnd_id = u'Media'
self.additional_extensions = {
u'audio/ac3': [u'.ac3'],
u'audio/flac': [u'.flac'],
u'audio/x-m4a': [u'.m4a'],
u'audio/x-mp3': [u'.mp3'],
u'audio/mpeg': [u'.mp3', u'.mp2', u'.mpga', u'.mpega', u'.m4a'],
u'audio/qcelp': [u'.qcp'],
u'audio/x-wma': [u'.wma'],
u'audio/x-ms-wma': [u'.wma'],
u'video/x-matroska': [u'.mpv', u'.mkv'],
u'video/x-wmv': [u'.wmv'],
u'video/x-ms-wmv': [u'.wmv']}
self.audio_extensions_list = []
self.video_extensions_list = []
mimetypes.init()
@ -65,6 +77,17 @@ class MediaPlugin(Plugin):
self.serviceManager.supportedSuffixes(extension[1:])
log.info(u'MediaPlugin: %s extensions: %s' % (mimetype,
u' '.join(extensions)))
# Add extensions for this mimetype from self.additional_extensions.
# This hack clears mimetypes' and operating system's shortcomings
# by providing possibly missing extensions.
if mimetype in self.additional_extensions.keys():
for extension in self.additional_extensions[mimetype]:
ext = u'*%s' % extensions
if ext not in list:
list.append(ext)
self.serviceManager.supportedSuffixes(extension[1:])
log.info(u'MediaPlugin: %s additional extensions: %s' % (mimetype,
u' '.join(self.additional_extensions[mimetype])))
def about(self):
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'