2 from __future__ import unicode_literals
6 from .common import InfoExtractor
8 class TenPlayIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?ten(play)?\.com\.au/.+'
11 'url': 'http://tenplay.com.au/ten-insider/extra/season-2013/tenplay-tv-your-way',
12 'md5': 'c9dda6aac8f814352ad2aee8899b1612',
14 'id': '2695695426001',
16 'title': 'TENplay: TV your way',
17 'description': 'Welcome to a new TV experience. Enjoy a taste of the TENplay benefits.',
18 'timestamp': 1380150606.889,
19 'upload_date': '20130925',
24 _video_fields = ["id","name","shortDescription","longDescription","creationDate","publishedDate","lastModifiedDate","customFields","videoStillURL","thumbnailURL","referenceId","length","playsTotal","playsTrailingWeek","renditions","captioning","startDate","endDate"]
26 def _real_extract(self, url):
27 webpage = self._download_webpage(url, url)
28 video_id = self._html_search_regex(r'videoID: "(\d+?)"', webpage, 'video_id')
29 api_token = self._html_search_regex(r'apiToken: "([a-zA-Z0-9-_\.]+?)"', webpage, 'api_token')
30 title = self._html_search_regex(r'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>', webpage, 'title')
32 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)
35 for rendition in json['renditions']:
36 url = rendition['remoteUrl'] or rendition['url']
37 protocol = 'rtmp' if url.startswith('rtmp') else 'http'
38 ext = 'flv' if protocol == 'rtmp' else rendition['videoContainer'].lower()
40 if protocol == 'rtmp':
41 url = url.replace('&mp4:', '')
44 'format_id': '_'.join(['rtmp', rendition['videoContainer'].lower(), rendition['videoCodec'].lower()]),
45 'width': rendition['frameWidth'],
46 'height': rendition['frameHeight'],
47 'tbr': rendition['encodingRate'] / 1024,
48 'filesize': rendition['size'],
51 'vcodec': rendition['videoCodec'].lower(),
52 'container': rendition['videoContainer'].lower(),
58 'display_id': json['referenceId'],
59 'title': json['name'],
60 'description': json['shortDescription'] or json['longDescription'],
63 'url': json['videoStillURL']
65 'url': json['thumbnailURL']
67 'thumbnail': json['videoStillURL'],
68 'duration': json['length'] / 1000,
69 'timestamp': float(json['creationDate']) / 1000,
70 'uploader': json['customFields']['production_company_distributor'] if 'production_company_distributor' in json['customFields'] else 'TENplay',
71 'view_count': json['playsTotal']