]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jwplatform.py
Update changelog.
[youtubedl] / youtube_dl / extractor / jwplatform.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import unsmuggle_url
8
9
10 class JWPlatformIE(InfoExtractor):
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})'
12 _TESTS = [{
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 }
23 }, {
24 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js',
25 'only_matching': True,
26 }]
27
28 @staticmethod
29 def _extract_url(webpage):
30 urls = JWPlatformIE._extract_urls(webpage)
31 return urls[0] if urls else None
32
33 @staticmethod
34 def _extract_urls(webpage):
35 return re.findall(
36 r'<(?:script|iframe)[^>]+?src=["\']((?:https?:)?//(?:content\.jwplatform|cdn\.jwplayer)\.com/players/[a-zA-Z0-9]{8})',
37 webpage)
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)