function issupport(url)
    if url:match('^http://www.acfun.tv/') then return true end
    return false
end

function analyze(url)
    print('-----------------------enter analyze-----------------------')
    print('url:'..url)
    
    local json = require('json')
    require('common')
    
    --´ò¿ªÍøÕ¾
    local page1 = idown.requesturl(url)
		local id = page1:match("%[Video%](%d+)%[/Video%]")	
		print(id)
		
		if id then 
		local infourl = "http://www.acfun.tv/api/getVideoByID.aspx?vid="..id
		local infopage = idown.requesturl(infourl)
		p = json:decode(infopage)
		else
			s = page1:match('flashvars="(.-)"')	
			print(s)
			s = unescapexml(s)
			print(s)
	
			p = urlparamdecode(s)
			if p.type2 then p.vtype = p.type2 end
			if p.type == 'video' then p.vtype = 'sina' end
			p.vid = p.id
		end		
		if p.vtype == 'youku' then u = string.format('http://v.youku.com/v_show/id_%s.html', p.vid) end 
		if p.vtype == 'tudou' then u = 'http://www.tudou.com/v/'..p.vid..'/v.swf' end
		if p.vtype == 'sina' then 
			url2 = 'http://v.iask.com/v_play.php?vid='..p.vid
			page2 = idown.requesturl(url2)
			u = page2:match('<url><!%[CDATA%[(.-)]]>')
			result={}
			result.realurl = u
			result.encode = 65001
			result.redown = true
			result.title = page1:match('<title>(.-)</title>')..'.hlv'
			result.realname = result.title
			return 1,json:encode(result)
		end
		
		print(u)
		
    result={}
    result.Location=u
    retstr=json:encode(result)
		print('-----------------------leave analyze-----------------------')
    return 301,retstr
end