]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jwplatform.py
d/rules: Drop makefile mangling
[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
8
9 class JWPlatformIE(InfoExtractor):
10 _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})'
11 _TESTS = [{
12 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js',
13 'md5': 'fa8899fa601eb7c83a64e9d568bdf325',
14 'info_dict': {
15 'id': 'nPripu9l',
16 'ext': 'mov',
17 'title': 'Big Buck Bunny Trailer',
18 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.',
19 'upload_date': '20081127',
20 'timestamp': 1227796140,
21 }
22 }, {
23 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js',
24 'only_matching': True,
25 }]
26
27 @staticmethod
28 def _extract_url(webpage):
29 urls = JWPlatformIE._extract_urls(webpage)
30 return urls[0] if urls else None
31
32 @staticmethod
33 def _extract_urls(webpage):
34 return re.findall(
35 r'<(?:script|iframe)[^>]+?src=["\']((?:https?:)?//content\.jwplatform\.com/players/[a-zA-Z0-9]{8})',
36 webpage)
37
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
40 json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id)
41 return self._parse_jwplayer_data(json_data, video_id)