3 from .common
import InfoExtractor
14 class UplynkBaseIE(InfoExtractor
):
15 _UPLYNK_URL_RE
= r
'''(?x)
16 https?://[\w-]+\.uplynk\.com/(?P<path>
17 ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|
20 (?:.*?\bpbs=(?P<session_id>[^&]+))?'''
22 def _extract_uplynk_info(self
, url
):
23 uplynk_content_url
, smuggled_data
= unsmuggle_url(url
, {})
24 mobj
= re
.match(self
._UPLYNK
_URL
_RE
, uplynk_content_url
)
26 raise ExtractorError('Necessary parameters not found in Uplynk URL')
27 path
, external_id
, video_id
, session_id
= mobj
.group('path', 'external_id', 'id', 'session_id')
28 display_id
= video_id
or external_id
29 headers
= traverse_obj(
30 smuggled_data
, {'Referer': 'Referer', 'Origin': 'Origin'}, casesense
=False)
31 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
32 f
'http://content.uplynk.com/{path}.m3u8', display_id
, 'mp4', headers
=headers
)
35 f
['extra_param_to_segment_url'] = f
'pbs={session_id}'
36 asset
= self
._download
_json
(
37 f
'http://content.uplynk.com/player/assetinfo/{path}.json', display_id
)
38 if asset
.get('error') == 1:
39 msg
= asset
.get('msg') or 'unknown error'
40 raise ExtractorError(f
'{self.IE_NAME} said: {msg}', expected
=True)
44 'title': asset
['desc'],
45 'thumbnail': asset
.get('default_poster_url'),
46 'duration': float_or_none(asset
.get('duration')),
47 'uploader_id': asset
.get('owner'),
49 'subtitles': subtitles
,
53 class UplynkIE(UplynkBaseIE
):
55 _VALID_URL
= UplynkBaseIE
._UPLYNK
_URL
_RE
57 'url': 'http://content.uplynk.com/e89eaf2ce9054aa89d92ddb2d817a52e.m3u8',
59 'id': 'e89eaf2ce9054aa89d92ddb2d817a52e',
61 'title': '030816-kgo-530pm-solar-eclipse-vid_web.mp4',
62 'uploader_id': '4413701bf5a1488db55b767f8ae9d4fa',
63 'duration': 530.2739166666679,
64 'thumbnail': r
're:^https?://.*\.jpg$',
67 'skip_download': 'm3u8',
71 def _real_extract(self
, url
):
72 return self
._extract
_uplynk
_info
(url
)
75 class UplynkPreplayIE(UplynkBaseIE
):
76 IE_NAME
= 'uplynk:preplay'
77 _VALID_URL
= r
'https?://[\w-]+\.uplynk\.com/preplay2?/(?P<path>ext/[0-9a-f]{32}/(?P<external_id>[^/?&]+)|(?P<id>[0-9a-f]{32}))\.json'
79 def _real_extract(self
, url
):
80 url
, smuggled_data
= unsmuggle_url(url
, {})
81 path
, external_id
, video_id
= self
._match
_valid
_url
(url
).groups()
82 display_id
= video_id
or external_id
83 preplay
= self
._download
_json
(url
, display_id
)
84 content_url
= f
'http://content.uplynk.com/{path}.m3u8'
85 session_id
= preplay
.get('sid')
87 content_url
= update_url_query(content_url
, {'pbs': session_id
})
88 return self
._extract
_uplynk
_info
(smuggle_url(content_url
, smuggled_data
))