require('idownx')

function issupport(url)
	if url:find('^http://www.88mtv.com/play/%d+.html') then return true end
	return false
end

function analyze(url)
	local page = idown.requesturl(url)
	print(page)
	local suburl = page:match('var urv="(.-)";')
	local page2,head2 = idown.requesturl('http://st4x.88mtv.com:97/vsidasp.asp?js=yes')
	local cookie = head2:match('virtualwall=.-;')	
	local title = page:match('ÕýÔÚ²¥·Å£º(.-)</div>')
	print(suburl,cookie,title)

	local result = {
		title = title,
		realurl = 'http://st4x.88mtv.com:97/MTV/'..suburl..'.mp3',
		realname = title..'.mp3',
		headers = {
			Cookie = cookie,
			Referer = 'http://www.88mtv.com/play/js/Jplayer.swf'
		}
	}
	
	return idown.ERR_SINGLE_FILE, idown.encode(result)
end