]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/jwplatform.py
[extractor/jwplatform] Look for `data-video-jw-id`
[yt-dlp.git] / yt_dlp / extractor / jwplatform.py
CommitLineData
7cb09524 1import re
2
77302fe5 3from .common import InfoExtractor
b7788822 4from ..utils import unsmuggle_url
77302fe5 5
6
a4a554a7 7class JWPlatformIE(InfoExtractor):
7d327fea 8 _VALID_URL = r'(?:https?://(?:content\.jwplatform|cdn\.jwplayer)\.com/(?:(?:feed|player|thumb|preview)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
YCH
24
25 @staticmethod
26 def _extract_url(webpage):
b0ead0e0
S
27 urls = JWPlatformIE._extract_urls(webpage)
28 return urls[0] if urls else None
29
30 @staticmethod
31 def _extract_urls(webpage):
389e2956 32 for tag, key in ((r'(?:script|iframe)', 'src'), ('input', 'value')):
33 # <input value=URL> is used by hyland.com
34 # if we find <iframe>, dont look for <input>
35 ret = re.findall(
36 r'<%s[^>]+?%s=["\']((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})' % (tag, key),
37 webpage)
38 if ret:
39 return ret
55baa67c 40 mobj = re.search(r'<div\b[^>]* data-video-jw-id="([a-zA-Z0-9]{8})"', webpage)
41 if mobj:
42 return [f'jwplatform:{mobj.group(1)}']
d1e440a4
YCH
43
44 def _real_extract(self, url):
b7788822
S
45 url, smuggled_data = unsmuggle_url(url, {})
46 self._initialize_geo_bypass({
47 'countries': smuggled_data.get('geo_countries'),
48 })
d1e440a4 49 video_id = self._match_id(url)
7c072f00 50 json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id)
d1e440a4 51 return self._parse_jwplayer_data(json_data, video_id)