commit 353058148c76c17a424ff6ba98467d10785a8a68
parent da3c03f853e6696f1e394ba0a693acda394c6be8
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Sat, 25 Sep 2010 01:20:26 +0200
Démon mplayer, commande à distance pour la lecture, filtrage de l'info "titre".
Diffstat:
4 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/config b/config
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+V="-8"
+MP_CONTROL="/dev/shm/mplayer-contol$V"
+MP_OUTPUT="/dev/shm/mplayer-output$V"
+MP_PID="/dev/shm/mplayer-pid$V"
+MP_ERROR="/tmp/mplayer-errors.log"
diff --git a/mplayerd b/mplayerd
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+source "$(dirname "$0")/config"
+
+if [ "$1" == "stop" ]; then
+ if [ -e /dev/shm/mplayer-pid ]; then
+ if ! kill "$(<"$MP_PID")"; then
+ echo "Failed to kill mplayer"
+ exit 2
+ fi
+ else
+ echo "Can't find $MP_PID ."
+ exit 3
+ fi
+else
+ [ -p "$MP_CONTROL" ] || mkfifo "$MP_CONTROL"
+ [ -p "$MP_OUTPUT" ] || mkfifo "$MP_OUTPUT"
+
+ mplayer -quiet -slave -input file="$MP_CONTROL" -idle > "$MP_OUTPUT" 2> "$MP_ERROR" &
+ echo "$!" > /dev/shm/mplayer-pid
+fi
diff --git a/mplayerd-getinfo b/mplayerd-getinfo
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+source "$(dirname "$0")/config"
+
+q="'"
+
+old_titre=""
+
+cat "$MP_OUTPUT" \
+| while read ligne; do
+ # TODO : utiliser grep n'est pas du tout efficace !
+ if grep -q "^[a-zA-Z_][a-zA-Z0-9_]*='"<<<"$ligne"; then
+ cle="${ligne%%=$q*}"
+ valeur="${ligne#*=$q}"
+ valeur="${valeur%$q}"
+ case "$cle" in
+ ANS_META_TITLE)
+ old_titre="$titre"
+ titre="$valeur"
+ if [ "$titre" != "$old_titre" ]; then
+ echo "TITRE = $titre"
+ fi
+ ;;
+ esac
+ else
+ (echo "get_meta_title" > "$MP_CONTROL") &
+ fi
+done
diff --git a/mplayerd-play b/mplayerd-play
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+source "$(dirname "$0")/config"
+
+echo "loadfile '$(readlink -f "$1")' 0" > "$MP_CONTROL"