
 if m_simpleTV.User.CDS.ScanServer == '1' then

 m_simpleTV.User.CDS.LastServer = nil 

if m_simpleTV.User.CDS.SvrTable == nil then
    dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/cdssvr.lua") 
    if m_simpleTV.User.CDS.SvrTable == nil then return end
end

--scan if table empty
if m_simpleTV.User.CDS.SvrTable[1] == nil then 
    m_simpleTV.User.CDS.SvrTable = nil
    m_simpleTV.OSD.ShowMessage("CDS: server not found, need rescan",255,3)
    dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/doscan.lua") 
   return
end

local svr = m_simpleTV.User.CDS.SvrTable[math.random(#m_simpleTV.User.CDS.SvrTable)]
---debug_in_file(svr .. '\n')

m_simpleTV.User.CDS.LastServer = 'http://'..svr..'/udp'

 
elseif m_simpleTV.User.CDS.ScanServer ~= '1' then

 m_simpleTV.User.CDS.LastServer = nil 

local file = io.open (m_simpleTV.MainScriptDir .. "user/tvplaylists/cds/proxylist.txt")

if file == nil then
           m_simpleTV.OSD.ShowMessage("CDS error: Proxylist not found",255,10)
	   return
 end

local t={}

for line in file:lines() do
  if string.match(line,'IP:') then
    table.insert(t, line)
  end
end
file:close()
local svr = t[math.random(#t)]
--debug_in_file(svr .. '\n')
svr = svr:match('IP: (.-)\t')

m_simpleTV.User.CDS.LastServer = 'http://'..svr..'/udp'

end 