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 logging
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ class MediaPlugin(Plugin):
|
|||||||
self.dnd_id = u'Media'
|
self.dnd_id = u'Media'
|
||||||
self.audio_list = u''
|
self.audio_list = u''
|
||||||
self.video_list = u''
|
self.video_list = u''
|
||||||
|
mimetypes.init()
|
||||||
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
||||||
mimetype = unicode(mimetype)
|
mimetype = unicode(mimetype)
|
||||||
type = mimetype.split(u'audio/x-')
|
type = mimetype.split(u'audio/x-')
|
||||||
@ -60,13 +62,18 @@ class MediaPlugin(Plugin):
|
|||||||
self.video_list, mimetype = self._addToList(self.video_list,
|
self.video_list, mimetype = self._addToList(self.video_list,
|
||||||
type, mimetype)
|
type, mimetype)
|
||||||
|
|
||||||
def _addToList(self, list, value, type):
|
def _addToList(self, list, value, mimetype):
|
||||||
|
# Is it a media type
|
||||||
if len(value) == 2:
|
if len(value) == 2:
|
||||||
if list.find(value[1]) == -1:
|
extensions = mimetypes.guess_all_extensions(unicode(mimetype))
|
||||||
list += u'*.%s ' % value[1]
|
# we have an extension
|
||||||
self.serviceManager.supportedSuffixes(value[1])
|
if extensions:
|
||||||
type = u''
|
for extension in extensions:
|
||||||
return list, type
|
if list.find(extension) == -1:
|
||||||
|
list += u'*%s ' % extension
|
||||||
|
self.serviceManager.supportedSuffixes(extension[1:])
|
||||||
|
mimetype = u''
|
||||||
|
return list, mimetype
|
||||||
|
|
||||||
def getSettingsTab(self):
|
def getSettingsTab(self):
|
||||||
return MediaTab(self.name)
|
return MediaTab(self.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user