]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tenplay.py
02a31a60920c116449d28bc8748f952d95e5443c
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class TenPlayIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?ten(play)?\.com\.au/.+'
14 'url': 'http://tenplay.com.au/ten-insider/extra/season-2013/tenplay-tv-your-way',
16 'id': '2695695426001',
18 'title': 'TENplay: TV your way',
19 'description': 'Welcome to a new TV experience. Enjoy a taste of the TENplay benefits.',
20 'timestamp': 1380150606.889,
21 'upload_date': '20130925',
22 'uploader': 'TENplay',
25 'skip_download': True, # Requires rtmpdump
30 'id', 'name', 'shortDescription', 'longDescription', 'creationDate',
31 'publishedDate', 'lastModifiedDate', 'customFields', 'videoStillURL',
32 'thumbnailURL', 'referenceId', 'length', 'playsTotal',
33 'playsTrailingWeek', 'renditions', 'captioning', 'startDate', 'endDate']
35 def _real_extract(self
, url
):
36 webpage
= self
._download
_webpage
(url
, url
)
37 video_id
= self
._html
_search
_regex
(
38 r
'videoID: "(\d+?)"', webpage
, 'video_id')
39 api_token
= self
._html
_search
_regex
(
40 r
'apiToken: "([a-zA-Z0-9-_\.]+?)"', webpage
, 'api_token')
41 title
= self
._html
_search
_regex
(
42 r
'<meta property="og:title" content="\s*(.*?)\s*"\s*/?\s*>',
45 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
)
48 for rendition
in json
['renditions']:
49 url
= rendition
['remoteUrl'] or rendition
['url']
50 protocol
= 'rtmp' if url
.startswith('rtmp') else 'http'
51 ext
= 'flv' if protocol
== 'rtmp' else rendition
['videoContainer'].lower()
53 if protocol
== 'rtmp':
54 url
= url
.replace('&mp4:', '')
56 tbr
= int_or_none(rendition
.get('encodingRate'), 1000)
59 'format_id': '_'.join(
60 ['rtmp', rendition
['videoContainer'].lower(),
61 rendition
['videoCodec'].lower(), '%sk' % tbr
]),
62 'width': int_or_none(rendition
['frameWidth']),
63 'height': int_or_none(rendition
['frameHeight']),
65 'filesize': int_or_none(rendition
['size']),
68 'vcodec': rendition
['videoCodec'].lower(),
69 'container': rendition
['videoContainer'].lower(),
72 self
._sort
_formats
(formats
)
76 'display_id': json
['referenceId'],
77 'title': json
['name'],
78 'description': json
['shortDescription'] or json
['longDescription'],
81 'url': json
['videoStillURL']
83 'url': json
['thumbnailURL']
85 'thumbnail': json
['videoStillURL'],
86 'duration': float_or_none(json
.get('length'), 1000),
87 'timestamp': float_or_none(json
.get('creationDate'), 1000),
88 'uploader': json
.get('customFields', {}).get('production_company_distributor') or 'TENplay',
89 'view_count': int_or_none(json
.get('playsTotal')),