require('idownx')

function issupport(url)
	if url:find('^http://www.1ting.com/player/') then return true end
	return false
end

function analyze(url)
	print('-----------------------Enter analyze-----------------------')
	print('url:'..url)
		
	local page = idown.requesturl(url)
	--print('page:\n'..page)
	
	--获得播放列表
	local jsonstring = page:match('(%[%[.*%]%])')
	print('jsonstring:'..jsonstring)
	
	local songs = json:decode(jsonstring)
	print('song1:')
	for i,v in ipairs(songs[1]) do
		v = idown.toansi(v)
		print(v)
	end
	
	local realurl = 'http://nonie.1ting.com:9092'..songs[1][8]
	local title = songs[1][4]..'-'..songs[1][2]
		
	--获取文件后缀
	local suffix = getsuffix(realurl)
	print('suffix:'..suffix)
	
	local realfilename = title..suffix
	print('realfilename:'..realfilename)
	
	local result = {
		title = title,
		files = {
			{realname = realfilename, realurl = realurl},
		},
	}

	retstr = json:encode(result)
	return 202, retstr
end