local service = 'Viet-Simpletv'

--local session=m_simpleTV.WinInet.New("ie")
	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)
 
	m_simpleTV.OSD.ShowMessage_UTF8(service .. ' - Đang làm mới danh sách...',0x00FF00,10)
	local rc,answer
	--rc,answer=m_simpleTV.WinInet.Get(session,root) 
	--if rc~=200 then 
	--   m_simpleTV.OSD.ShowMessage_UTF8("Lỗi mạng - " .. rc,255,5)
 	--  return
 	--end 
	
--load
local ProviderName = '' --empty line if not needed
local FileUrl = 'http://vietcago.com/tv/kenh.m3u'

if FileUrl == nil or FileUrl == '' then return end

local tmpName = m_simpleTV.Common.DownloadFileInTmp (FileUrl,'simpleTVtmp.tmp')

if tmpName == nil then
	m_simpleTV.OSD.ShowMessage_UTF8(ProviderName .. " Lỗi - Không thể tải file", 0x0000FF, 10)
	m_simpleTV.Common.Wait(2000)
	return
end

--options to load playlist 
p = {}
p.TypeSourse		= 1
p.DeleteBeforeLoad	= 1
p.TypeSkip			= 1
p.TypeFind			= 0
p.AutoSearch		= 1
p.NumberM3U			= 0
p.Find_Group		= 1
p.TypeCoding		= 1	--  -1-auto  0 - plane text  1- UTF8  2- unicode
p.ExtFilter = ProviderName

local err = m_simpleTV.Common.LoadPlayList(tmpName, p, 0, true, false)
os.remove(tmpName)

if err then 
	m_simpleTV.OSD.ShowMessage_UTF8(ProviderName ..  "Viet-Simpletv - Đã làm mới danh sách", 0x00FF00, 5)
else    
	m_simpleTV.OSD.ShowMessage_UTF8(ProviderName .. "Lỗi - Không thể tải file" , 0x0000FF, 10)
	m_simpleTV.Common.Wait(2000)
end
