fix platzi
This commit is contained in:
parent
5014bd67c2
commit
6abc344f22
@ -104,50 +104,40 @@ class PlatziIE(PlatziBaseIE):
|
|||||||
lecture_id = self._match_id(url)
|
lecture_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, lecture_id)
|
webpage = self._download_webpage(url, lecture_id)
|
||||||
|
data_preloaded_state = self._parse_json(
|
||||||
data = self._parse_json(
|
self._search_regex((r'window.__PRELOADED_STATE__ = (.*)\<\/script'), webpage, 'client data'),
|
||||||
self._search_regex(
|
|
||||||
# client_data may contain "};" so that we have to try more
|
|
||||||
# strict regex first
|
|
||||||
(r'client_data\s*=\s*({.+?})\s*;\s*\n',
|
|
||||||
r'client_data\s*=\s*({.+?})\s*;'),
|
|
||||||
webpage, 'client data'),
|
|
||||||
lecture_id)
|
lecture_id)
|
||||||
|
|
||||||
material = data['initialState']['material']
|
# desc = data_preloaded_state['videoPlayer']['courseDescription']
|
||||||
desc = material['description']
|
title = data_preloaded_state['videoPlayer']['name']
|
||||||
title = desc['title']
|
duration = data_preloaded_state['videoPlayer']['duration']
|
||||||
|
servers = data_preloaded_state['videoPlayer']['video']['servers']
|
||||||
formats = []
|
formats = []
|
||||||
for server_id, server in material['videos'].items():
|
for server in servers.keys():
|
||||||
if not isinstance(server, dict):
|
|
||||||
continue
|
|
||||||
for format_id in ('hls', 'dash'):
|
for format_id in ('hls', 'dash'):
|
||||||
format_url = url_or_none(server.get(format_id))
|
server_json = servers[server]
|
||||||
if not format_url:
|
if 'hls' in server_json.keys():
|
||||||
continue
|
|
||||||
if format_id == 'hls':
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
format_url, lecture_id, 'mp4',
|
server_json['hls'], lecture_id, 'mp4',
|
||||||
entry_protocol='m3u8_native', m3u8_id=format_id,
|
entry_protocol='m3u8_native', m3u8_id=format_id,
|
||||||
note='Downloading %s m3u8 information' % server_id,
|
note='Downloading %s m3u8 information' % server_json['id'],
|
||||||
fatal=False))
|
fatal=False))
|
||||||
elif format_id == 'dash':
|
elif 'dash' in server_json.keys():
|
||||||
formats.extend(self._extract_mpd_formats(
|
formats.extend(self._extract_mpd_formats(
|
||||||
format_url, lecture_id, mpd_id=format_id,
|
server_json['dash'], lecture_id, mpd_id=format_id,
|
||||||
note='Downloading %s MPD manifest' % server_id,
|
note='Downloading %s MPD manifest' % server_json['id'],
|
||||||
fatal=False))
|
fatal=False))
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
content = str_or_none(desc.get('content'))
|
# content = str_or_none(data['videoPlayer']['content'])
|
||||||
description = (clean_html(compat_b64decode(content).decode('utf-8'))
|
# description = (clean_html(compat_b64decode(content).decode('utf-8'))
|
||||||
if content else None)
|
# if content else None)
|
||||||
duration = int_or_none(material.get('duration'), invscale=60)
|
duration = int_or_none(duration, invscale=60)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': lecture_id,
|
'id': lecture_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': '',
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
@ -186,10 +176,12 @@ class PlatziCourseIE(PlatziBaseIE):
|
|||||||
|
|
||||||
webpage = self._download_webpage(url, course_name)
|
webpage = self._download_webpage(url, course_name)
|
||||||
|
|
||||||
|
initialData = self._search_regex(
|
||||||
|
(r'window.initialData\s*=\s*({.+?})\s*;\s*\n', r'window.initialData\s*=\s*({.+?})\s*;'),
|
||||||
|
webpage, 'window.initialData')
|
||||||
props = self._parse_json(
|
props = self._parse_json(
|
||||||
self._search_regex(r'data\s*=\s*({.+?})\s*;', webpage, 'data'),
|
initialData,
|
||||||
course_name)['initialProps']
|
course_name)['initialState']
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for chapter_num, chapter in enumerate(props['concepts'], 1):
|
for chapter_num, chapter in enumerate(props['concepts'], 1):
|
||||||
if not isinstance(chapter, dict):
|
if not isinstance(chapter, dict):
|
||||||
|
Loading…
Reference in New Issue
Block a user