[vlc-commits] lua: playlist/appletrailers: handle stream creation error

Marvin Scholz git at videolan.org
Wed Apr 25 13:47:21 CEST 2018


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Apr 25 13:47:06 2018 +0200| [875ff3187c2a8c594f95691d803f9b2e2e45c14b] | committer: Marvin Scholz

lua: playlist/appletrailers: handle stream creation error

Add additional error handling/logging and some general cleanup of
parse_json.

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

 share/lua/playlist/appletrailers.lua | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/share/lua/playlist/appletrailers.lua b/share/lua/playlist/appletrailers.lua
index 60148c1375..c10b135db5 100644
--- a/share/lua/playlist/appletrailers.lua
+++ b/share/lua/playlist/appletrailers.lua
@@ -32,26 +32,27 @@ function find( haystack, needle )
 end
 
 function parse_json(url)
-    vlc.msg.dbg("Trying to parse JSON from " .. url)
-    local json = require ("dkjson")
-
-    -- Use vlc.stream to grab a remote json file, place it in a string,
-    -- decode it and return the decoded data.
+    local json   = require("dkjson")
     local stream = vlc.stream(url)
     local string = ""
     local line   = ""
 
-    if not stream then return false end
+    if not stream then
+        return nil, nil, "Failed creating VLC stream"
+    end
 
     while true do
         line = stream:readline()
-        if not line then break end
+
+        if not line then
+            break
+        end
 
         string = string .. line
     end
 
     if string == "" then
-    	return 0, 0, "Got empty response from server."
+        return nil, nil, "Got empty response from server."
     end
 
     return json.decode(string)



More information about the vlc-commits mailing list