← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mahfiaz/openlp/fixes_and_improvements into lp:openlp

 

mahfiaz has proposed merging lp:~mahfiaz/openlp/fixes_and_improvements into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~mahfiaz/openlp/fixes_and_improvements/+merge/50764

Add more detailed mimetype logging, so that logs would be useful when filling that mimetypes dictionary.
-- 
https://code.launchpad.net/~mahfiaz/openlp/fixes_and_improvements/+merge/50764
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2011-02-20 18:12:55 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2011-02-22 15:06:58 +0000
@@ -61,8 +61,8 @@
         self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
         self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem',
             'Videos (%s);;Audio (%s);;%s (*)')) % (
-            u' '.join(self.parent.video_list), 
-            u' '.join(self.parent.audio_list), UiStrings.AllFiles)
+            u' '.join(self.parent.video_extensions_list), 
+            u' '.join(self.parent.audio_extensions_list), UiStrings.AllFiles)
         self.replaceAction.setText(UiStrings.ReplaceBG)
         self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
         self.resetAction.setText(UiStrings.ResetBG)

=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py	2011-02-20 18:49:59 +0000
+++ openlp/plugins/media/mediaplugin.py	2011-02-22 15:06:58 +0000
@@ -45,28 +45,39 @@
         self.icon = build_icon(self.icon_path)
         # passed with drag and drop messages
         self.dnd_id = u'Media'
-        self.audio_list = []
-        self.video_list = []
+        self.additional_extensions = {}
+        #   'video/msvideo': ['.avi']} This is an example line.
+        self.audio_extensions_list = []
+        self.video_extensions_list = []
         mimetypes.init()
         for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
             mimetype = unicode(mimetype)
             if mimetype.startswith(u'audio/'):
-                self._addToList(self.audio_list, mimetype)
+                self._addToList(self.audio_extensions_list, mimetype)
             elif mimetype.startswith(u'video/'):
-                self._addToList(self.video_list, mimetype)
-        log.info(u'MediaPlugin handles audio extensions: %s',
-            u' '.join(self.audio_list))
-        log.info(u'MediaPlugin handles video extensions: %s',
-            u' '.join(self.video_list))
+                self._addToList(self.video_extensions_list, mimetype)
 
     def _addToList(self, list, mimetype):
-        # Is it a media type
+        # Add all extensions which mimetypes provides us for supported types.
         extensions = mimetypes.guess_all_extensions(unicode(mimetype))
         for extension in extensions:
             ext = u'*%s' % extension
             if ext not in list:
                 list.append(ext)
                 self.serviceManager.supportedSuffixes(extension[1:])
+        log.info(u'MediaPlugin: %s extensions: %s' % (mimetype,
+            u' '.join(extensions)))
+        # Add all extensions listed in self.additional_extensions, which
+        # have this mimetype, previously claimed to be supported by Phonon,
+        # to hack away mimetypes' shortcomings in providing some 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>'


Follow ups