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',
11 #'md5': 'd68703d9f73dc8fccf3320ab34202590',
13 'id': '2695695426001',
15 'title': 'TENplay: TV your way',
16 'description': 'Welcome to a new TV experience. Enjoy a taste of the TENplay benefits.',
17 'timestamp': 1380150606.889,
18 'upload_date': '20130925',
19 'uploader': 'TENplay',
22 'skip_download': True, # Requires rtmpdump
27 "id", "name", "shortDescription", "longDescription", "creationDate",
28 "publishedDate", "lastModifiedDate", "customFields", "videoStillURL",
29 "thumbnailURL", "referenceId", "length", "playsTotal",
30 "playsTrailingWeek", "renditions", "captioning", "startDate", "endDate"]
32 def _real_extract(self, url):
33 webpage = self._download_webpage(url, url)
34 video_id = self._html_search_regex(
35 r'videoID: "(\d+?)"', webpage, 'video_id')
36 api_token = self._html_search_regex(
37 r'apiToken: "([a-zA-Z0-9-_\.]+?)"', webpage, 'api_token')
38 title = self._html_search_regex(
39 r'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>',
42 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)
45 for rendition in json['renditions']:
46 url = rendition['remoteUrl'] or rendition['url']
47 protocol = 'rtmp' if url.startswith('rtmp') else 'http'
48 ext = 'flv' if protocol == 'rtmp' else rendition['videoContainer'].lower()
50 if protocol == 'rtmp':
51 url = url.replace('&mp4:', '')
54 'format_id': '_'.join(['rtmp', rendition['videoContainer'].lower(), rendition['videoCodec'].lower()]),
55 'width': rendition['frameWidth'],
56 'height': rendition['frameHeight'],
57 'tbr': rendition['encodingRate'] / 1024,
58 'filesize': rendition['size'],
61 'vcodec': rendition['videoCodec'].lower(),
62 'container': rendition['videoContainer'].lower(),
68 'display_id': json['referenceId'],
69 'title': json['name'],
70 'description': json['shortDescription'] or json['longDescription'],
73 'url': json['videoStillURL']
75 'url': json['thumbnailURL']
77 'thumbnail': json['videoStillURL'],
78 'duration': json['length'] / 1000,
79 'timestamp': float(json['creationDate']) / 1000,
80 'uploader': json['customFields']['production_company_distributor'] if 'production_company_distributor' in json['customFields'] else 'TENplay',
81 'view_count': json['playsTotal']