#NEWLINE# def _real_extract( self , url ) : #NEWLINE# #INDENT# mobj = re . match ( self . _VALID_URL , url ) #NEWLINE# video_id = mobj . group ( 'videoid' ) #NEWLINE# url = ( ( mobj . group ( 'proto' ) + 'www.' ) + mobj . group ( 'url' ) ) #NEWLINE# req = compat_urllib_request . Request ( url ) #NEWLINE# req . add_header ( 'Cookie' , 'age_verified=1' ) #NEWLINE# webpage = self . _download_webpage ( req , video_id ) #NEWLINE# age_limit = self . _rta_search ( webpage ) #NEWLINE# json_params = self . _search_regex ( 'var currentVideo = new Video\\((.*)\\)[,;]' , webpage , 'JSON parameters' ) #NEWLINE# try : #NEWLINE# #INDENT# params = json . loads ( json_params ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise ExtractorError ( 'Invalid JSON' ) #NEWLINE# #UNINDENT# self . report_extraction ( video_id ) #NEWLINE# try : #NEWLINE# #INDENT# video_title = params [ 'title' ] #NEWLINE# upload_date = unified_strdate ( params [ 'release_date_f' ] ) #NEWLINE# video_description = video_title [ 'description' ] #NEWLINE# video_uploader = params [ 'submitted_by' ] #NEWLINE# thumbnail = params [ 'thumbnails' ] [ 0 ] [ 'image' ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise ExtractorError ( ( 'Missing JSON parameter: ' + sys . exc_info ( ) [ 1 ] ) ) #NEWLINE# #UNINDENT# DOWNLOAD_LIST_RE = '(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>' #NEWLINE# download_list_html = self . _search_regex ( DOWNLOAD_LIST_RE , webpage , 'download list' ) . strip ( ) #NEWLINE# LINK_RE = '<a href="([^"]+)">' #NEWLINE# links = re . findall ( LINK_RE , download_list_html ) #NEWLINE# encrypted_links = re . findall ( "var encryptedQuality[0-9]{3}URL = \\'([a-zA-Z0-9+/]+={0,2})\\';" , webpage ) #NEWLINE# for encrypted_link in encrypted_links : #NEWLINE# #INDENT# link = aes_decrypt_text ( encrypted_link , video_title , 32 ) . decode ( 'utf-8' ) #NEWLINE# links . append ( link ) #NEWLINE# #UNINDENT# formats = [ ] #NEWLINE# for link in links : #NEWLINE# #INDENT# video_url = unescapeHTML ( link ) #NEWLINE# path = compat_urllib_parse_urlparse ( video_url ) . path #NEWLINE# format_parts = path . split ( '/' ) [ 4 ] . split ( '_' ) [ : 2 ] #NEWLINE# dn = compat_urllib_parse_urlparse ( video_url ) . netloc . partition ( '.' ) [ 0 ] #NEWLINE# resolution = format_parts [ 0 ] #NEWLINE# height = int ( resolution [ : ( - len ( 'p' ) ) ] ) #NEWLINE# bitrate = int ( format_parts [ 1 ] [ : ( - len ( 'k' ) ) ] ) #NEWLINE# format = ( ( '-' . join ( format_parts ) + '-' ) + dn ) #NEWLINE# formats . append ( { #NEWLINE# #INDENT# 'url' : video_url , #NEWLINE# 'format' : format , #NEWLINE# 'format_id' : format , #NEWLINE# 'height' : height , #NEWLINE# 'tbr' : bitrate , #NEWLINE# 'resolution' : resolution , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# self . _sort_formats ( formats ) #NEWLINE# if ( not formats ) : #NEWLINE# #INDENT# raise ExtractorError ( 'ERROR: no known formats available for video' ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'id' : video_id , #NEWLINE# 'uploader' : video_uploader , #NEWLINE# 'upload_date' : upload_date , #NEWLINE# 'title' : video_title , #NEWLINE# 'thumbnail' : thumbnail , #NEWLINE# 'description' : video_description , #NEWLINE# 'age_limit' : age_limit , #NEWLINE# 'formats' : formats , #NEWLINE# #UNINDENT# }