Added media/mplayer/capture-dir to specify where to capture playing streams.
[elisp.git] / media-mplayer.el
index c7c581e..5b00526 100644 (file)
@@ -32,6 +32,11 @@ load Emacs less. Nil means no timing."
   :type 'float
   :group 'media)
 
+(defcustom media/mplayer/capture-dir nil
+  "States where to save the dumped streams."
+  :type 'string
+  :group 'media)
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;; It is impossible to tell mplayer to send information every time dt
@@ -87,7 +92,11 @@ load Emacs less. Nil means no timing."
 
                         (setq media/current-song-in-stream
                               (let ((s (match-string 1 param)))
-                                (concat (if (string= s "") "<no title>" s)
+                                (concat (if (string= s "")
+                                            "<no title>"
+                                          ;; (encode-coding-string s 'latin-1)
+                                          s
+                                          )
                                         " | "
                                         (format-time-string "%a %b %d %H:%M:%S")
                                         )
@@ -152,7 +161,9 @@ load Emacs less. Nil means no timing."
                    ;; ----------------------------------------
 
                    ("Starting"
-                    (media/mplayer/write "get_time_length\n"))
+                    (media/mplayer/write "get_time_length\n")
+                    (if media/mplayer/capture-dir (media/mplayer/write "capturing\n"))
+                    )
 
                    ;; ----------------------------------------
 
@@ -262,9 +273,19 @@ load Emacs less. Nil means no timing."
          (append
           '("mplayer" nil "mplayer" "-slave" "-quiet")
           media/mplayer/args
-          (if (string-match  "\\(asx\\|m3u\\|pls\\|ram\\)$" media/mplayer/url)
+          (when (string-match  "\\(asx\\|m3u\\|pls\\|ram\\)$" media/mplayer/url)
+            (if media/mplayer/capture-dir (list "-dumpfile"
+                                                (concat media/mplayer/capture-dir
+                                                        "/"
+                                                        (replace-regexp-in-string "[^a-zA-Z0-9\.]" "_" media/mplayer/url)
+                                                        (format-time-string "-%Y-%m-%d-%H:%M:%S"))
+                                                "-capture"
+                                                "-playlist"
+                                                )
               (list "-playlist"))
-          (list (replace-regexp-in-string "^file://" "" media/mplayer/url))))
+            )
+          (list (replace-regexp-in-string "^file://" "" media/mplayer/url)))
+         )
         media/mplayer/exit-type 'unknown
         media/mplayer/paused nil
         media/song-duration nil
@@ -278,7 +299,6 @@ load Emacs less. Nil means no timing."
   (process-kill-without-query media/mplayer/process)
   (media/mplayer/start-timing-requests)
   (media/mplayer/write "get_time_pos\n")
-
   )
 
 (defun media/api/stop () (interactive)