]>
Commit | Line | Data |
---|---|---|
7cb09524 | 1 | import re |
2 | ||
77302fe5 | 3 | from .common import InfoExtractor |
b7788822 | 4 | from ..utils import unsmuggle_url |
77302fe5 | 5 | |
6 | ||
a4a554a7 | 7 | class JWPlatformIE(InfoExtractor): |
f3c0c773 | 8 | _VALID_URL = r'(?:https?://(?:content\.jwplatform|cdn\.jwplayer)\.com/(?:(?:feed|player|thumb|preview|manifest)s|jw6|v2/media)/|jwplatform:)(?P<id>[a-zA-Z0-9]{8})' |
7c072f00 | 9 | _TESTS = [{ |
d1e440a4 | 10 | 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js', |
cf9fd52f | 11 | 'md5': '3aa16e4f6860e6e78b7df5829519aed3', |
d1e440a4 YCH |
12 | 'info_dict': { |
13 | 'id': 'nPripu9l', | |
cf9fd52f | 14 | 'ext': 'mp4', |
d1e440a4 YCH |
15 | 'title': 'Big Buck Bunny Trailer', |
16 | 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.', | |
17 | 'upload_date': '20081127', | |
18 | 'timestamp': 1227796140, | |
cf9fd52f CC |
19 | 'duration': 32.0, |
20 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/nPripu9l/poster.jpg?width=720', | |
d1e440a4 | 21 | } |
7c072f00 RA |
22 | }, { |
23 | 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js', | |
24 | 'only_matching': True, | |
25 | }] | |
d1e440a4 | 26 | |
d3a3d7f0 | 27 | _WEBPAGE_TESTS = [{ |
28 | # JWPlatform iframe | |
29 | 'url': 'https://www.covermagazine.co.uk/feature/2465255/business-protection-involved', | |
30 | 'info_dict': { | |
31 | 'id': 'AG26UQXM', | |
32 | 'ext': 'mp4', | |
33 | 'upload_date': '20160719', | |
34 | 'timestamp': 1468923808, | |
35 | 'title': '2016_05_18 Cover L&G Business Protection V1 FINAL.mp4', | |
36 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/AG26UQXM/poster.jpg?width=720', | |
37 | 'description': '', | |
38 | 'duration': 294.0, | |
39 | }, | |
40 | }, { | |
41 | # Player url not surrounded by quotes | |
cf9fd52f | 42 | 'url': 'https://www.deutsche-kinemathek.de/en/online/streaming/school-trip', |
d3a3d7f0 | 43 | 'info_dict': { |
cf9fd52f CC |
44 | 'id': 'jUxh5uin', |
45 | 'title': 'Klassenfahrt', | |
d3a3d7f0 | 46 | 'ext': 'mp4', |
cf9fd52f CC |
47 | 'upload_date': '20230109', |
48 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/jUxh5uin/poster.jpg?width=720', | |
49 | 'timestamp': 1673270298, | |
50 | 'description': '', | |
51 | 'duration': 5193.0, | |
d3a3d7f0 | 52 | }, |
53 | 'params': {'allowed_extractors': ['generic', 'jwplatform']}, | |
cf9fd52f CC |
54 | }, { |
55 | # iframe src attribute includes backslash before URL string | |
56 | 'url': 'https://www.elespectador.com/colombia/video-asi-se-evito-la-fuga-de-john-poulos-presunto-feminicida-de-valentina-trespalacios-explicacion', | |
57 | 'info_dict': { | |
58 | 'id': 'QD3gsexj', | |
59 | 'title': 'Así se evitó la fuga de John Poulos, presunto feminicida de Valentina Trespalacios', | |
60 | 'ext': 'mp4', | |
61 | 'upload_date': '20230127', | |
62 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/QD3gsexj/poster.jpg?width=720', | |
63 | 'timestamp': 1674862986, | |
64 | 'description': 'md5:128fd74591c4e1fc2da598c5cb6f5ce4', | |
65 | 'duration': 263.0, | |
66 | }, | |
d3a3d7f0 | 67 | }] |
68 | ||
bfd973ec | 69 | @classmethod |
70 | def _extract_embed_urls(cls, url, webpage): | |
389e2956 | 71 | for tag, key in ((r'(?:script|iframe)', 'src'), ('input', 'value')): |
72 | # <input value=URL> is used by hyland.com | |
73 | # if we find <iframe>, dont look for <input> | |
74 | ret = re.findall( | |
cf9fd52f | 75 | r'<%s[^>]+?%s=\\?["\']?((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})' % (tag, key), |
389e2956 | 76 | webpage) |
77 | if ret: | |
78 | return ret | |
55baa67c | 79 | mobj = re.search(r'<div\b[^>]* data-video-jw-id="([a-zA-Z0-9]{8})"', webpage) |
80 | if mobj: | |
81 | return [f'jwplatform:{mobj.group(1)}'] | |
d1e440a4 YCH |
82 | |
83 | def _real_extract(self, url): | |
b7788822 S |
84 | url, smuggled_data = unsmuggle_url(url, {}) |
85 | self._initialize_geo_bypass({ | |
86 | 'countries': smuggled_data.get('geo_countries'), | |
87 | }) | |
d1e440a4 | 88 | video_id = self._match_id(url) |
7c072f00 | 89 | json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id) |
d1e440a4 | 90 | return self._parse_jwplayer_data(json_data, video_id) |