function issupport(url)
	if url:match('^fs2you://') then return true end
	if url:match('^http://www.rayfile.com') then return true end
	return false
end

function getfs2youlink(url)
	local page = idown.requesturl(url)
	url2 = page:match("fs2you://[%w=/]+")
	if url2 then return url2 end 
	
	--key = page:match('var vkey = "([^"]*)')
	--url2 = url..key.."/"
	url2=page:match('<dt class="btn_22".-href="(.-)"')
	print(url2)
	page = idown.requesturl(url2,'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0',url)
	print(page)
	url = page:match("fs2you://[%w=/]+")
	return url
end

function analyze(url)
    local json = require('json')
    require('common')
	if url:match('^fs2you://') == nil then url = getfs2youlink(url) end
	print(url)
	
	decodeurl = url:match('^fs2you://(.+)')
	decodeurl = idown.crypt.base64decode(decodeurl)
	print(decodeurl)
	
	local arguments = split(decodeurl, '|')
	local realurl = 'http://'..arguments[1];
	local size = arguments[2];
	print(realurl)
	
	local title = urldecode(getfilename(realurl))
	local realfilename = title
	print(title)

	local result = {}
	result['encode'] = 65001
	result['realurl'] = realurl
	result['title'] = title
	result['realname'] = realfilename
	
	result['agent'] = 'Grid Service 2.1.10.8366'
	result['httpversion'] = 'HTTP/1.0'
	result['size'] = size;
	
	headers = {}
	headers['Grid'] = 'aWQ9yJrIz56ZyZ4mcF9udW09MCZkX3NwZWVkPTA='
	result['headers'] = headers
	
	retstr = json:encode(result)
	print('ret:'..retstr)
	
	return 1, retstr
end