require('common')
function issupport(url)
    --http://www.21edu8.com/art/shuhua/27710/
    if url:match('^http://www.21edu8.com/') then return true end
    return false
end

function analyze(url)
    print('-----------------------enter analyze-----------------------')
    print('url:'..url)
    
    local json = require('json')
    --´ò¿ªÍøÕ¾
    page1 = idown.requesturl(url)
	--print('page1:\n'..page1)
	id=string.match(url, '/(%d.*)/')
	print(id)
	url1=string.gsub(url,'show.html?.*',id..'%.js')
	print(url1)
	page2=idown.requesturl(url1)
	
	index = tonumber(string.match(url, '(%d+)$'))
	print(index)
	iid=''
	
	t = {}
	i = 0
	for match in string.gmatch(page2,"unescape%('(.-)'%)") do
	    iid=match
	    t[i] = match
	    i = i + 1
	    print(match)
	end
	--print('iid:'..iid)
	print('----------------------')
	print(t[index])
	
	
	key=string.match(t[index],'%$(.*)%$')
	print(key)
	provider=string.match(t[index],'$(%a.*)')
	print('--------------gdfdfgdfgdfg--------')
	print(provider)
	
	if provider=='tudou' then
	    url2='http://www.tudou.com/v/'..key..'/v.swf'
	elseif provider=='youku' then
	    url2='http://player.youku.com/player.php/sid/'..key..'/v.swf'
	end
	print(url2)
    
    result={}
    result.Location=url2
    retstr=json:encode(result)
	print('-----------------------leave analyze-----------------------')
    return 301,retstr
end
   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


