#NEWLINE# def _real_extract( self , url ) : #NEWLINE# #INDENT# webpage = self . _download_webpage ( url , url ) #NEWLINE# video_id = self . _html_search_regex ( 'videoID: "(\\d+?)"' , webpage , 'video_id' ) #NEWLINE# api_token = self . _html_search_regex ( 'apiToken: "([a-zA-Z0-9-_\\.]+?)"' , webpage , 'api_token' ) #NEWLINE# title = self . _html_search_regex ( '<meta property="og:title" content="\\s*(.*?)\\s*"\\s*/?\\s*>' , webpage , 'title' ) #NEWLINE# json = self . _download_json ( ( 'https://api.brightcove.com/services/library?command=find_video_by_id&video_id=%s&token=%s&video_fields=%s' % ( video_id , api_token , ',' . join ( self . _video_fields ) ) ) , title ) #NEWLINE# formats = [ ] #NEWLINE# for rendition in json [ 'renditions' ] : #NEWLINE# #INDENT# url = ( rendition [ 'remoteUrl' ] or rendition [ 'url' ] ) #NEWLINE# protocol = ( 'rtmp' if url . startswith ( 'rtmp' ) else 'http' ) #NEWLINE# ext = ( 'flv' if ( protocol == 'rtmp' ) else rendition [ 'videoContainer' ] . lower ( ) ) #NEWLINE# if ( protocol == 'rtmp' ) : #NEWLINE# #INDENT# url = url . replace ( '&mp4:' , '' ) #NEWLINE# #UNINDENT# formats . append ( { #NEWLINE# #INDENT# 'format_id' : '_' . join ( [ 'rtmp' , rendition [ 'videoContainer' ] . lower ( ) , rendition [ 'videoCodec' ] . lower ( ) ] ) , #NEWLINE# 'width' : rendition [ 'frameWidth' ] , #NEWLINE# 'height' : rendition [ 'frameHeight' ] , #NEWLINE# 'tbr' : ( rendition [ 'encodingRate' ] / 1024 ) , #NEWLINE# 'filesize' : rendition [ 'size' ] , #NEWLINE# 'protocol' : protocol , #NEWLINE# 'ext' : ext , #NEWLINE# 'vcodec' : rendition [ 'videoCodec' ] . lower ( ) , #NEWLINE# 'container' : rendition [ 'videoContainer' ] . lower ( ) , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'id' : video_id , #NEWLINE# 'display_id' : json [ 'referenceId' ] , #NEWLINE# 'title' : json [ 'name' ] , #NEWLINE# 'description' : ( json [ 'shortDescription' ] or json [ 'longDescription' ] ) , #NEWLINE# 'formats' : formats , #NEWLINE# 'thumbnails' : [ { #NEWLINE# #INDENT# 'url' : json [ 'videoStillURL' ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'url' : json [ 'thumbnailURL' ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'thumbnail' : json [ 'videoStillURL' ] , #NEWLINE# 'duration' : ( json [ 'length' ] / 1000 ) , #NEWLINE# 'timestamp' : ( float ( json [ 'creationDate' ] ) / 1000 ) , #NEWLINE# 'uploader' : ( json [ 'customFields' ] [ 'production_company_distributor' ] if ( 'production_company_distributor' in json [ 'customFields' ] ) else 'TENplay' ) , #NEWLINE# 'view_count' : json [ 'playsTotal' ] , #NEWLINE# #UNINDENT# }