]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/stv.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
16 class STVPlayerIE(InfoExtractor
):
17 IE_NAME
= 'stv:player'
18 _VALID_URL
= r
'https?://player\.stv\.tv/(?P<type>episode|video)/(?P<id>[a-z0-9]{4})'
21 'url': 'https://player.stv.tv/video/4gwd/emmerdale/60-seconds-on-set-with-laura-norton/',
22 'md5': '5adf9439c31d554f8be0707c7abe7e0a',
24 'id': '5333973339001',
26 'upload_date': '20170301',
27 'title': '60 seconds on set with Laura Norton',
28 'description': "How many questions can Laura - a.k.a Kerry Wyatt - answer in 60 seconds? Let\'s find out!",
29 'timestamp': 1488388054,
30 'uploader_id': '1486976045',
32 'skip': 'this resource is unavailable outside of the UK',
35 'url': 'https://player.stv.tv/episode/4125/jennifer-saunders-memory-lane',
36 'only_matching': True,
38 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/1486976045/default_default/index.html?videoId=%s'
40 'episode': 'episodes',
44 def _real_extract(self
, url
):
45 ptype
, video_id
= self
._match
_valid
_url
(url
).groups()
47 webpage
= self
._download
_webpage
(url
, video_id
, fatal
=False) or ''
48 props
= self
._search
_nextjs
_data
(webpage
, video_id
, default
='{}').get('props') or {}
49 player_api_cache = try_get(
50 props, lambda x: x['initialReduxState
']['playerApiCache
']) or {}
52 api_path, resp = None, {}
53 for k, v in player_api_cache.items():
54 if k.startswith('/episodes
/') or k.startswith('/shortform
/'):
58 episode_id = str_or_none(try_get(
59 props, lambda x: x['pageProps
']['episodeId
']))
60 api_path = '/%s/%s' % (self._PTYPE_MAP[ptype], episode_id or video_id)
62 result = resp.get('results
')
64 resp = self._download_json(
65 'https
://player
.api
.stv
.tv
/v1
' + api_path, video_id)
66 result = resp['results
']
68 video = result['video
']
69 video_id = compat_str(video['id'])
72 _subtitles = result.get('_subtitles
') or {}
73 for ext, sub_url in _subtitles.items():
74 subtitles.setdefault('en
', []).append({
75 'ext
': 'vtt
' if ext == 'webvtt
' else ext,
79 programme = result.get('programme
') or {}
82 '_type
': 'url_transparent
',
84 'url
': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['GB']}),
85 'description
': result.get('summary
'),
86 'duration
': float_or_none(video.get('length
'), 1000),
87 'subtitles
': subtitles,
88 'view_count
': int_or_none(result.get('views
')),
89 'series
': programme.get('name
') or programme.get('shortName
'),
90 'ie_key
': 'BrightcoveNew
',