]>
Raphaël G. Git Repositories - youtubedl/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\.)?ur(?:play|skola)\.se/(?:program|Produkter)/(?P<id>[0-9]+)'
10 'url': 'http://urplay.se/program/190031-tripp-trapp-trad-sovkudde',
11 'md5': 'ad5f0de86f16ca4c8062cd103959a9eb',
15 'title': 'Tripp, Trapp, Träd : Sovkudde',
16 'description': 'md5:b86bffdae04a7e9379d1d7e5947df1d1',
19 'url': 'http://urskola.se/Produkter/155794-Smasagor-meankieli-Grodan-i-vida-varlden',
20 'only_matching': True,
23 def _real_extract(self
, url
):
24 video_id
= self
._match
_id
(url
)
26 webpage
= self
._download
_webpage
(url
, video_id
)
27 urplayer_data
= self
._parse
_json
(self
._search
_regex
(
28 r
'urPlayer\.init\(({.+?})\);', webpage
, 'urplayer data'), video_id
)
29 host
= self
._download
_json
('http://streaming-loadbalancer.ur.se/loadbalancer.json', video_id
)['redirect']
32 for quality_attr
, quality
, preference
in (('', 'sd', 0), ('_hd', 'hd', 1)):
33 file_http
= urplayer_data
.get('file_http' + quality_attr
) or urplayer_data
.get('file_http_sub' + quality_attr
)
35 formats
.extend(self
._extract
_wowza
_formats
(
36 'http://%s/%splaylist.m3u8' % (host
, file_http
), video_id
, skip_protocols
=['rtmp', 'rtsp']))
37 self
._sort
_formats
(formats
)
40 for subtitle
in urplayer_data
.get('subtitles', []):
41 subtitle_url
= subtitle
.get('file')
42 kind
= subtitle
.get('kind')
43 if not subtitle_url
or (kind
and kind
!= 'captions'):
45 subtitles
.setdefault(subtitle
.get('label', 'Svenska'), []).append({
51 'title': urplayer_data
['title'],
52 'description': self
._og
_search
_description
(webpage
),
53 'thumbnail': urplayer_data
.get('image'),
54 'series': urplayer_data
.get('series_title'),
55 'subtitles': subtitles
,