require('common')
function issupport(url)
    if url:match("^http://www.51zxw.net/") then return true end
    return false
end

function analyze(url)
	print('-----------------------Enter analyze-----------------------')
	print(url)
	
	page = idown.requesturl(url, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0', '')
	print(page)
	iframe = page:match('%<P>ÊÓÆµÏÂÔØÖÐ¡£¡£¡£%<%/P>(.-)%<%/') or page:match('<IFRAME id=frm_v(.-)</IFRAME>')
	if iframe then
	url2 = iframe:match('src="(http://[^"]*)')
		
	realurl = string.gsub(url2, 'html', 'swf')
	print(realurl)
	else
	realurl = page:match('<PARAM NAME="Movie" VALUE="(.-)"')
	end
		
	title = page:match('<title>(.-)</title>')
	print(title)
		
	realfilename = title..getsuffix(realurl)
	print(realfilename)

	print('-----------------------Leave analyze-----------------------')
	json = require('json')

	result = {}
	result['title'] = title
	result['realurl'] = realurl
	result['realname'] = realfilename

	retstr = json:encode(result)
	print('ret:'..retstr)
	
	return 1, retstr	
end