#NEWLINE# def resolve( url ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# referer = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ 'referer' ] [ 0 ] #NEWLINE# page = urlparse . parse_qs ( urlparse . urlparse ( url ) . query ) [ 'id' ] [ 0 ] #NEWLINE# page = ( 'http://p2pcast.tv/stream.php?id=%s&live=0&p2p=0&stretching=uniform' % page ) #NEWLINE# result = client . request ( page , referer = referer ) #NEWLINE# try : #NEWLINE# #INDENT# swf = re . compile ( 'src\\s*=[\'|"](.+?player.+?\\.js)[\'|"]' ) . findall ( result ) [ 0 ] #NEWLINE# swf = client . request ( swf ) #NEWLINE# swf = re . compile ( 'flashplayer\\s*:\\s*[\'|"](.+?)[\'|"]' ) . findall ( swf ) [ 0 ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# swf = 'http://cdn.p2pcast.tv/jwplayer.flash.swf' #NEWLINE# #UNINDENT# url = re . compile ( 'url\\s*=\\s*[\'|"](.+?)[\'|"]' ) . findall ( result ) [ 0 ] #NEWLINE# url = base64 . b64decode ( url ) #NEWLINE# url = ( '%s|User-Agent=%s&Referer=%s' % ( url , urllib . quote_plus ( client . agent ( ) ) , urllib . quote_plus ( swf ) ) ) #NEWLINE# return url #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return