2018-05-05 03:21:52 +09:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2020-01-09 06:42:53 +09:00
|
|
|
import base64
|
2018-05-05 03:21:52 +09:00
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class CloudflareStreamIE(InfoExtractor):
|
2020-01-09 06:42:53 +09:00
|
|
|
_DOMAIN_RE = r'(?:cloudflarestream\.com|(?:videodelivery|bytehighway)\.net)'
|
2018-05-05 03:21:52 +09:00
|
|
|
_VALID_URL = r'''(?x)
|
|
|
|
https?://
|
|
|
|
(?:
|
2020-01-09 06:42:53 +09:00
|
|
|
(?:watch\.)?%s/|
|
|
|
|
embed\.%s/embed/[^/]+\.js\?.*?\bvideo=
|
2018-05-05 03:21:52 +09:00
|
|
|
)
|
2020-01-09 06:42:53 +09:00
|
|
|
(?P<id>[\da-f]{32}|[\w-]+\.[\w-]+\.[\w-]+)
|
|
|
|
''' % (_DOMAIN_RE, _DOMAIN_RE)
|
2018-05-05 03:21:52 +09:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://embed.cloudflarestream.com/embed/we4g.fla9.latest.js?video=31c9291ab41fac05471db4e73aa11717',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '31c9291ab41fac05471db4e73aa11717',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '31c9291ab41fac05471db4e73aa11717',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'https://watch.cloudflarestream.com/9df17203414fd1db3e3ed74abbe936c1',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://cloudflarestream.com/31c9291ab41fac05471db4e73aa11717/manifest/video.mpd',
|
|
|
|
'only_matching': True,
|
2019-05-11 05:09:00 +09:00
|
|
|
}, {
|
|
|
|
'url': 'https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=81d80727f3022488598f68d323c1ad5e',
|
|
|
|
'only_matching': True,
|
2018-05-05 03:21:52 +09:00
|
|
|
}]
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _extract_urls(webpage):
|
|
|
|
return [
|
|
|
|
mobj.group('url')
|
|
|
|
for mobj in re.finditer(
|
2019-05-11 05:09:00 +09:00
|
|
|
r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//embed\.(?:cloudflarestream\.com|videodelivery\.net)/embed/[^/]+\.js\?.*?\bvideo=[\da-f]+?.*?)\1',
|
2018-05-05 03:21:52 +09:00
|
|
|
webpage)]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
2020-01-09 06:42:53 +09:00
|
|
|
domain = 'bytehighway.net' if 'bytehighway.net/' in url else 'videodelivery.net'
|
|
|
|
base_url = 'https://%s/%s/' % (domain, video_id)
|
|
|
|
if '.' in video_id:
|
|
|
|
video_id = self._parse_json(base64.urlsafe_b64decode(
|
|
|
|
video_id.split('.')[1]), video_id)['sub']
|
|
|
|
manifest_base_url = base_url + 'manifest/video.'
|
2018-05-05 03:21:52 +09:00
|
|
|
|
|
|
|
formats = self._extract_m3u8_formats(
|
2020-01-09 06:42:53 +09:00
|
|
|
manifest_base_url + 'm3u8', video_id, 'mp4',
|
|
|
|
'm3u8_native', m3u8_id='hls', fatal=False)
|
2018-05-05 03:21:52 +09:00
|
|
|
formats.extend(self._extract_mpd_formats(
|
2020-01-09 06:42:53 +09:00
|
|
|
manifest_base_url + 'mpd', video_id, mpd_id='dash', fatal=False))
|
2018-05-05 03:21:52 +09:00
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': video_id,
|
2020-01-09 06:42:53 +09:00
|
|
|
'thumbnail': base_url + 'thumbnails/thumbnail.jpg',
|
2018-05-05 03:21:52 +09:00
|
|
|
'formats': formats,
|
|
|
|
}
|