Commit 875ff318 authored by Marvin Scholz's avatar Marvin Scholz

lua: playlist/appletrailers: handle stream creation error

Add additional error handling/logging and some general cleanup of
parent c5c44df6
...@@ -32,26 +32,27 @@ function find( haystack, needle ) ...@@ -32,26 +32,27 @@ function find( haystack, needle )
end end
function parse_json(url) function parse_json(url)
vlc.msg.dbg("Trying to parse JSON from " .. url) local json = require("dkjson")
local json = require ("dkjson")
-- Use to grab a remote json file, place it in a string,
-- decode it and return the decoded data.
local stream = local stream =
local string = "" local string = ""
local line = "" local line = ""
if not stream then return false end if not stream then
return nil, nil, "Failed creating VLC stream"
while true do while true do
line = stream:readline() line = stream:readline()
if not line then break end
if not line then
string = string .. line string = string .. line
end end
if string == "" then if string == "" then
return 0, 0, "Got empty response from server." return nil, nil, "Got empty response from server."
end end
return json.decode(string) return json.decode(string)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment