mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 01:25:06 +00:00
[udemy:course] Skip non-video lectures
This commit is contained in:
parent
3f64379eda
commit
03caa463e7
1 changed files with 9 additions and 4 deletions
|
@ -193,12 +193,12 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
asset = lecture['asset']
|
asset = lecture['asset']
|
||||||
|
|
||||||
asset_type = asset.get('assetType') or asset.get('asset_type')
|
asset_type = asset.get('asset_type') or asset.get('assetType')
|
||||||
if asset_type != 'Video':
|
if asset_type != 'Video':
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Lecture %s is not a video' % lecture_id, expected=True)
|
'Lecture %s is not a video' % lecture_id, expected=True)
|
||||||
|
|
||||||
stream_url = asset.get('streamUrl') or asset.get('stream_url')
|
stream_url = asset.get('stream_url') or asset.get('streamUrl')
|
||||||
if stream_url:
|
if stream_url:
|
||||||
youtube_url = self._search_regex(
|
youtube_url = self._search_regex(
|
||||||
r'(https?://www\.youtube\.com/watch\?v=.*)', stream_url, 'youtube URL', default=None)
|
r'(https?://www\.youtube\.com/watch\?v=.*)', stream_url, 'youtube URL', default=None)
|
||||||
|
@ -206,7 +206,7 @@ def _real_extract(self, url):
|
||||||
return self.url_result(youtube_url, 'Youtube')
|
return self.url_result(youtube_url, 'Youtube')
|
||||||
|
|
||||||
video_id = asset['id']
|
video_id = asset['id']
|
||||||
thumbnail = asset.get('thumbnailUrl') or asset.get('thumbnail_url')
|
thumbnail = asset.get('thumbnail_url') or asset.get('thumbnailUrl')
|
||||||
duration = float_or_none(asset.get('data', {}).get('duration'))
|
duration = float_or_none(asset.get('data', {}).get('duration'))
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -325,7 +325,7 @@ def _real_extract(self, url):
|
||||||
'https://www.udemy.com/api-2.0/courses/%s/cached-subscriber-curriculum-items' % course_id,
|
'https://www.udemy.com/api-2.0/courses/%s/cached-subscriber-curriculum-items' % course_id,
|
||||||
course_id, 'Downloading course curriculum', query={
|
course_id, 'Downloading course curriculum', query={
|
||||||
'fields[chapter]': 'title,object_index',
|
'fields[chapter]': 'title,object_index',
|
||||||
'fields[lecture]': 'title',
|
'fields[lecture]': 'title,asset',
|
||||||
'page_size': '1000',
|
'page_size': '1000',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -334,6 +334,11 @@ def _real_extract(self, url):
|
||||||
for entry in response['results']:
|
for entry in response['results']:
|
||||||
clazz = entry.get('_class')
|
clazz = entry.get('_class')
|
||||||
if clazz == 'lecture':
|
if clazz == 'lecture':
|
||||||
|
asset = entry.get('asset')
|
||||||
|
if isinstance(asset, dict):
|
||||||
|
asset_type = asset.get('asset_type') or asset.get('assetType')
|
||||||
|
if asset_type != 'Video':
|
||||||
|
continue
|
||||||
lecture_id = entry.get('id')
|
lecture_id = entry.get('id')
|
||||||
if lecture_id:
|
if lecture_id:
|
||||||
entry = {
|
entry = {
|
||||||
|
|
Loading…
Reference in a new issue