--http://spbtvonline.ru/kanaly-tv/anekdot_tv.html --http://spbtvonline.ru/kanaly-tv/pervyi-kanal-online.html --http://spbtvonline.ru/kanaly-tv/rossiia_1.html function probe() if vlc.access ~= "http" and vlc.access ~= "https" then return false end return vlc.path:match("spbtvonline%.ru/kanaly%-tv") or vlc.path:match("tv3%.spr%.spbtv%.com") end function addParameter( url, param ) if url:match( "%?" ) then url = url .. "&" else url = url .. "?" end return url .. param end function trim1(s) return (s:gsub("^%s*(.-)%s*$", "%1")) end -- Parse function. function parse() local html = vlc.read(200000) if vlc.path:match("tv3.spr.spbtv.com") then url = "http://spbtv.cdn.spbtv.com/" .. html:match("spbtv%.cdn%.spbtv%.com/(.-)%.m3u8") .. "-inadv-qidx-1k_v2.m3u8" url = url:gsub("657%-inadv%-qidx%-1k_v2", "657%-2064k") url = url:gsub("514%-inadv%-qidx%-1k_v2", "514%-2064k") url = url:gsub("515%-inadv%-qidx%-1k_v2", "515%-2064k") title = vlc.path:match("title=([^&]+)" ) img = vlc.path:match("poster=([^&]+)") if not url then vlc.msg.err("Couldn't find url to stream in the "..vlc.access.."://"..vlc.path) end if title then title = vlc.strings.decode_uri(title) end if img then img = vlc.strings.decode_uri(img ) end else urlid = html:match("'#ch_(.-)'%)%.addClass" ) title = html:match("(.-)" ) img = "http://spbtvonline.ru/tafiimage/" .. urlid .. ".png" if not urlid then vlc.msg.err("Couldn't find iframe url in the "..vlc.access.."://"..vlc.path) return {} end if urlid then url = "http://tv3.spr.spbtv.com/v1/channels/" .. urlid .. "/stream?protocol=hls" url = addParameter(url, "poster="..vlc.strings.encode_uri_component(img)) end if title then title = trim1(title:gsub("смотреть", "")) title = trim1(title:gsub("Смотреть", "")) title = trim1(title:gsub("Смотрите", "")) title = trim1(title:gsub("онлайн", "")) title = trim1(title:gsub("ТВ каналы", "")) title = trim1(title:gsub("SPB TV", "")) title = trim1(title:gsub("бесплатно!", "")) title = trim1(title:gsub("бесплатно", "")) title = trim1(title:gsub("в прямом эфире", "")) title = trim1(title:gsub(" SPB", "")) title = trim1(title:gsub(" »", "")) title = title:gsub(" %-", "") url = addParameter(url, "title="..vlc.strings.encode_uri_component(title)) end end item = {} item.path = url item.title = title item.arturl = img item.options = { ":http-user-agent=Mozilla/5.0"; ':http-referrer='..vlc.access.."://"..vlc.path } return { item } end