[vlc-commits] lua: sd: strengthen icecast. (fix #8425)

Francois Cartegnie git at videolan.org
Wed Apr 24 16:34:02 CEST 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr 24 16:30:31 2013 +0200| [7144c1d36ffef99c6563d2716e85a852142643ce] | committer: Francois Cartegnie

lua: sd: strengthen icecast. (fix #8425)

XML is correct, but data is still random and full of junk...

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7144c1d36ffef99c6563d2716e85a852142643ce
---

 share/lua/sd/icecast.lua |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/share/lua/sd/icecast.lua b/share/lua/sd/icecast.lua
index 7242ec4..d6ecefe 100644
--- a/share/lua/sd/icecast.lua
+++ b/share/lua/sd/icecast.lua
@@ -25,12 +25,16 @@ function descriptor()
     return { title="Icecast Radio Directory" }
 end
 
+function dropnil(s)
+    if s == nil then return "" else return s end
+end
+
 function main()
     local tree = simplexml.parse_url("http://dir.xiph.org/yp.xml")
     for _, station in ipairs( tree.children ) do
         simplexml.add_name_maps( station )
         local station_name = station.children_map["server_name"][1].children[1]
-        if station_name == "Unspecified name" or station_name == ""
+        if station_name == "Unspecified name" or station_name == "" or station_name == nil
         then
                 station_name = station.children_map["listen_url"][1].children[1]
                 if string.find( station_name, "radionomy.com" )
@@ -41,15 +45,15 @@ function main()
         end
         vlc.sd.add_item( {path=station.children_map["listen_url"][1].children[1],
                           title=station_name,
-                          genre=station.children_map["genre"][1].children[1],
-                          nowplaying=station.children_map["current_song"][1].children[1],
+                          genre=dropnil(station.children_map["genre"][1].children[1]),
+                          nowplaying=dropnil(station.children_map["current_song"][1].children[1]),
                           uiddata=station.children_map["listen_url"][1].children[1]
-                                  .. station.children_map["server_name"][1].children[1],
+                                  .. dropnil(station.children_map["server_name"][1].children[1]),
                           meta={
                                   ["Listing Source"]="dir.xiph.org",
                                   ["Listing Type"]="radio",
-                                  ["Icecast Bitrate"]=station.children_map["bitrate"][1].children[1],
-                                  ["Icecast Server Type"]=station.children_map["server_type"][1].children[1]
+                                  ["Icecast Bitrate"]=dropnil(station.children_map["bitrate"][1].children[1]),
+                                  ["Icecast Server Type"]=dropnil(station.children_map["server_type"][1].children[1])
                           }} )
     end
 end



More information about the vlc-commits mailing list