[Extension] Mix playlists

Discuss your Lua playlist, album art and interface scripts.
mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

[Extension] Mix playlists

Postby mederi » 29 Aug 2015 20:05

The idea: https://forum.videolan.org/viewtopic.ph ... 49#p430409
Perhaps it could become a part of Sampler (PG).

Code: Select all

-- VLC Extension that searches for playlist items (location) in several xspf playlists -- and then combines them in 1 playlist so the items take turns: {a1, b1, a2, b2, b3} -- or {a1, b1, a2, b2, a1, b3}. --[[ tab={ {"a1","a2"}, {"b1","b2","b3"}, } --]] -- TO DO: proper parsing of playlist files; parsing of folders; function descriptor() return { title = "Mix playlists", capabilities = {}, } end function activate() Create_dialog() end function deactivate() end function meta_changed() end function close() vlc.deactivate() end --------------------------- function Create_dialog() d = vlc.dialog(descriptor().title) l_mix = d:add_label("Enqueue xspf playlist files in VLC playlist,<br /> then press [Read playlist] button,<br /> then [Clear playlist]<br /> and then [Mix].",1,1,3,2) cb_supplement = d:add_check_box("supplement", false, 3,2,1,1) d:add_button("Read playlist", click_Read, 1,3,1,1) d:add_button("Clear playlist", click_Clear, 2,3,1,1) d:add_button("Mix", click_Mix, 3,3,1,1) end function click_Read() tab={} local playlist = vlc.playlist.get("playlist",false) for k, item in pairs(playlist.children) do if string.match(item.path, "%.xspf$") then local s = vlc.stream(item.path) --if s==nil then return false end local playlist_tab = {} while true do line = s:readline() if not line then break else for location in string.gmatch(line, "<location>(.-)</location>") do table.insert(playlist_tab, vlc.strings.resolve_xml_special_chars(location)) end end end vlc.msg.info(#playlist_tab) table.insert(tab, playlist_tab) end end local message="" for i,v in ipairs(tab) do message=message.."Playlist "..i..": "..#v.." items<br />" end if message=="" then message="No items found." end l_mix:set_text(message) end function click_Clear() vlc.playlist.clear() end function click_Mix() local tabmix={} local x=0 local a=0 for i,v in ipairs(tab) do if #v>a then a=#v end end while true do x=x+1 local y=0 for i,v in ipairs(tab) do if v[x]~=nil then y=y+1 table.insert(tabmix, v[x]) elseif cb_supplement:get_checked() then table.insert(tabmix, v[(x-1) % #v + 1]) end end if x==a or y==0 then break end end --l_mix:set_text(table.concat(tabmix,", ")) for i,v in ipairs(tabmix) do vlc.playlist.enqueue({{path=v}}) end end
--- EDIT 2.9.2015 ---
vlc.strings.resolve_xml_special_chars

Timic83
New Cone
New Cone
Posts: 9
Joined: 14 Sep 2013 20:33

Re: [Extension] Mix playlists

Postby Timic83 » 15 Sep 2015 13:32

This extension does a fantastic job! Thankyou very much for making it :)

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: [Extension] Mix playlists

Postby mederi » 15 Sep 2015 21:52

okay


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 15 guests