function issupport(url)
    if url:match("^http://v.163.com/") then return true end
    return false   
end


function analyze(url)
require('common')
local json = require('json')
require("xml")
    print('-----------------------enter analyze-----------------------')
    print('url:'..url)
    local agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)'
    --判断url 是否是video 还是movie
    b=string.match(url,'(movie)')
    print(b)
    if(b==nil)then
        page1=idown.requesturl(url,'','')
        vid=string.match(page1,'var vid="(%w*)"')
        print('vid:'..vid)
        cid=string.match(page1,'var topicid="(%d*)"')
        print('cid:'..cid)
        x=string.sub(vid,-2,-2)
        y=string.sub(vid,-1,-1)
        a=string.match(url,'/(%w*).html')
        print(a)
        url1='http://live.ws.126.net/video/'..x..'/'..y..'/'..cid..'_'..a..'.xml'
        print(url1)
    else
        page1=idown.requesturl(url,'','')
        vid=string.match(page1,"thisPlay.id = '(%w*)';")
        print('vid:'..vid)
        cid=string.match(page1,"thisMovieInfo.id = '(%w*)';")
        print('cid:'..cid)
        x=string.sub(cid,-2,-2)
        y=string.sub(cid,-1,-1)
        url1='http://live.ws.126.net/movie/'..x..'/'..y..'/'..'2'..'_'..vid..'_'..cid..'.xml'
        print(url1)
    end    
        
    page2=idown.requesturl(url1,'','')
    local k = xml.eval(page2)
    print(k)
    kk=k:find('flv')
    print(kk)
    realurl=kk[1]
    print(realurl)
    realname=string.match(page1,'<title>(.*)</title>')
    print('-----------------------1111111111111111-----------------------')
    print(realname)
    --获取文件后缀
    suffix =getsuffix(getfilename(realurl))
    realfilename=realname..suffix
   	result = {}
    result['realurl'] = realurl
	result['title'] = realname
	result['realname'] = realfilename
    retstr = json:encode(result)
	print('ret:'..retstr)
 
     print('-----------------------leave analyze-----------------------')
    return 1,retstr
end