mirror of
https://github.com/l1ving/youtube-dl
synced 2025-01-23 17:22:52 +08:00
Removed undocumented variable "skill_level" and added checks to prevent wrong input data from crashing the program.
This commit is contained in:
parent
7bd772a69f
commit
89ca9f8f67
@ -309,26 +309,22 @@ class LyndaCourseIE(LyndaBaseIE):
|
|||||||
unaccessible_videos = 0
|
unaccessible_videos = 0
|
||||||
entries = []
|
entries = []
|
||||||
|
|
||||||
templateVars = {}
|
template_vars = {}
|
||||||
date = course.get('DateReleasedUtc')
|
date = course.get('DateReleasedUtc')
|
||||||
if date:
|
if isinstance(date, str) and len(date) > 10:
|
||||||
date = date[6:10] + date[0:2] + date[3:5]
|
date = date[6:10] + date[0:2] + date[3:5]
|
||||||
templateVars.update({'release_date': date})
|
template_vars.update({'release_date': date})
|
||||||
|
|
||||||
authors = course.get("Authors")
|
authors = course.get("Authors")
|
||||||
if authors:
|
if authors and isinstance(authors, list):
|
||||||
authorString = ''
|
author_string = ''
|
||||||
for author in authors:
|
for author in authors:
|
||||||
authorString += author.get("Fullname") + ", "
|
if isinstance(author, dict):
|
||||||
authorString = authorString[:-2]
|
name = author.get("Fullname")
|
||||||
templateVars.update({'creator': authorString})
|
if isinstance(name, str) and name:
|
||||||
|
author_string += name + ", "
|
||||||
tags = course.get('Tags')
|
author_string = author_string[:-2]
|
||||||
if tags:
|
template_vars.update({'creator': author_string})
|
||||||
for tag in tags:
|
|
||||||
if tag.get('TypeName') == 'Level':
|
|
||||||
templateVars.update({'skill_level': tag.get('Name')})
|
|
||||||
|
|
||||||
# Might want to extract videos right here from video['Formats'] as it seems 'Formats' is not provided
|
# Might want to extract videos right here from video['Formats'] as it seems 'Formats' is not provided
|
||||||
# by single video API anymore
|
# by single video API anymore
|
||||||
|
|
||||||
@ -347,7 +343,7 @@ class LyndaCourseIE(LyndaBaseIE):
|
|||||||
'chapter_number': int_or_none(chapter.get('ChapterIndex')),
|
'chapter_number': int_or_none(chapter.get('ChapterIndex')),
|
||||||
'chapter_id': compat_str(chapter.get('ID')),
|
'chapter_id': compat_str(chapter.get('ID')),
|
||||||
}
|
}
|
||||||
entry.update(templateVars)
|
entry.update(template_vars)
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
|
|
||||||
if unaccessible_videos > 0:
|
if unaccessible_videos > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user