The attached patch take care of:
* adding some mplayer options to get the now playing song name
* adding the -playlist option in case the webradio has the streamlist type

I'm not a programmer, so there is certainly room for improvement but
it's basically doing its job.

Two minor things to note though:

* mplayer advises against using the -playlist option for security
  reasons, I guess it shouldn't be used by default and emms should use
  an option allowing the user to decide whether to use it or not.

* The mplayer output for some webradios has two different ICY fields
  (see
  --8<---------------cut here---------------start------------->8---
   mplayer -ao null -vo null -cache 200 -endpos 0 
http://ouifm5.ice.infomaniak.ch/ouifm2.aac
  --8<---------------cut here---------------end--------------->8---
  for instance)
  the first one being empty. emms-stream-info-call-backend unfortunately
  picks up the first (empty one). Some modifications should be made so
  that it picks the non empty one.

Regards,

Julien.
  
>From 62c351093010da6f686823ad0d95676ef4ee4ec4 Mon Sep 17 00:00:00 2001
From: Julien Cubizolles <j.cubizol...@free.fr>
Date: Fri, 14 Oct 2016 23:43:01 +0200
Subject: [PATCH 2/3] mplayer options to get the "now playing" track name from
 webradios

---
 lisp/emms-stream-info.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/emms-stream-info.el b/lisp/emms-stream-info.el
index bdf0aad..8cf8195 100644
--- a/lisp/emms-stream-info.el
+++ b/lisp/emms-stream-info.el
@@ -61,7 +61,9 @@
   "Backend command for running mplayer on URL."
   (condition-case excep
       (call-process "mplayer" nil t nil
-		    "-nocache" "-endpos" "0" "-vo" "null" "-ao" "null"
+		    "-cache" "256"
+		    "-endpos" "0" "-vo" "null" "-ao" "null"
+		    "-msglevel" "all=-1:network=4:demuxer=4"
 		    url)
     (file-error
      (error "Could not find the mplayer backend binary"))))
-- 
2.7.4

>From e0492b1543d52a9977a5c39a6432260149d0c85c Mon Sep 17 00:00:00 2001
From: Julien Cubizolles <j.cubizol...@free.fr>
Date: Fri, 14 Oct 2016 23:50:16 +0200
Subject: [PATCH 3/3] mplayer option to parse webradio playlists

---
 lisp/emms-stream-info.el | 15 ++++++++++-----
 lisp/emms-streams.el     |  5 +++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/emms-stream-info.el b/lisp/emms-stream-info.el
index 8cf8195..cb26cc5 100644
--- a/lisp/emms-stream-info.el
+++ b/lisp/emms-stream-info.el
@@ -57,13 +57,18 @@
 		(> (length (match-string-no-properties 1)) 0))
        (setq ,symname (match-string-no-properties 1)))))
 
-(defun emms-stream-info-mplayer-backend (url)
+(defun emms-stream-info-mplayer-backend (url type)
   "Backend command for running mplayer on URL."
+  (cond ((eq type 'streamlist)
+	 (setq urlcall "-playlist"))
+    ((eq type 'url)
+     (setq urlcall "")))
   (condition-case excep
       (call-process "mplayer" nil t nil
 		    "-cache" "256"
 		    "-endpos" "0" "-vo" "null" "-ao" "null"
 		    "-msglevel" "all=-1:network=4:demuxer=4"
+		    urlcall
 		    url)
     (file-error
      (error "Could not find the mplayer backend binary"))))
@@ -77,7 +82,7 @@
     (file-error
      (error "Could not find the VLC backend binary"))))
 
-(defun emms-stream-info-call-backend (url)
+(defun emms-stream-info-call-backend (url type)
   "Call backend and return a list of stream information for URL."
   (let ((name "N/A")
 	(genre "N/A")
@@ -87,7 +92,7 @@
       (message "querying stream...")
       (cond
        ((eq *emms-stream-info-backend* 'mplayer)
-	(emms-stream-info-mplayer-backend url)
+	(emms-stream-info-mplayer-backend url type)
 	(emms-stream-info-defreg name "^Name[ ]+:[ ]+\\(.*\\)$")
 	(emms-stream-info-defreg genre "^Genre[ ]+:[ ]+\\(.*\\)$")
 	(emms-stream-info-defreg bitrate "^Bitrate[ ]+:[ ]+\\(.*\\)$")
@@ -103,10 +108,10 @@
     (list name genre bitrate nowplaying)))
 
 ;; point of entry
-(defun emms-stream-info-message (url)
+(defun emms-stream-info-message (url type)
   "Display a message with information about the stream at URL."
   (interactive "Murl: ")
-  (let* ((stream-info (emms-stream-info-call-backend url))
+  (let* ((stream-info (emms-stream-info-call-backend url type))
 	 (name (nth 0 stream-info))
 	 (genre (nth 1 stream-info))
 	 (bitrate (nth 2 stream-info))
diff --git a/lisp/emms-streams.el b/lisp/emms-streams.el
index 41de8d2..3b19224 100644
--- a/lisp/emms-streams.el
+++ b/lisp/emms-streams.el
@@ -478,8 +478,9 @@ Don't forget to save your modifications !"
   (interactive)
   (if (fboundp 'emms-stream-info-message)
       (let* ((line (get-text-property (point) 'emms-stream))
-	     (url (emms-stream-url line)))
-	(emms-stream-info-message url))
+	     (url (emms-stream-url line))
+	     (type (emms-stream-type line)))
+	(emms-stream-info-message url type))
     (message "Streaming media info not available.")))
 
 ;; Killing and yanking
-- 
2.7.4

_______________________________________________
Emms-help mailing list
Emms-help@gnu.org
https://lists.gnu.org/mailman/listinfo/emms-help

Reply via email to