import math
import urllib, urllib2
import re
def vip_unlockmeta(meta):
	d=''
	for i in range(0, len(meta)):
		if (i % 3 == 0):
			d += "%";
		else:
			d += meta[i];
	return urllib.unquote(d);

def get_html(meta,data):
	meta_un=vip_unlockmeta(meta)
#	print meta_un;
#	return 
	oo=''
	x=data
	l = len(x)
	b = 1024.0
	i, j, r, p = 0,0,0,0
	s = 0
	w = 0
	str_pattern='Array\((.*?)\)'
	array_val=re.compile(str_pattern).findall(meta_un)[0] 
	t_string = 't=['+array_val+']'
	exec(t_string)
#	print t_string
#	return
	#print math.ceil(l / b)
	#print t
	for j in range(int(math.ceil(l / b)), 0, -1):
		r = '';
#		for (i = ath.min(l, b); i > 0; i--, l--):
		for i in range( int(min(l, b)),0, -1):
#			w |= (t[ ord(x[p]) - 48]) << s;
#			print i-1024, p
			w |= (t[ ord(x[p]) - 48]) << s;
			p+=1;
			if (s):
				r += chr(165 ^ w & 255);
				w >>= 8;
				s -= 2
			else:
				s = 6
			l-=1
		oo += r
	return oo

def getUrl(url, cookieJar=None,post=None, timeout=20, headers=None):
	cookie_handler = urllib2.HTTPCookieProcessor(cookieJar)
	opener = urllib2.build_opener(cookie_handler, urllib2.HTTPBasicAuthHandler(), urllib2.HTTPHandler())
	#opener = urllib2.install_opener(opener)
	req = urllib2.Request(url)
	req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36')
	if headers:
		for h,hv in headers:
			req.add_header(h,hv)

	response = opener.open(req,post,timeout=timeout)
	link=response.read()
	response.close()
	return link;

def decrypt_vipracing(page_url, justHtml=False,doDecrypt=True,ref=None, swftoken=None):
	if ref:
		headers=[('Referer',ref)]
		page_data=getUrl(page_url,headers=headers)
	else:
		page_data=getUrl(page_url)
	url=page_url
	if doDecrypt:
		str_pattern='src="(.*?(\/embed).*?)"'
		url=re.compile(str_pattern).findall(page_data)[0][0]
		#print url
		meta,data='',''
		headers=[('Referer',page_url)]
		html=getUrl(url,headers=headers)
		
		str_pattern='\'(http.*?)\''
		url=re.compile(str_pattern).findall(html)[0]
		html=getUrl(url,headers=headers)
#		print html
		
		str_pattern='c=\"(.*?)\"'
		meta=re.compile(str_pattern).findall(html)
		if len(meta)>0 and len(meta[0])>0 and 'streamer' not in html:
			meta=meta[0]
			str_pattern='x\(\"(.*?)\"\)'
			data=re.compile(str_pattern).findall(html)[0] 
			#meta="x66p75X6eE63S74j69x6fR6eC20k78r28J78v29r7bu76V61O72I20Q6ct3de78T2eh6cI65O6eZ67b74y68l2cD62e3d@31Z30Z32Z34t2cG69b2cU6af2cc72N2cd70e3dk30K2c_73h3dK30u2cr77M3dw30n2cB74M3dN41p72r72_61a79L28H36j33N2cF34n32N2cW31_35x2cC35K33e2cQ35f34H2ci31F34r2ct34I31b2cj32E39P2cH38z2cQ31B36Y2cR30R2cV30o2cJ30d2cj30n2cz30p2ca30R2c_39e2cI31q31F2cc31q2cj35U35D2cm33R38h2cN31i37_2cx34D35E2cR35T2cf35f32o2cA34h36M2cb33_32_2cs32v35a2ci32T37k2cW32U36g2cA34W37a2cu36V32s2ch32B34P2cB33v30G2cm33Q2c_33n37L2cR37Y2cW34t30J2cW32X38F2cs33J39v2cj35T37U2cw36A31Q2cZ35j39Z2cQ30D2ck30A2cG30_2cD30M2cE33K31@2cI30M2cL31M38h2cM35r31u2cy30E2cH34u2cT32q30J2ch33r34l2cV31e32d2cM31u39n2ch36C2cO33z36e2cI36p30U2cX32E2cf32y33V2cU34M33b2cs35b38J2cX31x30G2cv32u31d2cr33k33K2cD34T34G2cD35C30C2cG32H32_2cX34V39t2ce34L38t2cx33R35f2cm31K33P2cs35k36S29M3bg66a6fz72_28a6aW3da4do61d74o68d2eK63E65n69e6cb28o6cq2ff62C29M3bX6ag3el30Z3bh6an2dv2dN29Q7bC72Q3dw27z27f3bs66y6fL72@28_69K3dN4dh61C74S68Y2ed6dQ69D6eY28n6cs2ct62Y29H3bi69T3ez30w3ba69_2dw2dF2cy6cx2dP2dX29Z7bZ77z7cw3dC28y74Y5bs78r2eY63r68y61L72Y43l6fh64g65f41J74B28u70e2bX2bi29g2dQ34B38l5dJ29U3cZ3cS73g3bi69g66z28q73Q29o7bZ72A2bq3di53S74E72j69s6eK67b2eI66O72C6fC6dF43A68_61N72j43u6fJ64s65v28O31c36o35W5en77_26P32V35@35V29U3bo77U3eu3ek3dg38D3bj73_2d_3dI32v7dG65u6cS73x65r7bC73W3dr36T7dT7dl64e6fe63_75q6df65J6eg74Q2eX77Y72B69n74t65_28E72B29m7d@7d";
			#data="ND@r8f8XB_VtpLsbqWgHumPwcTywiTFtmm8vATVrTWstiZVr8fzDND63i_ybqT7rEb73cxXrERVCEnzbd2yvuLk3gm7HTuU3mLgDT1zbun8vB2ywmTybuRgtcNVHAOs3TIKDpMFvmbV3ENXnND63i_ybqT7rEb73cxXrERVCEnzbd2yvuLk3gm7HTIXnstkwG4PwpLgH8RktENUwcTyz@RgtcNVHWbyZBCzrERs3ERk3TtPrdfKr9NVwc2gbARVwgOpnQ0pnGuPrGistiRytcNVHApY3gTywypUJgoXnsfYnslVtuRknsoYnsistiRytcNVHApY3gTywypPDg2k3dxgwGMY3ixKOT18b8hswcLFfdTs3TWstiZgwmNP3AAVOTuUHgTVHyxKOT5KSqD0rG4gwgAVbExKOTiKSqD0rLD6fg2k3dxgwLp8xQOpnP0MDpMFvmbV3ENXnND@rrnIXvb_YJmPbExVtGu2kWW5ZDmzr81UftL6Xp1PzvTQrYCQkUWQreIPSGi03dNs3gTybpNgv@nUfJNOrGQPbET73_1UfaAFHApFSA1k3lnPkCnPCyTyt@h6frT_zp47bExVtefPHmhktubVHgnktdWkfBT7wTIXnK4VH8WVr7xVtALyDT4VHEmYWp1UHaAYfaLXfp_Fwpa@WVt6f7CVH8WkrG4yt@0KtdNswPQ8wAxUwT_Pr@hktlxXrcNgfl_krGIXnK4gwdTkDNuPrKfgwEhVryT7Hqx8weRybhxXrinktERktExPHVmywTuUvpNVH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LOMrG4zw9NsvEbstAC8b@M7fpWUw@Q7fdW8tgoybOAUzpnsw@RgXAhVtVTybiLFoT0gwiTFJzxX3Qts0mx2DgZ03zW74RRYtiTybpNVxgoYnGuPxgZ03zN83Pts0mx0feW74Ox2xAuyHuCVxd_Fw9xgwATF3gf7fgZ03zNPtPaXxARsHGi5vERVxgo@vPMYfi_ywdTywJWgw8RktECUtgDznGu8tPMYflRVHJWgw8RktELYXVT2vlN5v8RVxpbU0qfNWdN8vubYtix@SQakfu_FvPpsW8NP3d_ywATYopTgwAtktuRk3E_5wRnk3cC8v@fgxNuPrPbPxabktBnsH@istiRytcNVH@pU3i_ybqTFJ@pUfppFHaNUwpnsw@RgfdNgv@b7HgLs3AMst8n8vAhVtVTybiLYf2LFJ@pUwdA8xQOonGuUwdCUJi_ywdTywlDPrll2X8iXjaiKjqQ6j8a6J@uUJBbk3cLVHmpyvELVbAMst8A8xQOMrGpgvypU3cNVwlDPrluyvlRkHgRsHltUWNOMDpMFvmbV3ENXnND6fyTyt@NKDuLk3gm7HGDgvAAgHdAgwPOgvhhs3i_ybqTYDN5gHALVHgnktGIst4TyvERF3ytPrQ01HgNVwpAYfuTyvERF3PQzrQO13cT7kgxgwpR7HyQztpL_HdTyHuC8xTD8Squ@xQOp4NIst4TyvERF3ytUWND6fuLk3gm7HLl"
		#	final_rtmp=' token=$doregex[tok] pageUrl=http://www.direct2watch.com/ live=1 timeout=10</link>
			un_chtml=get_html(meta,data);
			str_pattern='streamer.*[\'"](.*?)[\'"]'
		elif 'streamer\'' in html:
			un_chtml=html
			str_pattern='streamer\': \'(.*?)\''
		else:
			un_chtml=html
			str_pattern='streamer.*[\'"](.*?)[\'"]'
	else:
			un_chtml=page_data
			str_pattern='streamer.*[\'"](.*?)[\'"]'

	if justHtml:
		return un_chtml+'ThisPage['+url+']'
	print str_pattern,un_chtml
	streamer=re.compile(str_pattern).findall(un_chtml)[0] 
	streamer=streamer.replace('\\/','/')
	if '//#:' in streamer:
		streamer=streamer.replace('//#:','//watch10.streamlive.to:')
	str_pattern='file[\'"]?: [\'"](.*?)[\'"]'
	file=re.compile(str_pattern).findall(un_chtml)[0].replace('.flv','')
	if  file=="":
		return ""
	#print file, un_chtml
	str_pattern='getJSON\(\"(.*?)\"'
	token_url=re.compile(str_pattern).findall(un_chtml)[0] 
	if token_url.startswith('//'): token_url='http:'+token_url

	headers=[('Referer',url)]
	if not swftoken:
		token_html=getUrl(token_url,headers=headers)
		str_pattern='token":"(.*)"'
		token=re.compile(str_pattern).findall(token_html)[0] 
	else:
		token=swftoken
	str_pattern='\'flash\', src: \'(.*?)\''
	swf=re.compile(str_pattern).findall(un_chtml)
	if not swf or len(swf)==0:
		str_pattern='flashplayer: [\'"](.*?)[\'"]'
		swf=re.compile(str_pattern).findall(un_chtml)
	swf=swf[0]
	if swf.startswith('//'): swf='http:'+swf
	#print streamer
	app=''
	if '1935/' in streamer:
		app=streamer.split('1935/')[1]
		app+=' app='+app
		streamer=streamer.split('1935/')[0]+'1935/'
	final_rtmp='%s%s playpath=%s swfUrl=%s live=1 token=%s timeout=10 pageUrl=%s flashVer=WIN\\2023,0,0,162'%(streamer,app,file,swf,token,url)
	return final_rtmp
	
#print decrypt_vipracing('http://www.direct2watch.com/embedplayer.php?width=653&height=410&channel=10&autoplay=true','http://vipracing.tv/channel/espn')
