3 from .common
import InfoExtractor
6 class CloudflareStreamIE(InfoExtractor
):
7 _DOMAIN_RE
= r
'(?:cloudflarestream\.com|(?:videodelivery|bytehighway)\.net)'
8 _EMBED_RE
= r
'embed\.%s/embed/[^/]+\.js\?.*?\bvideo=' % _DOMAIN_RE
9 _ID_RE
= r
'[\da-f]{32}|[\w-]+\.[\w-]+\.[\w-]+'
17 ''' % (_DOMAIN_RE
, _EMBED_RE
, _ID_RE
)
18 _EMBED_REGEX
= [fr
'<script[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//{_EMBED_RE}
(?
:{_ID_RE}
).*?
)\
1']
20 'url
': 'https
://embed
.cloudflarestream
.com
/embed
/we4g
.fla9
.latest
.js?video
=31c9291ab41fac05471db4e73aa11717
',
22 'id': '31c9291ab41fac05471db4e73aa11717
',
24 'title
': '31c9291ab41fac05471db4e73aa11717
',
27 'skip_download
': True,
30 'url
': 'https
://watch
.cloudflarestream
.com
/9df17203414fd1db3e3ed74abbe936c1
',
31 'only_matching
': True,
33 'url
': 'https
://cloudflarestream
.com
/31c9291ab41fac05471db4e73aa11717
/manifest
/video
.mpd
',
34 'only_matching
': True,
36 'url
': 'https
://embed
.videodelivery
.net
/embed
/r4xu
.fla9
.latest
.js?video
=81d80727f3022488598f68d323c1ad5e
',
37 'only_matching
': True,
39 'url
': 'https
://customer
-aw5py76sw8wyqzmh
.cloudflarestream
.com
/2463f6d3e06fa29710a337f5f5389fd8
/iframe
',
40 'only_matching
': True,
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 domain = 'bytehighway
.net
' if 'bytehighway
.net
/' in url else 'videodelivery
.net
'
46 base_url = 'https
://%s/%s/' % (domain, video_id)
48 video_id = self._parse_json(base64.urlsafe_b64decode(
49 video_id.split('.')[1] + '==='), video_id)['sub
']
50 manifest_base_url = base_url + 'manifest
/video
.'
52 formats, subtitles = self._extract_m3u8_formats_and_subtitles(
53 manifest_base_url + 'm3u8
', video_id, 'mp4
',
54 'm3u8_native
', m3u8_id='hls
', fatal=False)
55 fmts, subs = self._extract_mpd_formats_and_subtitles(
56 manifest_base_url + 'mpd
', video_id, mpd_id='dash
', fatal=False)
58 self._merge_subtitles(subs, target=subtitles)
63 'thumbnail
': base_url + 'thumbnails
/thumbnail
.jpg
',
65 'subtitles
': subtitles,