]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cloudflarestream.py
Annotate changelog with bug being closed.
[youtubedl] / youtube_dl / extractor / cloudflarestream.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class CloudflareStreamIE(InfoExtractor):
10 _VALID_URL = r'''(?x)
11 https?://
12 (?:
13 (?:watch\.)?(?:cloudflarestream\.com|videodelivery\.net)/|
14 embed\.(?:cloudflarestream\.com|videodelivery\.net)/embed/[^/]+\.js\?.*?\bvideo=
15 )
16 (?P<id>[\da-f]+)
17 '''
18 _TESTS = [{
19 'url': 'https://embed.cloudflarestream.com/embed/we4g.fla9.latest.js?video=31c9291ab41fac05471db4e73aa11717',
20 'info_dict': {
21 'id': '31c9291ab41fac05471db4e73aa11717',
22 'ext': 'mp4',
23 'title': '31c9291ab41fac05471db4e73aa11717',
24 },
25 'params': {
26 'skip_download': True,
27 },
28 }, {
29 'url': 'https://watch.cloudflarestream.com/9df17203414fd1db3e3ed74abbe936c1',
30 'only_matching': True,
31 }, {
32 'url': 'https://cloudflarestream.com/31c9291ab41fac05471db4e73aa11717/manifest/video.mpd',
33 'only_matching': True,
34 }, {
35 'url': 'https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=81d80727f3022488598f68d323c1ad5e',
36 'only_matching': True,
37 }]
38
39 @staticmethod
40 def _extract_urls(webpage):
41 return [
42 mobj.group('url')
43 for mobj in re.finditer(
44 r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//embed\.(?:cloudflarestream\.com|videodelivery\.net)/embed/[^/]+\.js\?.*?\bvideo=[\da-f]+?.*?)\1',
45 webpage)]
46
47 def _real_extract(self, url):
48 video_id = self._match_id(url)
49
50 formats = self._extract_m3u8_formats(
51 'https://cloudflarestream.com/%s/manifest/video.m3u8' % video_id,
52 video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls',
53 fatal=False)
54 formats.extend(self._extract_mpd_formats(
55 'https://cloudflarestream.com/%s/manifest/video.mpd' % video_id,
56 video_id, mpd_id='dash', fatal=False))
57 self._sort_formats(formats)
58
59 return {
60 'id': video_id,
61 'title': video_id,
62 'formats': formats,
63 }