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