#NEWLINE# def _real_extract( self , url ) : #NEWLINE# #INDENT# mobj = re . match ( self . _VALID_URL , url ) #NEWLINE# ( video_id , host ) = ( mobj . group ( 'id' ) , mobj . group ( 'host' ) ) #NEWLINE# webpage = self . _download_webpage ( url , video_id ) #NEWLINE# config_url = NFLIE . prepend_host ( host , self . _search_regex ( '(?:config|configURL)\\s*:\\s*"([^"]+)"' , webpage , 'config URL' ) ) #NEWLINE# config = self . _download_json ( config_url , video_id , note = 'Downloading player config' ) #NEWLINE# url_template = NFLIE . prepend_host ( host , '{contentURLTemplate:}' . format ( ** config ) ) #NEWLINE# video_data = self . _download_json ( url_template . format ( id = video_id ) , video_id ) #NEWLINE# formats = [ ] #NEWLINE# cdn_data = video_data . get ( 'cdnData' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# streams = cdn_data . get ( 'bitrateInfo' , [ ] ) #NEWLINE# if ( cdn_data . get ( 'format' ) == 'EXTERNAL_HTTP_STREAM' ) : #NEWLINE# #INDENT# parts = compat_urllib_parse_urlparse ( cdn_data . get ( 'uri' ) ) #NEWLINE# ( protocol , host ) = ( parts . scheme , parts . netloc ) #NEWLINE# for stream in streams : #NEWLINE# #INDENT# formats . append ( NFLIE . format_from_stream ( stream , protocol , host ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# cdns = config . get ( 'cdns' ) #NEWLINE# if ( not cdns ) : #NEWLINE# #INDENT# raise ExtractorError ( 'Failed to get CDN data' , expected = True ) #NEWLINE# #UNINDENT# for ( name , cdn ) in cdns . items ( ) : #NEWLINE# #INDENT# if ( cdn . get ( 'name' ) == 'LIMELIGHT' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# protocol = cdn . get ( 'protocol' ) #NEWLINE# host = remove_end ( cdn . get ( 'host' , '' ) , '/' ) #NEWLINE# if ( not ( protocol and host ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# prefix = cdn . get ( 'pathprefix' , '' ) #NEWLINE# if ( prefix and ( not prefix . endswith ( '/' ) ) ) : #NEWLINE# #INDENT# prefix = ( '%s/' % prefix ) #NEWLINE# #UNINDENT# preference = 0 #NEWLINE# if ( mobj == 'rtmp' ) : #NEWLINE# #INDENT# preference = ( - 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'prog' in name . lower ( ) ) : #NEWLINE# #INDENT# preference = 1 #NEWLINE# #UNINDENT# #UNINDENT# for stream in streams : #NEWLINE# #INDENT# formats . append ( NFLIE . format_from_stream ( stream , protocol , host , prefix , preference , name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _sort_formats ( formats ) #NEWLINE# thumbnail = None #NEWLINE# for q in ( 'xl' , 'l' , 'm' , 's' , 'xs' ) : #NEWLINE# #INDENT# thumbnail = video_data . get ( 'imagePaths' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( q ) #NEWLINE# if thumbnail : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# 'id' : video_id , #NEWLINE# 'title' : video_data . get ( 'headline' ) , #NEWLINE# 'formats' : formats , #NEWLINE# 'description' : video_data . get ( 'caption' ) , #NEWLINE# 'duration' : video_data . get ( 'duration' ) , #NEWLINE# 'thumbnail' : thumbnail , #NEWLINE# 'timestamp' : int_or_none ( video_data . get ( 'posted' ) , 1000 ) , #NEWLINE# #UNINDENT# }