Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KelbyOneIE #2181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions yt_dlp/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@
from .karaoketv import KaraoketvIE
from .karrierevideos import KarriereVideosIE
from .keezmovies import KeezMoviesIE
from .kelbyone import KelbyOneIE
from .ketnet import KetnetIE
from .khanacademy import (
KhanAcademyIE,
Expand Down
88 changes: 88 additions & 0 deletions yt_dlp/extractor/kelbyone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from ..utils import int_or_none


class KelbyOneIE(InfoExtractor):
_VALID_URL = r'https?://members\.kelbyone\.com/course/(?P<id>[^$&?#/]+)'

_TESTS = [{
'url': 'https://members.kelbyone.com/course/glyn-dewis-mastering-selections/',
'playlist_mincount': 1,
'info_dict': {
'id': 'glyn-dewis-mastering-selections',
'title': 'Trailer - Mastering Selections in Photoshop',
},
'playlist': [{
'info_dict': {
'id': 'MkiOnLqK',
'ext': 'mp4',
'title': 'Trailer - Mastering Selections in Photoshop',
'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
'thumbnails': list,
'thumbnail': 'https://content.jwplatform.com/v2/media/MkiOnLqK/poster.jpg?width=720',
'timestamp': 1601568639,
'duration': 90,
'upload_date': '20201001',
'n_entries': 1,
},
}]
}]

def _entries(self, playlist):
for item in playlist:
id = item['mediaid']
thumbnails = [{
'url': image.get('src'),
'width': int_or_none(image.get('width')),
} for image in item.get('images') or []]
formats, subtitles = [], {}
for source in item.get('sources') or []:
if not source.get('file'):
continue
if source.get('type') == 'application/vnd.apple.mpegurl':
fmts, subs = self._extract_m3u8_formats_and_subtitles(source['file'], id)
formats.extend(fmts)
subtitles = self._merge_subtitles(subs, subtitles)
elif source.get('type') == 'audio/mp4':
formats.append({
'format_id': source.get('label'),
'url': source['file'],
'vcodec': 'none',
})
else:
formats.append({
'format_id': source.get('label'),
'height': source.get('height'),
'width': source.get('width'),
'url': source['file'],
})
for track in item.get('tracks'):
if track.get('kind') == 'captions' and track.get('file'):
subtitles.setdefault('en', []).append({
'url': track['file'],
})
self._sort_formats(formats)
yield {
'id': id,
'title': item['title'],
'description': item.get('description'),
'thumbnails': thumbnails,
'thumbnail': item.get('image'),
'timestamp': item.get('pubdate'),
'duration': item.get('duration'),
'formats': formats,
'subtitles': subtitles,
}

def _real_extract(self, url):
id = self._match_id(url)
webpage = self._download_webpage(url, id)
playlist_url = self._html_search_regex(r'playlist"\:"(https.*content\.jwplatform\.com.*json)"', webpage, 'playlist url').replace('\\', '')
course_data = self._download_json(playlist_url, id)
return self.playlist_result(self._entries(course_data['playlist']),
playlist_id=id,
playlist_title=course_data.get('title'),
playlist_description=course_data.get('description'))