]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/urplay.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
7 class URPlayIE(InfoExtractor
):
8 _VALID_URL
= r
'https?://(?:www\.)?urplay\.se/program/(?P<id>[0-9]+)'
10 'url': 'http://urplay.se/program/190031-tripp-trapp-trad-sovkudde',
11 'md5': '15ca67b63fd8fb320ac2bcd854bad7b6',
15 'title': 'Tripp, Trapp, Träd : Sovkudde',
16 'description': 'md5:b86bffdae04a7e9379d1d7e5947df1d1',
20 def _real_extract(self
, url
):
21 video_id
= self
._match
_id
(url
)
23 webpage
= self
._download
_webpage
(url
, video_id
)
24 urplayer_data
= self
._parse
_json
(self
._search
_regex
(
25 r
'urPlayer\.init\(({.+?})\);', webpage
, 'urplayer data'), video_id
)
26 host
= self
._download
_json
('http://streaming-loadbalancer.ur.se/loadbalancer.json', video_id
)['redirect']
29 for quality_attr
, quality
, preference
in (('', 'sd', 0), ('_hd', 'hd', 1)):
30 file_rtmp
= urplayer_data
.get('file_rtmp' + quality_attr
)
33 'url': 'rtmp://%s/urplay/mp4:%s' % (host
, file_rtmp
),
34 'format_id': quality
+ '-rtmp',
36 'preference': preference
,
38 file_http
= urplayer_data
.get('file_http' + quality_attr
) or urplayer_data
.get('file_http_sub' + quality_attr
)
40 file_http_base_url
= 'http://%s/%s' % (host
, file_http
)
41 formats
.extend(self
._extract
_f
4m
_formats
(
42 file_http_base_url
+ 'manifest.f4m', video_id
,
43 preference
, '%s-hds' % quality
, fatal
=False))
44 formats
.extend(self
._extract
_m
3u8_formats
(
45 file_http_base_url
+ 'playlist.m3u8', video_id
, 'mp4',
46 'm3u8_native', preference
, '%s-hls' % quality
, fatal
=False))
47 self
._sort
_formats
(formats
)
50 for subtitle
in urplayer_data
.get('subtitles', []):
51 subtitle_url
= subtitle
.get('file')
52 kind
= subtitle
.get('kind')
53 if subtitle_url
or kind
and kind
!= 'captions':
55 subtitles
.setdefault(subtitle
.get('label', 'Svenska'), []).append({
61 'title': urplayer_data
['title'],
62 'description': self
._og
_search
_description
(webpage
),
63 'thumbnail': urplayer_data
.get('image'),
64 'series': urplayer_data
.get('series_title'),
65 'subtitles': subtitles
,