]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/stv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class STVPlayerIE(InfoExtractor
):
15 IE_NAME
= 'stv:player'
16 _VALID_URL
= r
'https?://player\.stv\.tv/(?P<type>episode|video)/(?P<id>[a-z0-9]{4})'
18 'url': 'https://player.stv.tv/video/4gwd/emmerdale/60-seconds-on-set-with-laura-norton/',
19 'md5': '5adf9439c31d554f8be0707c7abe7e0a',
21 'id': '5333973339001',
23 'upload_date': '20170301',
24 'title': '60 seconds on set with Laura Norton',
25 'description': "How many questions can Laura - a.k.a Kerry Wyatt - answer in 60 seconds? Let\'s find out!",
26 'timestamp': 1488388054,
27 'uploader_id': '1486976045',
29 'skip': 'this resource is unavailable outside of the UK',
31 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/1486976045/default_default/index.html?videoId=%s'
33 'episode': 'episodes',
37 def _real_extract(self
, url
):
38 ptype
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
39 resp
= self
._download
_json
(
40 'https://player.api.stv.tv/v1/%s/%s' % (self
._PTYPE
_MAP
[ptype
], video_id
),
43 result
= resp
['results']
44 video
= result
['video']
45 video_id
= compat_str(video
['id'])
48 _subtitles
= result
.get('_subtitles') or {}
49 for ext
, sub_url
in _subtitles
.items():
50 subtitles
.setdefault('en', []).append({
51 'ext': 'vtt' if ext
== 'webvtt' else ext
,
55 programme
= result
.get('programme') or {}
58 '_type': 'url_transparent',
60 'url': self
.BRIGHTCOVE_URL_TEMPLATE
% video_id
,
61 'description': result
.get('summary'),
62 'duration': float_or_none(video
.get('length'), 1000),
63 'subtitles': subtitles
,
64 'view_count': int_or_none(result
.get('views')),
65 'series': programme
.get('name') or programme
.get('shortName'),
66 'ie_key': 'BrightcoveNew',