]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/urplay.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import unified_timestamp
8 class URPlayIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?ur(?:play|skola)\.se/(?:program|Produkter)/(?P<id>[0-9]+)'
11 'url': 'https://urplay.se/program/203704-ur-samtiden-livet-universum-och-rymdens-markliga-musik-om-vetenskap-kritiskt-tankande-och-motstand',
12 'md5': 'ff5b0c89928f8083c74bbd5099c9292d',
16 'title': 'UR Samtiden - Livet, universum och rymdens märkliga musik : Om vetenskap, kritiskt tänkande och motstånd',
17 'description': 'md5:5344508a52aa78c1ced6c1b8b9e44e9a',
18 'timestamp': 1513512768,
19 'upload_date': '20171217',
22 'url': 'https://urskola.se/Produkter/190031-Tripp-Trapp-Trad-Sovkudde',
26 'title': 'Tripp, Trapp, Träd : Sovkudde',
27 'description': 'md5:b86bffdae04a7e9379d1d7e5947df1d1',
28 'timestamp': 1440093600,
29 'upload_date': '20150820',
32 'url': 'http://urskola.se/Produkter/155794-Smasagor-meankieli-Grodan-i-vida-varlden',
33 'only_matching': True,
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
39 webpage
= self
._download
_webpage
(url
, video_id
)
40 urplayer_data
= self
._parse
_json
(self
._search
_regex
(
41 r
'urPlayer\.init\(({.+?})\);', webpage
, 'urplayer data'), video_id
)
42 host
= self
._download
_json
('http://streaming-loadbalancer.ur.se/loadbalancer.json', video_id
)['redirect']
45 for quality_attr
, quality
, preference
in (('', 'sd', 0), ('_hd', 'hd', 1)):
46 file_http
= urplayer_data
.get('file_http' + quality_attr
) or urplayer_data
.get('file_http_sub' + quality_attr
)
48 formats
.extend(self
._extract
_wowza
_formats
(
49 'http://%s/%splaylist.m3u8' % (host
, file_http
), video_id
, skip_protocols
=['rtmp', 'rtsp']))
50 self
._sort
_formats
(formats
)
53 for subtitle
in urplayer_data
.get('subtitles', []):
54 subtitle_url
= subtitle
.get('file')
55 kind
= subtitle
.get('kind')
56 if not subtitle_url
or (kind
and kind
!= 'captions'):
58 subtitles
.setdefault(subtitle
.get('label', 'Svenska'), []).append({
64 'title': urplayer_data
['title'],
65 'description': self
._og
_search
_description
(webpage
),
66 'thumbnail': urplayer_data
.get('image'),
67 'timestamp': unified_timestamp(self
._html
_search
_meta
(('uploadDate', 'schema:uploadDate'), webpage
, 'timestamp')),
68 'series': urplayer_data
.get('series_title'),
69 'subtitles': subtitles
,