]>
Commit | Line | Data |
---|---|---|
497d77e1 AG |
1 | from .common import InfoExtractor |
2 | from ..utils import int_or_none | |
3 | ||
4 | ||
5 | class KelbyOneIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://members\.kelbyone\.com/course/(?P<id>[^$&?#/]+)' | |
7 | ||
8 | _TESTS = [{ | |
9 | 'url': 'https://members.kelbyone.com/course/glyn-dewis-mastering-selections/', | |
10 | 'playlist_mincount': 1, | |
11 | 'info_dict': { | |
12 | 'id': 'glyn-dewis-mastering-selections', | |
13 | 'title': 'Trailer - Mastering Selections in Photoshop', | |
14 | }, | |
15 | 'playlist': [{ | |
16 | 'info_dict': { | |
17 | 'id': 'MkiOnLqK', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Trailer - Mastering Selections in Photoshop', | |
20 | 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', | |
21 | 'thumbnail': 'https://content.jwplatform.com/v2/media/MkiOnLqK/poster.jpg?width=720', | |
22 | 'timestamp': 1601568639, | |
23 | 'duration': 90, | |
24 | 'upload_date': '20201001', | |
25 | }, | |
26 | }] | |
27 | }] | |
28 | ||
29 | def _entries(self, playlist): | |
30 | for item in playlist: | |
31 | video_id = item['mediaid'] | |
32 | thumbnails = [{ | |
33 | 'url': image.get('src'), | |
34 | 'width': int_or_none(image.get('width')), | |
35 | } for image in item.get('images') or []] | |
36 | formats, subtitles = [], {} | |
37 | for source in item.get('sources') or []: | |
38 | if not source.get('file'): | |
39 | continue | |
40 | if source.get('type') == 'application/vnd.apple.mpegurl': | |
41 | fmts, subs = self._extract_m3u8_formats_and_subtitles(source['file'], video_id) | |
42 | formats.extend(fmts) | |
43 | subtitles = self._merge_subtitles(subs, subtitles) | |
44 | elif source.get('type') == 'audio/mp4': | |
45 | formats.append({ | |
46 | 'format_id': source.get('label'), | |
47 | 'url': source['file'], | |
48 | 'vcodec': 'none', | |
49 | }) | |
50 | else: | |
51 | formats.append({ | |
52 | 'format_id': source.get('label'), | |
53 | 'height': source.get('height'), | |
54 | 'width': source.get('width'), | |
55 | 'url': source['file'], | |
56 | }) | |
57 | for track in item.get('tracks'): | |
58 | if track.get('kind') == 'captions' and track.get('file'): | |
59 | subtitles.setdefault('en', []).append({ | |
60 | 'url': track['file'], | |
61 | }) | |
497d77e1 AG |
62 | yield { |
63 | 'id': video_id, | |
64 | 'title': item['title'], | |
65 | 'description': item.get('description'), | |
66 | 'thumbnails': thumbnails, | |
67 | 'thumbnail': item.get('image'), | |
68 | 'timestamp': item.get('pubdate'), | |
69 | 'duration': item.get('duration'), | |
70 | 'formats': formats, | |
71 | 'subtitles': subtitles, | |
72 | } | |
73 | ||
74 | def _real_extract(self, url): | |
75 | item_id = self._match_id(url) | |
76 | webpage = self._download_webpage(url, item_id) | |
77 | playlist_url = self._html_search_regex(r'playlist"\:"(https.*content\.jwplatform\.com.*json)"', webpage, 'playlist url').replace('\\', '') | |
78 | course_data = self._download_json(playlist_url, item_id) | |
79 | return self.playlist_result(self._entries(course_data['playlist']), item_id, | |
80 | course_data.get('title'), course_data.get('description')) |