forked from openlp/openlp
Fix mimetype issues
bzr-revno: 1109 Fixes: https://launchpad.net/bugs/657465
This commit is contained in:
commit
a1d2e8390b
@ -25,6 +25,7 @@
|
||||
###############################################################################
|
||||
|
||||
import logging
|
||||
import mimetypes
|
||||
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
@ -45,6 +46,7 @@ class MediaPlugin(Plugin):
|
||||
self.dnd_id = u'Media'
|
||||
self.audio_list = u''
|
||||
self.video_list = u''
|
||||
mimetypes.init()
|
||||
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
||||
mimetype = unicode(mimetype)
|
||||
type = mimetype.split(u'audio/x-')
|
||||
@ -60,13 +62,18 @@ class MediaPlugin(Plugin):
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
|
||||
def _addToList(self, list, value, type):
|
||||
def _addToList(self, list, value, mimetype):
|
||||
# Is it a media type
|
||||
if len(value) == 2:
|
||||
if list.find(value[1]) == -1:
|
||||
list += u'*.%s ' % value[1]
|
||||
self.serviceManager.supportedSuffixes(value[1])
|
||||
type = u''
|
||||
return list, type
|
||||
extensions = mimetypes.guess_all_extensions(unicode(mimetype))
|
||||
# we have an extension
|
||||
if extensions:
|
||||
for extension in extensions:
|
||||
if list.find(extension) == -1:
|
||||
list += u'*%s ' % extension
|
||||
self.serviceManager.supportedSuffixes(extension[1:])
|
||||
mimetype = u''
|
||||
return list, mimetype
|
||||
|
||||
def getSettingsTab(self):
|
||||
return MediaTab(self.name)
|
||||
|
Loading…
Reference in New Issue
Block a user