if #arg < 1 then return nil end json = require "json" local _url = arg[1] local ret = {} local Curl = nil local CONF_PATH = "/var/tuxbox/config/" if DIR and DIR.CONFIGDIR then CONF_PATH = DIR.CONFIGDIR .. '/' end function pop(cmd) local f = assert(io.popen(cmd, 'r')) local s = assert(f:read('*a')) f:close() return s end function getdata(Url,outputfile,Postfields,pass_headers,httpheaders) if Url == nil then return nil end if Curl == nil then Curl = curl.new() end if Url:sub(1, 2) == '//' then Url = 'http:' .. Url end local ret, data = Curl:download{ url=Url, A="com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip",maxRedirs=5,followRedir=true,postfields=Postfields,header=pass_headers,o=outputfile,httpheader=httpheaders } if ret == CURL.OK then if outputfile then return 1 end return data else return nil end end function hex2char(hex) return string.char(tonumber(hex, 16)) end function unescape_uri(url) if url == nil then return nil end return url:gsub("%%(%x%x)", hex2char) end function add_entry(vurl,aurl,res1,res2,newname,count) entry = {} entry['url'] = vurl if aurl then entry['url2'] = aurl end entry['band'] = "1" --dummy entry['res1'] = res1 entry['res2'] = res2 entry['name'] = "" if newname then entry['name'] = newname end count = count + 1 ret[count] = {} ret[count] = entry return count end function get_MaxRes_YTKey() local maxRes = 1280 local key = nil local Nconfig = configfile.new() if Nconfig then Nconfig:loadConfig(CONF_PATH .. "neutrino.conf") maxRes = Nconfig:getInt32("livestreamResolution", 1280) key = Nconfig:getString("youtube_dev_id", '#') end return maxRes, key end function getVideoData(yurl) if yurl == nil then return 0 end if yurl:find("www.youtube.com/user/") or yurl:find("youtube.com/channel") or yurl:find("youtube.com/c/") or yurl:find("youtube.com/@") then --check user link or channel alias local youtube_user = getdata(yurl) if youtube_user == nil then return 0 end local youtube_live_url = youtube_user:match('"url":"(/watch.-)"') or youtube_user:match('feature=c4.-href="(/watch.-)"') or youtube_user:match('ytimg.com\\/vi\\/([a-zA-Z0-9_$%[%]]+)\\/default_live') or youtube_user:match('ytimg.com\\/vi\\/([a-zA-Z0-9_$%[%]]+)\\/hqdefault_live') if youtube_live_url == nil then youtube_user = getdata(yurl .. "/streams") youtube_live_url = youtube_user:match('"url":"(/watch.-)"') or youtube_user:match('feature=c4.-href="(/watch.-)"') or youtube_user:match('ytimg.com\\/vi\\/([a-zA-Z0-9_$%[%]]+)\\/default_live') or youtube_user:match('ytimg.com\\/vi\\/([a-zA-Z0-9_$%[%]]+)\\/hqdefault_live') end if youtube_live_url == nil then return 0 end if not youtube_live_url:find("/watch") then youtube_live_url = "/watch?v=" .. youtube_live_url end yurl = 'https://www.youtube.com' .. youtube_live_url end local h = hintbox.new{caption="Please Wait ...", text="I'm Thinking."} if h then h:paint() end local maxRes,key = get_MaxRes_YTKey() local data = getdata(yurl) local count = 0 if data then local newname = data:match('