--get adress

if m_simpleTV.Control.ChangeAdress ~= 'No' then return end
local inAdr =  m_simpleTV.Control.CurrentAdress
if inAdr==nil then return end

if  string.match(inAdr,'acelive$') or  string.match(inAdr,'^torrent') then return end
if  not string.match( inAdr, '1torrent%.tv' ) then return end


m_simpleTV.Control.ChangeAdress='Yes'
m_simpleTV.Control.CurrentAdress = ''

local session = m_simpleTV.WinInet.New("Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.9.168 Version/11.52")
if session == nil then return end

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

local rc,answer=m_simpleTV.WinInet.Get(session,inAdr)
 m_simpleTV.WinInet.Close(session)
 if rc~=200 then
	   m_simpleTV.OSD.ShowMessage('Page not found (error ' .. rc .. ')',255,5)
	   return
 end

--debug_in_file (answer)
local retAdr = findpattern( answer,'this%.loadTorrent%(%b""',1,18,1)
 if retAdr==nil then
	   retAdr = findpattern( answer,'this%.loadPlayer%(%b""',1,17,1)
	   if retAdr==nil then
	   	   m_simpleTV.OSD.ShowMessage("Not found torrent or ID",255,5)
	       return
	   end
	   retAdr  = 'PID=' .. retAdr 
	   --debug_in_file (retAdr )
 end

 m_simpleTV.Control.CurrentAdress = 'torrent://' .. retAdr
 