|
|
|
@ -21,7 +21,7 @@ |
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|
|
|
--]==========================================================================] |
|
|
|
|
|
|
|
module("httprequests",package.seeall) |
|
|
|
local httprequests = {} |
|
|
|
|
|
|
|
local common = require ("common") |
|
|
|
local dkjson = require ("dkjson") |
|
|
|
@ -38,6 +38,7 @@ function round(what, precision) |
|
|
|
end |
|
|
|
return nil |
|
|
|
end |
|
|
|
httprequests.round = round |
|
|
|
|
|
|
|
--split text where it matches the delimiter |
|
|
|
function strsplit(text, delimiter) |
|
|
|
@ -63,6 +64,7 @@ function strsplit(text, delimiter) |
|
|
|
end |
|
|
|
return list |
|
|
|
end |
|
|
|
httprequests.strsplit = strsplit |
|
|
|
|
|
|
|
--main function to process commands sent with the request |
|
|
|
|
|
|
|
@ -206,6 +208,7 @@ processcommands = function () |
|
|
|
local val = nil |
|
|
|
|
|
|
|
end |
|
|
|
httprequests.processcommands = processcommands |
|
|
|
|
|
|
|
--utilities for formatting output |
|
|
|
|
|
|
|
@ -218,6 +221,7 @@ function xmlString(s) |
|
|
|
return tostring(s) |
|
|
|
end |
|
|
|
end |
|
|
|
httprequests.xmlString = xmlString |
|
|
|
|
|
|
|
--dkjson outputs numbered tables as arrays |
|
|
|
--so we don't need the array indicators |
|
|
|
@ -237,6 +241,7 @@ function removeArrayIndicators(dict) |
|
|
|
|
|
|
|
return newDict |
|
|
|
end |
|
|
|
httprequests.removeArrayIndicators = removeArrayIndicators |
|
|
|
|
|
|
|
printTableAsJson = function (dict) |
|
|
|
dict=removeArrayIndicators(dict) |
|
|
|
@ -244,6 +249,7 @@ printTableAsJson = function (dict) |
|
|
|
local output=dkjson.encode (dict, { indent = true }) |
|
|
|
print(output) |
|
|
|
end |
|
|
|
httprequests.printTableAsJson = printTableAsJson |
|
|
|
|
|
|
|
local printXmlKeyValue = function (k,v,indent) |
|
|
|
print("\n") |
|
|
|
@ -269,12 +275,14 @@ local printXmlKeyValue = function (k,v,indent) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
httprequests.printXmlKeyValue = printXmlKeyValue |
|
|
|
|
|
|
|
printTableAsXml = function (dict,indent) |
|
|
|
for k,v in pairs(dict) do |
|
|
|
printXmlKeyValue(k,v,indent) |
|
|
|
end |
|
|
|
end |
|
|
|
httprequests.printTableAsXml = printTableAsXml |
|
|
|
|
|
|
|
--[[ |
|
|
|
function logTable(t,pre) |
|
|
|
@ -309,6 +317,7 @@ getplaylist = function () |
|
|
|
|
|
|
|
return p |
|
|
|
end |
|
|
|
httprequests.getplaylist = getplaylist |
|
|
|
|
|
|
|
parseplaylist = function (item) |
|
|
|
if item.flags.disabled then return end |
|
|
|
@ -357,6 +366,7 @@ parseplaylist = function (item) |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
httprequests.parseplaylist = parseplaylist |
|
|
|
|
|
|
|
playlisttable = function () |
|
|
|
|
|
|
|
@ -364,6 +374,7 @@ playlisttable = function () |
|
|
|
|
|
|
|
return parseplaylist(basePlaylist) |
|
|
|
end |
|
|
|
httprequests.playlisttable = playlisttable |
|
|
|
|
|
|
|
getbrowsetable = function () |
|
|
|
|
|
|
|
@ -441,6 +452,7 @@ getbrowsetable = function () |
|
|
|
|
|
|
|
return result; |
|
|
|
end |
|
|
|
httprequests.getbrowsetable = getbrowsetable |
|
|
|
|
|
|
|
|
|
|
|
getstatus = function (includecategories) |
|
|
|
@ -553,4 +565,7 @@ getstatus = function (includecategories) |
|
|
|
end |
|
|
|
return s |
|
|
|
end |
|
|
|
httprequests.getstatus = getstatus |
|
|
|
|
|
|
|
_G.httprequests = httprequests |
|
|
|
return httprequests |
|
|
|
|