Heavy cosmetics in media/mplayer/filter-subfunctions.
authorFrancois Fleuret <francois@fleuret.org>
Thu, 12 Mar 2015 18:03:18 +0000 (19:03 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Thu, 12 Mar 2015 18:03:18 +0000 (19:03 +0100)
media-mplayer.el

index 77f1516..c7c581e 100644 (file)
@@ -69,117 +69,121 @@ load Emacs less. Nil means no timing."
 
 (defun media/mplayer/filter-subfunctions (cmd param)
   ;; (unless (string= cmd "A:")
-    ;; (message "cmd=%s param=%s" cmd param)
-    ;; )
+  ;; (message "cmd=%s param=%s" cmd param)
+  ;; )
   (eval
-   (cdr
-    (assoc cmd
+   (cons 'progn
+         (cdr
+          (assoc cmd
 
-           '(
+                 '(
 
-             ;; ----------------------------------------
+                   ;; ----------------------------------------
 
-             ("ICY Info:" .
-              (progn
-                ;; (message "ICY Info \"%s\"" param)
-                (if (string-match "StreamTitle='\\([^;]*\\)';" param)
-                    (setq media/current-song-in-stream
-                          (let ((s (match-string 1 param)))
-                            (concat (if (string= s "") "<no title>" s)
-                                    " | "
-                                    ;; (current-time-string)
-                                    (format-time-string "%a %b %d %H:%M:%S")
-                                    )))
-                  (setq media/current-song-in-stream nil)
-                  (message "ICY Info \"%s\"" param))
-                (if (and media/current-song-in-stream media/current-information)
-                    (media/show-current-information)))
-              )
+                   ("ICY Info:"
+                    ;; (message "ICY Info \"%s\"" param)
 
-             ;; ----------------------------------------
+                    (if (string-match "StreamTitle='\\([^;]*\\)';" param)
 
-             ("ANS_LENGTH" .
+                        (setq media/current-song-in-stream
+                              (let ((s (match-string 1 param)))
+                                (concat (if (string= s "") "<no title>" s)
+                                        " | "
+                                        (format-time-string "%a %b %d %H:%M:%S")
+                                        )
+                                )
+                              )
 
-              (setq media/song-duration
-                    (string-to-number (substring param 1))))
+                      (setq media/current-song-in-stream nil)
 
-             ;; ----------------------------------------
+                      ;; If we did not parse it properly, show it
+                      (message "ICY Info \"%s\"" param))
 
-             ("ANS_TIME_POSITION" .
+                    (if (and media/current-song-in-stream media/current-information)
+                        (media/show-current-information))
+                    )
 
-              (progn
-                (setq media/song-current-time
-                      (string-to-number (substring param 1)))
+                   ;; ----------------------------------------
 
-                (when (and media/duration-to-history
-                           (< media/mplayer/cumulated-duration media/duration-to-history))
+                   ("ANS_LENGTH"
 
-                  (when media/mplayer/last-current-time
-                    (setq media/mplayer/cumulated-duration
-                          (+ media/mplayer/cumulated-duration
-                             (- media/song-current-time media/mplayer/last-current-time))))
+                    (setq media/song-duration
+                          (string-to-number (substring param 1))))
 
-                  (when (>= media/mplayer/cumulated-duration media/duration-to-history)
-                    (media/put-in-history)
-                    )
+                   ;; ----------------------------------------
 
-                  (setq media/mplayer/last-current-time media/song-current-time)
-                  )
+                   ("ANS_TIME_POSITION"
 
+                    (setq media/song-current-time
+                          (string-to-number (substring param 1)))
 
-                )
-              )
+                    (when (and media/duration-to-history
+                               (< media/mplayer/cumulated-duration media/duration-to-history))
 
-             ;; ----------------------------------------
+                      (when media/mplayer/last-current-time
+                        (setq media/mplayer/cumulated-duration
+                              (+ media/mplayer/cumulated-duration
+                                 (- media/song-current-time media/mplayer/last-current-time))))
 
-             ("AUDIO:" .
+                      (when (>= media/mplayer/cumulated-duration media/duration-to-history)
+                        (media/put-in-history)
+                        )
 
-              (progn
-                ;; param = "44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)"
-                (when (string-match "^\\([0-9]+\\) Hz, \\([0-9]+\\) ch.* \\([0-9.]+\\) kbit"
-                                    param)
-                  (setq media/current-information
-                        (list media/mplayer/url
-                              (string-to-number (match-string 1 param))
-                              (string-to-number (match-string 2 param))
-                              (string-to-number (match-string 3 param))))
-                  )
-                (run-hooks 'media/play-hook)
-                ))
+                      (setq media/mplayer/last-current-time media/song-current-time)
+                      )
+                    )
 
-             ;; ----------------------------------------
+                   ;; ----------------------------------------
 
-             ("Starting" .
-              (media/mplayer/write "get_time_length\n"))
+                   ("AUDIO:"
 
-             ;; ----------------------------------------
+                    ;; param = "44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)"
+                    (when (string-match "^\\([0-9]+\\) Hz, \\([0-9]+\\) ch.* \\([0-9.]+\\) kbit"
+                                        param)
+                      (setq media/current-information
+                            (list media/mplayer/url
+                                  (string-to-number (match-string 1 param))
+                                  (string-to-number (match-string 2 param))
+                                  (string-to-number (match-string 3 param))))
+                      )
+                    (run-hooks 'media/play-hook)
+                    )
 
-             ("Cache fill:" .
+                   ;; ----------------------------------------
 
-              (when (string-match "(\\([0-9]+\\) bytes" param)
-                (message "Caching stream (%dkb)"
-                         (/ (string-to-number (match-string 1 param)) 1024))))
+                   ("Starting"
+                    (media/mplayer/write "get_time_length\n"))
 
-             ;; ----------------------------------------
+                   ;; ----------------------------------------
 
-             ("Exiting..." .
+                   ("Cache fill:"
+                    (when (string-match "(\\([0-9]+\\) bytes" param)
+                      (message "Caching stream (%dkb)"
+                               (/ (string-to-number (match-string 1 param)) 1024))))
 
-              (progn
-                (setq media/mplayer/exit-type
-                      (cdr (assoc param '(("(End of file)" . file-finished)
-                                          ("(Quit)" . quit))))
-                      media/current-information nil
-                      media/song-duration nil
-                      media/song-current-time nil)
+                   ;; ----------------------------------------
 
-                (when media/mplayer/process (kill-process media/mplayer/process))
+                   ("Exiting..."
+                    (setq media/mplayer/exit-type
+                          (cdr (assoc param '(("(End of file)" . file-finished)
+                                              ("(Quit)" . quit))))
+                          media/current-information nil
+                          media/song-duration nil
+                          media/song-current-time nil)
 
-                (force-mode-line-update)))
+                    (when media/mplayer/process (kill-process media/mplayer/process))
 
-             ;; ----------------------------------------
+                    (force-mode-line-update)
+                    )
+
+                   ;; ----------------------------------------
 
-             )
-           ))))
+                   )
+                 )
+          )
+         )
+   )
+  )
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;