]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/jwplatform.py
[adobepass] Add MSO Sling TV (#596)
[yt-dlp.git] / yt_dlp / extractor / jwplatform.py
CommitLineData
77302fe5 1# coding: utf-8
2from __future__ import unicode_literals
3
7cb09524 4import re
5
77302fe5 6from .common import InfoExtractor
b7788822 7from ..utils import unsmuggle_url
77302fe5 8
9
a4a554a7 10class JWPlatformIE(InfoExtractor):
7d327fea 11 _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 12 _TESTS = [{
d1e440a4
YCH
13 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js',
14 'md5': 'fa8899fa601eb7c83a64e9d568bdf325',
15 'info_dict': {
16 'id': 'nPripu9l',
17 'ext': 'mov',
18 'title': 'Big Buck Bunny Trailer',
19 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.',
20 'upload_date': '20081127',
21 'timestamp': 1227796140,
22 }
7c072f00
RA
23 }, {
24 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js',
25 'only_matching': True,
26 }]
d1e440a4
YCH
27
28 @staticmethod
29 def _extract_url(webpage):
b0ead0e0
S
30 urls = JWPlatformIE._extract_urls(webpage)
31 return urls[0] if urls else None
32
33 @staticmethod
34 def _extract_urls(webpage):
389e2956 35 for tag, key in ((r'(?:script|iframe)', 'src'), ('input', 'value')):
36 # <input value=URL> is used by hyland.com
37 # if we find <iframe>, dont look for <input>
38 ret = re.findall(
39 r'<%s[^>]+?%s=["\']((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})' % (tag, key),
40 webpage)
41 if ret:
42 return ret
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)