]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tenplay.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   7 class TenPlayIE(InfoExtractor
): 
   8     _VALID_URL 
= r
'https?://(?:www\.)?ten(play)?\.com\.au/.+' 
  10         'url': 'http://tenplay.com.au/ten-insider/extra/season-2013/tenplay-tv-your-way', 
  12             'id': '2695695426001', 
  14             'title': 'TENplay: TV your way', 
  15             'description': 'Welcome to a new TV experience. Enjoy a taste of the TENplay benefits.', 
  16             'timestamp': 1380150606.889, 
  17             'upload_date': '20130925', 
  18             'uploader': 'TENplay', 
  21             'skip_download': True,  # Requires rtmpdump 
  26         "id", "name", "shortDescription", "longDescription", "creationDate", 
  27         "publishedDate", "lastModifiedDate", "customFields", "videoStillURL", 
  28         "thumbnailURL", "referenceId", "length", "playsTotal", 
  29         "playsTrailingWeek", "renditions", "captioning", "startDate", "endDate"] 
  31     def _real_extract(self
, url
): 
  32         webpage 
= self
._download
_webpage
(url
, url
) 
  33         video_id 
= self
._html
_search
_regex
( 
  34             r
'videoID: "(\d+?)"', webpage
, 'video_id') 
  35         api_token 
= self
._html
_search
_regex
( 
  36             r
'apiToken: "([a-zA-Z0-9-_\.]+?)"', webpage
, 'api_token') 
  37         title 
= self
._html
_search
_regex
( 
  38             r
'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>', 
  41         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
) 
  44         for rendition 
in json
['renditions']: 
  45             url 
= rendition
['remoteUrl'] or rendition
['url'] 
  46             protocol 
= 'rtmp' if url
.startswith('rtmp') else 'http' 
  47             ext 
= 'flv' if protocol 
== 'rtmp' else rendition
['videoContainer'].lower() 
  49             if protocol 
== 'rtmp': 
  50                 url 
= url
.replace('&mp4:', '') 
  53                 'format_id': '_'.join(['rtmp', rendition
['videoContainer'].lower(), rendition
['videoCodec'].lower()]), 
  54                 'width': rendition
['frameWidth'], 
  55                 'height': rendition
['frameHeight'], 
  56                 'tbr': rendition
['encodingRate'] / 1024, 
  57                 'filesize': rendition
['size'], 
  60                 'vcodec': rendition
['videoCodec'].lower(), 
  61                 'container': rendition
['videoContainer'].lower(), 
  67             'display_id': json
['referenceId'], 
  68             'title': json
['name'], 
  69             'description': json
['shortDescription'] or json
['longDescription'], 
  72                 'url': json
['videoStillURL'] 
  74                 'url': json
['thumbnailURL'] 
  76             'thumbnail': json
['videoStillURL'], 
  77             'duration': json
['length'] / 1000, 
  78             'timestamp': float(json
['creationDate']) / 1000, 
  79             'uploader': json
['customFields']['production_company_distributor'] if 'production_company_distributor' in json
['customFields'] else 'TENplay', 
  80             'view_count': json
['playsTotal']