1 from .common
import InfoExtractor
11 class STVPlayerIE(InfoExtractor
):
12 IE_NAME
= 'stv:player'
13 _VALID_URL
= r
'https?://player\.stv\.tv/(?P<type>episode|video)/(?P<id>[a-z0-9]{4})'
16 'url': 'https://player.stv.tv/video/4gwd/emmerdale/60-seconds-on-set-with-laura-norton/',
17 'md5': '5adf9439c31d554f8be0707c7abe7e0a',
19 'id': '5333973339001',
21 'upload_date': '20170301',
22 'title': '60 seconds on set with Laura Norton',
23 'description': "How many questions can Laura - a.k.a Kerry Wyatt - answer in 60 seconds? Let's find out!",
24 'timestamp': 1488388054,
25 'uploader_id': '1486976045',
27 'skip': 'this resource is unavailable outside of the UK',
30 'url': 'https://player.stv.tv/episode/4125/jennifer-saunders-memory-lane',
31 'only_matching': True,
33 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/1486976045/default_default/index.html?videoId=%s'
35 'episode': 'episodes',
39 def _real_extract(self
, url
):
40 ptype
, video_id
= self
._match
_valid
_url
(url
).groups()
42 webpage
= self
._download
_webpage
(url
, video_id
, fatal
=False) or ''
43 props
= self
._search
_nextjs
_data
(webpage
, video_id
, default
={}).get('props') or {}
44 player_api_cache
= try_get(
45 props
, lambda x
: x
['initialReduxState']['playerApiCache']) or {}
47 api_path
, resp
= None, {}
48 for k
, v
in player_api_cache
.items():
49 if k
.startswith(('/episodes/', '/shortform/')):
53 episode_id
= str_or_none(try_get(
54 props
, lambda x
: x
['pageProps']['episodeId']))
55 api_path
= f
'/{self._PTYPE_MAP[ptype]}/{episode_id or video_id}'
57 result
= resp
.get('results')
59 resp
= self
._download
_json
(
60 'https://player.api.stv.tv/v1' + api_path
, video_id
)
61 result
= resp
['results']
63 video
= result
['video']
64 video_id
= str(video
['id'])
67 _subtitles
= result
.get('_subtitles') or {}
68 for ext
, sub_url
in _subtitles
.items():
69 subtitles
.setdefault('en', []).append({
70 'ext': 'vtt' if ext
== 'webvtt' else ext
,
74 programme
= result
.get('programme') or {}
75 if programme
.get('drmEnabled'):
76 self
.report_drm(video_id
)
79 '_type': 'url_transparent',
81 'url': smuggle_url(self
.BRIGHTCOVE_URL_TEMPLATE
% video_id
, {'geo_countries': ['GB']}),
82 'description': result
.get('summary'),
83 'duration': float_or_none(video
.get('length'), 1000),
84 'subtitles': subtitles
,
85 'view_count': int_or_none(result
.get('views')),
86 'series': programme
.get('name') or programme
.get('shortName'),
87 'ie_key': 'BrightcoveNew',