[vlc-commits] lua: scripts: fix playlist
Loiret David
git at videolan.org
Thu Dec 19 10:29:14 CET 2019
vlc | branch: master | Loiret David <loiret.d at gmail.com> | Mon Oct 28 13:42:33 2019 +0100| [de30f66edf4155f360233442d285eb4d2cbdd51d] | committer: Thomas Guillem
lua: scripts: fix playlist
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de30f66edf4155f360233442d285eb4d2cbdd51d
---
share/lua/intf/modules/httprequests.lua | 37 +++++++--------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/share/lua/intf/modules/httprequests.lua b/share/lua/intf/modules/httprequests.lua
index 66e0e278ae..ef7ee2fca5 100644
--- a/share/lua/intf/modules/httprequests.lua
+++ b/share/lua/intf/modules/httprequests.lua
@@ -281,7 +281,6 @@ end
getplaylist = function ()
local p
-
if _GET["search"] then
if _GET["search"] ~= "" then
_G.search_key = _GET["search"]
@@ -291,7 +290,7 @@ getplaylist = function ()
local key = vlc.strings.decode_uri(_GET["search"])
p = vlc.playlist.search(key)
else
- p = vlc.playlist.get()
+ p = vlc.playlist.list()
end
--logTable(p) --Uncomment to debug
@@ -299,34 +298,14 @@ getplaylist = function ()
return p
end
-parseplaylist = function (item)
- if item.flags.disabled then return end
-
- if (item.children) then
+parseplaylist = function (list)
+ local playlist = {}
+ local current_item_id = vlc.playlist.current()
+ for i, item in ipairs(list) do
local result={}
- local name = (item.name or "")
-
- result["type"]="node"
- result.id=tostring(item.id)
- result.name=tostring(name)
- result.ro=item.flags.ro and "ro" or "rw"
-
- --store children in an array
- --we use _array as a proxy for arrays
- result.children={}
- result.children._array={}
- for _, child in ipairs(item.children) do
- local nextChild=parseplaylist(child)
- table.insert(result.children._array,nextChild)
- end
-
- return result
- else
- local result={}
local name, path = item.name or ""
local path = item.path or ""
- local current_item_id = vlc.playlist.current()
-- Is the item the one currently played
if(current_item_id ~= nil) then
@@ -334,16 +313,14 @@ parseplaylist = function (item)
result.current = "current"
end
end
-
result["type"]="leaf"
result.id=tostring(item.id)
result.uri=tostring(path)
result.name=name
- result.ro=item.flags.ro and "ro" or "rw"
result.duration=math.floor(item.duration)
-
- return result
+ playlist[i] = result
end
+ return playlist
end
More information about the vlc-commits
mailing list