emms-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emms-patches] [PATCH] emms-player-mpd.el: Parsing of supported formats


From: David Engster
Subject: [Emms-patches] [PATCH] emms-player-mpd.el: Parsing of supported formats for newer versions of mpd.
Date: Tue, 02 Mar 2010 22:00:36 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.92 (gnu/linux)

* emms-player-mpd: (emms-player-mpd-get-supported-regexp): Added code
  to parse the output of newer versions of mpd.
---
 lisp/emms-player-mpd.el |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/emms-player-mpd.el b/lisp/emms-player-mpd.el
index 4b37cee..ae43aa1 100644
--- a/lisp/emms-player-mpd.el
+++ b/lisp/emms-player-mpd.el
@@ -140,19 +140,24 @@ leave it set to nil."
 (defun emms-player-mpd-get-supported-regexp ()
   "Returns a regexp of file extensions that MusicPD supports,
 or nil if we cannot figure it out."
-  (let ((out (split-string (shell-command-to-string "mpd --version")
-                           "\n"))
+  (let ((out (shell-command-to-string "mpd --version"))
         (found-start nil)
         (supported nil))
     ;; Get supported formats
-    (while (car out)
-      (cond ((string= (car out) "Supported formats:")
-             (setq found-start t))
-            ((string= (car out) "")
-             (setq found-start nil))
-            (found-start
-             (setq supported (concat supported (car out)))))
-      (setq out (cdr out)))
+    ;; New version (0.15.x)
+    (if (string-match "Supported decoders:\\([^0]+?\\)Supported outputs:" out)
+       (setq supported (replace-regexp-in-string "\\[.+?\\]" ""
+                                                 (match-string 1 out)))
+      ;; Older versions
+      (setq out (split-string out "\n"))
+      (while (car out)
+       (cond ((string= (car out) "Supported formats:")
+              (setq found-start t))
+             ((string= (car out) "")
+              (setq found-start nil))
+             (found-start
+              (setq supported (concat supported (car out)))))
+       (setq out (cdr out))))
     ;; Create regexp
     (when (and (stringp supported)
                (not (string= supported "")))
-- 
1.6.3.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]