and_cesbo icon

Playlist generator for Astra 4.5

and_cesbo | PRO | 05/17/15 05:27:19 PM UTC | 0 ⭐ | 803 👁️ | Never ⏰ | []
Lua |

940 B

|

None

|

0 👍

/

0 👎

host = "server-address.local"
 
-- Do not change
 
__playlist_cache = nil
astra_storage["/playlist.m3u8"] = function(server, client, request)
    if not request then return nil end
 
    if not __playlist_cache then
        __playlist_cache = "#EXTM3U\r\n"
        for _,c in ipairs(channel_list) do
            if c.config.enable and c.config.output then
                for _,o in ipairs(c.config.output) do
                    local oc = parse_url(o)
                    if oc.format == "http" then
                        __playlist_cache = __playlist_cache .. "#EXTINF:-1," .. c.config.name .. "\r\n" .. "http://" .. host .. oc.path .. "\r\n"
                    end
                end
            end
        end
    end
 
    server:send(client, {
        code = 200,
        headers = {
            "Content-Type: application/x-mpegurl",
            "Connection: close",
        },
        content = __playlist_cache,
    })
end

Comments