and_cesbo

Playlist generator for Astra 4.5

May 17th, 2015
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. host = "server-address.local"
  2.  
  3. -- Do not change
  4.  
  5. __playlist_cache = nil
  6. astra_storage["/playlist.m3u8"] = function(server, client, request)
  7.     if not request then return nil end
  8.  
  9.     if not __playlist_cache then
  10.         __playlist_cache = "#EXTM3U\r\n"
  11.         for _,c in ipairs(channel_list) do
  12.             if c.config.enable and c.config.output then
  13.                 for _,o in ipairs(c.config.output) do
  14.                     local oc = parse_url(o)
  15.                     if oc.format == "http" then
  16.                         __playlist_cache = __playlist_cache .. "#EXTINF:-1," .. c.config.name .. "\r\n" .. "http://" .. host .. oc.path .. "\r\n"
  17.                     end
  18.                 end
  19.             end
  20.         end
  21.     end
  22.  
  23.     server:send(client, {
  24.         code = 200,
  25.         headers = {
  26.             "Content-Type: application/x-mpegurl",
  27.             "Connection: close",
  28.         },
  29.         content = __playlist_cache,
  30.     })
  31. end
Advertisement
Add Comment
Please, Sign In to add comment