]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/jwplatform.py
d6b8420a87f4fd3a3e359c75c89ee03f8ce21f04
[yt-dlp.git] / yt_dlp / extractor / jwplatform.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import unsmuggle_url
5
6
7 class JWPlatformIE(InfoExtractor):
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})'
9 _TESTS = [{
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 }
20 }, {
21 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js',
22 'only_matching': True,
23 }]
24
25 @classmethod
26 def _extract_embed_urls(cls, url, webpage):
27 for tag, key in ((r'(?:script|iframe)', 'src'), ('input', 'value')):
28 # <input value=URL> is used by hyland.com
29 # if we find <iframe>, dont look for <input>
30 ret = re.findall(
31 r'<%s[^>]+?%s=["\']((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})' % (tag, key),
32 webpage)
33 if ret:
34 return ret
35 mobj = re.search(r'<div\b[^>]* data-video-jw-id="([a-zA-Z0-9]{8})"', webpage)
36 if mobj:
37 return [f'jwplatform:{mobj.group(1)}']
38
39 def _real_extract(self, url):
40 url, smuggled_data = unsmuggle_url(url, {})
41 self._initialize_geo_bypass({
42 'countries': smuggled_data.get('geo_countries'),
43 })
44 video_id = self._match_id(url)
45 json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id)
46 return self._parse_jwplayer_data(json_data, video_id)