]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/konserthusetplay.py
55291c66ff066733a8610abe5acc65b1e0daf7f3
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
11 class KonserthusetPlayIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?konserthusetplay\.se/\?.*\bm=(?P<id>[^&]+)'
14 'url': 'http://www.konserthusetplay.se/?m=CKDDnlCY-dhWAAqiMERd-A',
16 'id': 'CKDDnlCY-dhWAAqiMERd-A',
18 'title': 'Orkesterns instrument: Valthornen',
19 'description': 'md5:f10e1f0030202020396a4d712d2fa827',
20 'thumbnail': 're:^https?://.*$',
25 'skip_download': True,
29 def _real_extract(self
, url
):
30 video_id
= self
._match
_id
(url
)
32 webpage
= self
._download
_webpage
(url
, video_id
)
34 e
= self
._search
_regex
(
35 r
'https?://csp\.picsearch\.com/rest\?.*\be=(.+?)[&"\']', webpage, 'e
')
37 rest = self._download_json(
38 'http
://csp
.picsearch
.com
/rest?e
=%s&containerId
=mediaplayer
&i
=object' % e,
39 video_id, transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1])
42 player_config = media['playerconfig
']
43 playlist = player_config['playlist
']
45 source = next(f for f in playlist if f.get('bitrates
'))
47 FORMAT_ID_REGEX = r'_([^_
]+)_h264m\
.mp4
'
51 fallback_url = source.get('fallbackUrl
')
52 fallback_format_id = None
54 fallback_format_id = self._search_regex(
55 FORMAT_ID_REGEX, fallback_url, 'format
id', default=None)
57 connection_url = (player_config.get('rtmp
', {}).get(
58 'netConnectionUrl
') or player_config.get(
59 'plugins
', {}).get('bwcheck
', {}).get('netConnectionUrl
'))
61 for f in source['bitrates
']:
62 video_url = f.get('url
')
65 format_id = self._search_regex(
66 FORMAT_ID_REGEX, video_url, 'format
id', default=None)
68 'vbr
': int_or_none(f.get('bitrate
')),
69 'width
': int_or_none(f.get('width
')),
70 'height
': int_or_none(f.get('height
')),
74 'url
': connection_url,
75 'play_path
': video_url,
76 'format_id
': 'rtmp
-%s' % format_id if format_id else 'rtmp
',
80 if format_id and format_id == fallback_format_id:
84 'format_id
': 'http
-%s' % format_id if format_id else 'http
',
88 if not formats and fallback_url:
93 self._sort_formats(formats)
95 title = player_config.get('title
') or media['title
']
96 description = player_config.get('mediaInfo
', {}).get('description
')
97 thumbnail = media.get('image
')
98 duration = float_or_none(media.get('duration
'), 1000)
103 'description
': description,
104 'thumbnail
': thumbnail,
105 'duration
': duration,