mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[egghead] Fix extraction (closes #14388)
This commit is contained in:
parent
9211e3319e
commit
514e8aefd4
1 changed files with 62 additions and 19 deletions
|
@ -2,7 +2,9 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
|
@ -17,7 +19,7 @@ class EggheadCourseIE(InfoExtractor):
|
||||||
'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
|
'url': 'https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript',
|
||||||
'playlist_count': 29,
|
'playlist_count': 29,
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'professor-frisby-introduces-composable-functional-javascript',
|
'id': '72',
|
||||||
'title': 'Professor Frisby Introduces Composable Functional JavaScript',
|
'title': 'Professor Frisby Introduces Composable Functional JavaScript',
|
||||||
'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
|
'description': 're:(?s)^This course teaches the ubiquitous.*You\'ll start composing functionality before you know it.$',
|
||||||
},
|
},
|
||||||
|
@ -26,14 +28,28 @@ class EggheadCourseIE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
playlist_id = self._match_id(url)
|
playlist_id = self._match_id(url)
|
||||||
|
|
||||||
course = self._download_json(
|
lessons = self._download_json(
|
||||||
'https://egghead.io/api/v1/series/%s' % playlist_id, playlist_id)
|
'https://egghead.io/api/v1/series/%s/lessons' % playlist_id,
|
||||||
|
playlist_id, 'Downloading course lessons JSON')
|
||||||
|
|
||||||
entries = [
|
entries = []
|
||||||
self.url_result(
|
for lesson in lessons:
|
||||||
'wistia:%s' % lesson['wistia_id'], ie='Wistia',
|
lesson_url = lesson.get('http_url')
|
||||||
video_id=lesson['wistia_id'], video_title=lesson.get('title'))
|
if not lesson_url or not isinstance(lesson_url, compat_str):
|
||||||
for lesson in course['lessons'] if lesson.get('wistia_id')]
|
continue
|
||||||
|
lesson_id = lesson.get('id')
|
||||||
|
if lesson_id:
|
||||||
|
lesson_id = compat_str(lesson_id)
|
||||||
|
entries.append(self.url_result(
|
||||||
|
lesson_url, ie=EggheadLessonIE.ie_key(), video_id=lesson_id))
|
||||||
|
|
||||||
|
course = self._download_json(
|
||||||
|
'https://egghead.io/api/v1/series/%s' % playlist_id,
|
||||||
|
playlist_id, 'Downloading course JSON', fatal=False) or {}
|
||||||
|
|
||||||
|
playlist_id = course.get('id')
|
||||||
|
if playlist_id:
|
||||||
|
playlist_id = compat_str(playlist_id)
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
entries, playlist_id, course.get('title'),
|
entries, playlist_id, course.get('title'),
|
||||||
|
@ -43,11 +59,12 @@ def _real_extract(self, url):
|
||||||
class EggheadLessonIE(InfoExtractor):
|
class EggheadLessonIE(InfoExtractor):
|
||||||
IE_DESC = 'egghead.io lesson'
|
IE_DESC = 'egghead.io lesson'
|
||||||
IE_NAME = 'egghead:lesson'
|
IE_NAME = 'egghead:lesson'
|
||||||
_VALID_URL = r'https://egghead\.io/lessons/(?P<id>[^/?#&]+)'
|
_VALID_URL = r'https://egghead\.io/(?:api/v1/)?lessons/(?P<id>[^/?#&]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
|
'url': 'https://egghead.io/lessons/javascript-linear-data-flow-with-container-style-types-box',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'fv5yotjxcg',
|
'id': '1196',
|
||||||
|
'display_id': 'javascript-linear-data-flow-with-container-style-types-box',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Create linear data flow with container style types (Box)',
|
'title': 'Create linear data flow with container style types (Box)',
|
||||||
'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
|
'description': 'md5:9aa2cdb6f9878ed4c39ec09e85a8150e',
|
||||||
|
@ -60,25 +77,51 @@ class EggheadLessonIE(InfoExtractor):
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
|
'format': 'bestvideo',
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://egghead.io/api/v1/lessons/react-add-redux-to-a-react-application',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
lesson_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
|
|
||||||
lesson = self._download_json(
|
lesson = self._download_json(
|
||||||
'https://egghead.io/api/v1/lessons/%s' % lesson_id, lesson_id)
|
'https://egghead.io/api/v1/lessons/%s' % display_id, display_id)
|
||||||
|
|
||||||
|
lesson_id = compat_str(lesson['id'])
|
||||||
|
title = lesson['title']
|
||||||
|
|
||||||
|
formats = []
|
||||||
|
for _, format_url in lesson['media_urls'].items():
|
||||||
|
if not format_url or not isinstance(format_url, compat_str):
|
||||||
|
continue
|
||||||
|
ext = determine_ext(format_url)
|
||||||
|
if ext == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
format_url, lesson_id, 'mp4', entry_protocol='m3u8',
|
||||||
|
m3u8_id='hls', fatal=False))
|
||||||
|
elif ext == 'mpd':
|
||||||
|
formats.extend(self._extract_mpd_formats(
|
||||||
|
format_url, lesson_id, mpd_id='dash', fatal=False))
|
||||||
|
else:
|
||||||
|
formats.append({
|
||||||
|
'url': format_url,
|
||||||
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'id': lesson_id,
|
||||||
'ie_key': 'Wistia',
|
'display_id': display_id,
|
||||||
'url': 'wistia:%s' % lesson['wistia_id'],
|
'title': title,
|
||||||
'id': lesson['wistia_id'],
|
|
||||||
'title': lesson.get('title'),
|
|
||||||
'description': lesson.get('summary'),
|
'description': lesson.get('summary'),
|
||||||
'thumbnail': lesson.get('thumb_nail'),
|
'thumbnail': lesson.get('thumb_nail'),
|
||||||
'timestamp': unified_timestamp(lesson.get('published_at')),
|
'timestamp': unified_timestamp(lesson.get('published_at')),
|
||||||
'duration': int_or_none(lesson.get('duration')),
|
'duration': int_or_none(lesson.get('duration')),
|
||||||
'view_count': int_or_none(lesson.get('plays_count')),
|
'view_count': int_or_none(lesson.get('plays_count')),
|
||||||
'tags': try_get(lesson, lambda x: x['tag_list'], list),
|
'tags': try_get(lesson, lambda x: x['tag_list'], list),
|
||||||
|
'series': try_get(
|
||||||
|
lesson, lambda x: x['series']['title'], compat_str),
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue