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