#NEWLINE# def _real_extract( self , url ) : #NEWLINE# #INDENT# mobj = re . match ( self . _VALID_URL , url ) #NEWLINE# show_path = mobj . group ( 'show_path' ) #NEWLINE# episode_path = mobj . group ( 'episode_path' ) #NEWLINE# is_playlist = ( True if mobj . group ( 'is_playlist' ) else False ) #NEWLINE# webpage = self . _download_webpage ( url , episode_path ) #NEWLINE# bootstrappedDataJS = self . _search_regex ( 'var bootstrappedData = ({.*});' , webpage , episode_path ) #NEWLINE# try : #NEWLINE# #INDENT# bootstrappedData = json . loads ( bootstrappedDataJS ) #NEWLINE# #UNINDENT# except ValueError as ve : #NEWLINE# #INDENT# errmsg = ( '%s: Failed to parse JSON ' % episode_path ) #NEWLINE# raise ExtractorError ( errmsg , cause = ve ) #NEWLINE# #UNINDENT# if is_playlist : #NEWLINE# #INDENT# collections = bootstrappedData [ 'playlists' ] [ 'collections' ] #NEWLINE# collection = self . find_collection_by_linkURL ( collections , show_path ) #NEWLINE# video_info = self . find_video_info ( collection , episode_path ) #NEWLINE# show_title = video_info [ 'showTitle' ] #NEWLINE# segment_ids = [ video_info [ 'videoPlaybackID' ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# collections = bootstrappedData [ 'show' ] [ 'collections' ] #NEWLINE# ( collection , video_info ) = self . find_collection_containing_video ( collections , episode_path ) #NEWLINE# show = bootstrappedData [ 'show' ] #NEWLINE# show_title = show [ 'title' ] #NEWLINE# segment_ids = [ clip [ 'videoPlaybackID' ] for clip in video_info [ 'clips' ] ] #NEWLINE# #UNINDENT# episode_id = video_info [ 'id' ] #NEWLINE# episode_title = video_info [ 'title' ] #NEWLINE# episode_description = video_info [ 'description' ] #NEWLINE# episode_duration = video_info . get ( 'duration' ) #NEWLINE# entries = [ ] #NEWLINE# for ( part_num , segment_id ) in enumerate ( segment_ids ) : #NEWLINE# #INDENT# segment_url = ( 'http://www.adultswim.com/videos/api/v0/assets?id=%s&platform=mobile' % segment_id ) #NEWLINE# segment_title = ( '%s - %s' % ( show_title , episode_title ) ) #NEWLINE# if ( len ( segment_ids ) > 1 ) : #NEWLINE# #INDENT# segment_title += ( ' Part %d' % ( part_num + 1 ) ) #NEWLINE# #UNINDENT# idoc = self . _download_xml ( segment_url , segment_title , 'Downloading segment information' , 'Unable to download segment information' ) #NEWLINE# segment_duration = float_or_none ( xpath_text ( idoc , './/trt' , 'segment duration' ) . strip ( ) ) #NEWLINE# formats = [ ] #NEWLINE# file_els = idoc . findall ( './/files/file' ) #NEWLINE# for file_el in file_els : #NEWLINE# #INDENT# bitrate = file_el . attrib . get ( 'bitrate' ) #NEWLINE# ftype = file_el . attrib . get ( 'type' ) #NEWLINE# formats . append ( { #NEWLINE# #INDENT# 'format_id' : ( '%s_%s' % ( bitrate , ftype ) ) , #NEWLINE# 'url' : file_el . text . strip ( ) , #NEWLINE# 'tbr' : ( int ( bitrate ) if bitrate . isdigit ( ) else None ) , #NEWLINE# 'quality' : ( 1 if ( ftype == 'hd' ) else ( - 1 ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# self . _sort_formats ( formats ) #NEWLINE# entries . append ( { #NEWLINE# #INDENT# 'id' : segment_id , #NEWLINE# 'title' : segment_title , #NEWLINE# 'formats' : formats , #NEWLINE# 'duration' : segment_duration , #NEWLINE# 'description' : episode_description , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# '_type' : 'playlist' , #NEWLINE# 'id' : episode_id , #NEWLINE# 'display_id' : episode_title , #NEWLINE# 'entries' : entries , #NEWLINE# 'title' : ( '%s - %s' % ( show_title , episode_title ) ) , #NEWLINE# 'description' : episode_description , #NEWLINE# 'duration' : episode_duration , #NEWLINE# #UNINDENT# }