[vlc-devel] [PATCH] Fix nil value trac #25309 : Error in parsing Icecast Radio Directory

Lamisedaxeh lamisedaxeh at yahoo.com
Tue Dec 22 01:00:18 UTC 2020


---
 share/lua/sd/icecast.lua | 43 +++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/share/lua/sd/icecast.lua b/share/lua/sd/icecast.lua
index 5ad183b704..97fa338112 100644
--- a/share/lua/sd/icecast.lua
+++ b/share/lua/sd/icecast.lua
@@ -41,27 +41,30 @@ 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 == "" or station_name == nil
+        if not( station.children_map["listen_url"][1].children[1] == nil )
         then
-                station_name = station.children_map["listen_url"][1].children[1]
-                if string.find( station_name, "radionomy.com" )
-                then
-                        station_name = string.match( station_name, "([^/]+)$")
-                        station_name = string.gsub( station_name, "-", " " )
-                end
+            local station_name = station.children_map["server_name"][1].children[1]
+            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" )
+                    then
+                            station_name = string.match( station_name, "([^/]+)$")
+                            station_name = string.gsub( station_name, "-", " " )
+                    end
+            end
+            vlc.sd.add_item( {path=station.children_map["listen_url"][1].children[1],
+                              title=station_name,
+                              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]
+                                      .. dropnil(station.children_map["server_name"][1].children[1]),
+                              meta={
+                                      ["Listing Source"]="dir.xiph.org",
+                                      ["Listing Type"]="radio",
+                                      ["Icecast Bitrate"]=dropnil(station.children_map["bitrate"][1].children[1]),
+                                      ["Icecast Server Type"]=dropnil(station.children_map["server_type"][1].children[1])
+                              }} )
         end
-        vlc.sd.add_item( {path=station.children_map["listen_url"][1].children[1],
-                          title=station_name,
-                          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]
-                                  .. dropnil(station.children_map["server_name"][1].children[1]),
-                          meta={
-                                  ["Listing Source"]="dir.xiph.org",
-                                  ["Listing Type"]="radio",
-                                  ["Icecast Bitrate"]=dropnil(station.children_map["bitrate"][1].children[1]),
-                                  ["Icecast Server Type"]=dropnil(station.children_map["server_type"][1].children[1])
-                          }} )
     end
 end
-- 
2.29.2



More information about the vlc-devel mailing list