summaryrefslogtreecommitdiff
path: root/helpers/mimetypes
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-03-07 15:54:28 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-03-07 15:54:28 +0100
commitdc1388bc75113e35d29079e777333648e27d8346 (patch)
tree1e428ce5365ce6213ba433a4bab277406ca27150 /helpers/mimetypes
parentfa76dcb81282ff961bb398aef36a959f0a7c6a5f (diff)
include/ → helpers/
Diffstat (limited to 'helpers/mimetypes')
-rwxr-xr-xhelpers/mimetypes27
1 files changed, 27 insertions, 0 deletions
diff --git a/helpers/mimetypes b/helpers/mimetypes
new file mode 100755
index 0000000..425d2b5
--- /dev/null
+++ b/helpers/mimetypes
@@ -0,0 +1,27 @@
+#!/usr/bin/env zsh
+typeset -a audio video image
+eval $(perl -ne 'if (/^mime_\w+\=\(/ or $found == 1) { $found = 1; print } if (/^\)/ and $found == 1) {$found = 0}' ~/.zshrc)
+
+while read mime extensions; do
+ [[ $mime == audio/* ]] && audio+=(${(s/ /)extensions})
+ [[ $mime == video/* ]] && video+=(${(s/ /)extensions})
+ [[ $mime == image/* ]] && image+=(${(s/ /)extensions})
+done < /etc/mime.types
+
+audio=(${(i)audio})
+video=(${(i)video})
+image=(${(i)image})
+
+for mimetype in $audio; {
+ [[ ${mime_audio[(I)$mimetype]} == 0 ]] && echo "mime_audio+=$mimetype"
+}
+for mimetype in $video; {
+ [[ ${mime_video[(I)$mimetype]} == 0 ]] && echo "mime_video+=$mimetype"
+}
+for mimetype in $image; {
+ [[ ${mime_image[(I)$mimetype]} == 0 ]] && echo "mime_image+=$mimetype"
+}
+
+echo "mime_audio=($audio)"
+echo "mime_video=($video)"
+echo "mime_image=($image)"