1 from .common
import InfoExtractor
10 class KonserthusetPlayIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?(?:konserthusetplay|rspoplay)\.se/\?.*\bm=(?P<id>[^&]+)'
13 'url': 'http://www.konserthusetplay.se/?m=CKDDnlCY-dhWAAqiMERd-A',
14 'md5': 'e3fd47bf44e864bd23c08e487abe1967',
16 'id': 'CKDDnlCY-dhWAAqiMERd-A',
18 'title': 'Orkesterns instrument: Valthornen',
19 'description': 'md5:f10e1f0030202020396a4d712d2fa827',
20 'thumbnail': 're:^https?://.*$',
24 'url': 'http://rspoplay.se/?m=elWuEH34SMKvaO4wO_cHBw',
25 'only_matching': True,
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
31 webpage
= self
._download
_webpage
(url
, video_id
)
33 e
= self
._search
_regex
(
34 r
'https?://csp\.picsearch\.com/rest\?.*\be=(.+?)[&"\']', webpage, 'e
')
36 rest = self._download_json(
37 'http
://csp
.picsearch
.com
/rest?e
=%s&containerId
=mediaplayer
&i
=object' % e,
38 video_id, transform_source=lambda s: s[s.index('{'):s.rindex('}
') + 1])
41 player_config = media['playerconfig
']
42 playlist = player_config['playlist
']
44 source = next(f for f in playlist if f.get('bitrates
') or f.get('provider
'))
46 FORMAT_ID_REGEX = r'_([^_
]+)_h264m\
.mp4
'
50 m3u8_url = source.get('url
')
51 if m3u8_url and determine_ext(m3u8_url) == 'm3u8
':
52 formats.extend(self._extract_m3u8_formats(
53 m3u8_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
54 m3u8_id='hls
', fatal=False))
56 fallback_url = source.get('fallbackUrl
')
57 fallback_format_id = None
59 fallback_format_id = self._search_regex(
60 FORMAT_ID_REGEX, fallback_url, 'format
id', default=None)
62 connection_url = (player_config.get('rtmp
', {}).get(
63 'netConnectionUrl
') or player_config.get(
64 'plugins
', {}).get('bwcheck', {}).get('netConnectionUrl
'))
66 for f in source['bitrates
']:
67 video_url = f.get('url
')
70 format_id = self._search_regex(
71 FORMAT_ID_REGEX, video_url, 'format
id', default=None)
73 'vbr
': int_or_none(f.get('bitrate
')),
74 'width
': int_or_none(f.get('width
')),
75 'height
': int_or_none(f.get('height
')),
79 'url
': connection_url,
80 'play_path
': video_url,
81 'format_id
': 'rtmp
-%s' % format_id if format_id else 'rtmp
',
85 if format_id and format_id == fallback_format_id:
89 'format_id
': 'http
-%s' % format_id if format_id else 'http
',
93 if not formats and fallback_url:
98 self._sort_formats(formats)
100 title = player_config.get('title
') or media['title
']
101 description = player_config.get('mediaInfo
', {}).get('description
')
102 thumbnail = media.get('image
')
103 duration = float_or_none(media.get('duration
'), 1000)
106 captions = source.get('captionsAvailableLanguages
')
107 if isinstance(captions, dict):
108 for lang, subtitle_url in captions.items():
109 subtitle_url = url_or_none(subtitle_url)
110 if lang != 'none
' and subtitle_url:
111 subtitles.setdefault(lang, []).append({'url': subtitle_url})
116 'description
': description,
117 'thumbnail
': thumbnail,
118 'duration
': duration,
120 'subtitles
': subtitles,