]>
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 YCH |
10 | 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js', |
11 | 'md5': 'fa8899fa601eb7c83a64e9d568bdf325', | |
12 | 'info_dict': { | |
13 | 'id': 'nPripu9l', | |
14 | 'ext': 'mov', | |
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, | |
19 | } | |
7c072f00 RA |
20 | }, { |
21 | 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js', | |
22 | 'only_matching': True, | |
23 | }] | |
d1e440a4 | 24 | |
d3a3d7f0 | 25 | _WEBPAGE_TESTS = [{ |
26 | # JWPlatform iframe | |
27 | 'url': 'https://www.covermagazine.co.uk/feature/2465255/business-protection-involved', | |
28 | 'info_dict': { | |
29 | 'id': 'AG26UQXM', | |
30 | 'ext': 'mp4', | |
31 | 'upload_date': '20160719', | |
32 | 'timestamp': 1468923808, | |
33 | 'title': '2016_05_18 Cover L&G Business Protection V1 FINAL.mp4', | |
34 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/AG26UQXM/poster.jpg?width=720', | |
35 | 'description': '', | |
36 | 'duration': 294.0, | |
37 | }, | |
38 | }, { | |
39 | # Player url not surrounded by quotes | |
40 | 'url': 'https://www.deutsche-kinemathek.de/en/online/streaming/darling-berlin', | |
41 | 'info_dict': { | |
42 | 'id': 'R10NQdhY', | |
43 | 'title': 'Playgirl', | |
44 | 'ext': 'mp4', | |
45 | 'upload_date': '20220624', | |
46 | 'thumbnail': 'https://cdn.jwplayer.com/v2/media/R10NQdhY/poster.jpg?width=720', | |
47 | 'timestamp': 1656064800, | |
48 | 'description': 'BRD 1966, Will Tremper', | |
49 | 'duration': 5146.0, | |
50 | }, | |
51 | 'params': {'allowed_extractors': ['generic', 'jwplatform']}, | |
52 | }] | |
53 | ||
bfd973ec | 54 | @classmethod |
55 | def _extract_embed_urls(cls, url, webpage): | |
389e2956 | 56 | for tag, key in ((r'(?:script|iframe)', 'src'), ('input', 'value')): |
57 | # <input value=URL> is used by hyland.com | |
58 | # if we find <iframe>, dont look for <input> | |
59 | ret = re.findall( | |
d3a3d7f0 | 60 | r'<%s[^>]+?%s=["\']?((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})' % (tag, key), |
389e2956 | 61 | webpage) |
62 | if ret: | |
63 | return ret | |
55baa67c | 64 | mobj = re.search(r'<div\b[^>]* data-video-jw-id="([a-zA-Z0-9]{8})"', webpage) |
65 | if mobj: | |
66 | return [f'jwplatform:{mobj.group(1)}'] | |
d1e440a4 YCH |
67 | |
68 | def _real_extract(self, url): | |
b7788822 S |
69 | url, smuggled_data = unsmuggle_url(url, {}) |
70 | self._initialize_geo_bypass({ | |
71 | 'countries': smuggled_data.get('geo_countries'), | |
72 | }) | |
d1e440a4 | 73 | video_id = self._match_id(url) |
7c072f00 | 74 | json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id) |
d1e440a4 | 75 | return self._parse_jwplayer_data(json_data, video_id) |