]> pere.pagekite.me Git - homepage.git/commitdiff
New post.
authorPetter Reinholdtsen <pere@hungry.com>
Fri, 18 Jan 2013 09:35:11 +0000 (09:35 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Fri, 18 Jan 2013 09:35:11 +0000 (09:35 +0000)
blog/data/2013-01-18-debian-browserplugin.txt [new file with mode: 0644]

diff --git a/blog/data/2013-01-18-debian-browserplugin.txt b/blog/data/2013-01-18-debian-browserplugin.txt
new file mode 100644 (file)
index 0000000..fa7b0be
--- /dev/null
@@ -0,0 +1,59 @@
+Title: How to find a browser plugin supporting a given MIME type
+Tags: english, debian
+Date: 2013-01-18 10:40
+
+<p>Some times I try to figure out which Iceweasel browser plugin to
+install to get support for a given MIME type.  Thanks to
+<a href="https://wiki.ubuntu.com/MozillaTeam/Plugins">specifications
+done by Ubuntu</a> and Mozilla, it is possible to do this in Debian.
+Unfortunately, not very many packages provide the needed meta
+information, Anyway, here is a small script to look up all browser
+plugin packages announcing ther MIME support using this specification:</p>
+
+<pre>
+#!/usr/bin/python
+import sys
+import apt
+def pkgs_handling_mimetype(mimetype):
+    cache = apt.Cache()
+    cache.open(None)
+    thepkgs = []
+    for pkg in cache:
+        version = pkg.candidate
+        if version is None:
+            version = pkg.installed
+        if version is None:
+            continue
+        record = version.record
+        if not record.has_key('Npp-MimeType'):
+            continue
+        mime_types = record['Npp-MimeType'].split(',')
+        for t in mime_types:
+            t = t.rstrip().strip()
+            if t == mimetype:
+                thepkgs.append(pkg.name)
+    return thepkgs
+mimetype = "audio/ogg"
+if 1 < len(sys.argv):
+    mimetype = sys.argv[1]
+print "Browser plugin packages supporting %s:" % mimetype
+for pkg in pkgs_handling_mimetype(mimetype):
+    print "  %s" %pkg
+</pre>
+
+<p>It can be used like this to look up a given MIME type:</p>
+
+<pre>
+% ./apt-find-browserplug-for-mimetype 
+Browser plugin packages supporting audio/ogg:
+  gecko-mediaplayer
+% ./apt-find-browserplug-for-mimetype application/x-shockwave-flash
+Browser plugin packages supporting application/x-shockwave-flash:
+  browser-plugin-gnash
+%
+</pre>
+
+<p>In Ubuntu this mechanism is combined with support in the browser
+itself to query for plugins and propose to install the needed
+packages.  It would be great if Debian supported such feature too.  Is
+anyone working on adding it?</p>