Skip to content

Commit

Permalink
[cloudflarestream] import embed URL extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine authored and pareronia committed Jun 22, 2020
1 parent 6b5770c commit e82690d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions youtube_dl/extractor/cloudflarestream.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@

class CloudflareStreamIE(InfoExtractor):
_DOMAIN_RE = r'(?:cloudflarestream\.com|(?:videodelivery|bytehighway)\.net)'
_EMBED_RE = r'embed\.%s/embed/[^/]+\.js\?.*?\bvideo=' % _DOMAIN_RE
_ID_RE = r'[\da-f]{32}|[\w-]+\.[\w-]+\.[\w-]+'
_VALID_URL = r'''(?x)
https?://
(?:
(?:watch\.)?%s/|
embed\.%s/embed/[^/]+\.js\?.*?\bvideo=
%s
)
(?P<id>[\da-f]{32}|[\w-]+\.[\w-]+\.[\w-]+)
''' % (_DOMAIN_RE, _DOMAIN_RE)
(?P<id>%s)
''' % (_DOMAIN_RE, _EMBED_RE, _ID_RE)
_TESTS = [{
'url': 'https://embed.cloudflarestream.com/embed/we4g.fla9.latest.js?video=31c9291ab41fac05471db4e73aa11717',
'info_dict': {
Expand All @@ -43,7 +45,7 @@ def _extract_urls(webpage):
return [
mobj.group('url')
for mobj in re.finditer(
r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//embed\.(?:cloudflarestream\.com|videodelivery\.net)/embed/[^/]+\.js\?.*?\bvideo=[\da-f]+?.*?)\1',
r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//%s(?:%s).*?)\1' % (CloudflareStreamIE._EMBED_RE, CloudflareStreamIE._ID_RE),
webpage)]

def _real_extract(self, url):
Expand Down

0 comments on commit e82690d

Please sign in to comment.