 
 (def player-cmd (str "/usr/bin/mplayer -quiet -slave -input file=" fifo-path " -idle -nocache -nortc"))
 
+
+(defn mplayer-key->keyword [s]
+  (->>
+   (str/replace s #"(ANS_META_|ANS_)" "")
+   str/lower-case
+   keyword
+   ))
+
+(defn mplayer-pairs->map [& [pairs]]
+  (let [pairs (str/replace pairs "=\n" "=nil")] ;; egregious work-around for last value null
+  (->>
+   (clojure.string/split pairs #"[=\n]")
+   (map str/trim)
+   (map-indexed (fn [i x] (if (odd? i) x (mplayer-key->keyword x))))
+   (apply hash-map)
+   )))
 
 (defn mkfifo []
   (let [fifo-path "/tmp/MYCMD"]

(defn pause-player []
  (sh "bash" "-c" (str "echo 'pause' > " fifo-path) ))

(defn quit-player []
  (sh "bash" "-c" (str "echo 'quit' > " fifo-path) ))


(ns moodseer-clj.process
  (:use [clojure.java.shell :only [sh]])
  (:require [clojure.string :as str]))

;; (sh "bash" "-c" "mplayer -playlist /tmp/gort.m3u -shuffle -quiet -slave -input file=/tmp/MYCMD  1>/tmp/mplayer-out.log 2>&1 & \n echo $!")
;; (sh "bash" "-c" "echo 'get_meta_artist\nget_meta_title\nget_meta_album\nget_meta_genre\nget_meta_year\nget_meta_track\nget_meta_comment' > /tmp/MYCMD")
