if m_simpleTV.Control.ChangeAdress ~= 'No' then return end

local inAdr =  m_simpleTV.Control.CurrentAdress

if inAdr==nil then return end

if not string.match( inAdr, '^http://m%.ntv%.ru/air' ) then return end

m_simpleTV.Control.ChangeAdress='Yes'
m_simpleTV.Control.CurrentAdress = ''
----------------------------------------------------------------
local session = m_simpleTV.WinInet.New("Mozilla/5.0 (iPad; CPU OS 7_1 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/33.0.1750.15 Mobile/11D167 Safari/9537.53")
if session == nil then return end

 --INTERNET_OPTION_CONNECT_TIMEOUT
 m_simpleTV.WinInet.SetOptionInt(session,2,5000,0)
 --INTERNET_OPTION_RECEIVE_TIMEOUT
 m_simpleTV.WinInet.SetOptionInt(session,6,5000,0)
---------------------------------------------------------------


local  rc,answer=m_simpleTV.WinInet.Get(session,inAdr)

 if rc~=200 then
	   m_simpleTV.WinInet.Close(session)
	   m_simpleTV.OSD.ShowMessage("Connection error - " .. rc ,255,10)
	   return
 end
--debug_in_file(answer .. "\n\n")

local retAdr = findpattern( answer, "hlsStream = \'(.-)\'",1,13,1)

if retAdr == nil then
m_simpleTV.OSD.ShowMessage("m3u8 not found - " .. rc ,255,10)
m_simpleTV.WinInet.Close(session)
m_simpleTV.Control.CurrentAdress = retAdr
return
end

--debug_in_file(retAdr .. '\n\n')

m_simpleTV.WinInet.Close(session)
m_simpleTV.Control.CurrentAdress = retAdr