mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-16 22:37:35 +00:00
Further improve extraction
* detect when login required * extract further metadata
This commit is contained in:
parent
0235e627b9
commit
1ce8590329
@ -7,12 +7,15 @@ from ..compat import (
|
|||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
|
dict_get,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
get_element_by_class,
|
get_element_by_class,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
parse_iso8601,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
strip_or_none,
|
strip_or_none,
|
||||||
try_get,
|
try_get,
|
||||||
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
urljoin,
|
urljoin,
|
||||||
)
|
)
|
||||||
@ -113,6 +116,13 @@ class PlatziIE(PlatziBaseIE):
|
|||||||
video_player = try_get(data_preloaded_state, lambda x: x['videoPlayer'], dict)
|
video_player = try_get(data_preloaded_state, lambda x: x['videoPlayer'], dict)
|
||||||
title = strip_or_none(video_player.get('name')) or self._og_search_title(webpage)
|
title = strip_or_none(video_player.get('name')) or self._og_search_title(webpage)
|
||||||
servers = try_get(video_player, lambda x: x['video']['servers'], dict) or {}
|
servers = try_get(video_player, lambda x: x['video']['servers'], dict) or {}
|
||||||
|
if not servers and try_get(video_player, lambda x: x['blockedInfo']['blocked']):
|
||||||
|
why = video_player['blockedInfo'].get('type') or 'unspecified'
|
||||||
|
if why == 'unlogged':
|
||||||
|
self.raise_login_required()
|
||||||
|
raise ExtractorError(
|
||||||
|
'All video formats blocked because ' + why, expected=True)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
headers['Referer'] = url
|
headers['Referer'] = url
|
||||||
extractions = {
|
extractions = {
|
||||||
@ -137,13 +147,22 @@ class PlatziIE(PlatziBaseIE):
|
|||||||
for f in formats:
|
for f in formats:
|
||||||
f.setdefault('http_headers', {})['Referer'] = headers['Referer']
|
f.setdefault('http_headers', {})['Referer'] = headers['Referer']
|
||||||
|
|
||||||
|
def categories():
|
||||||
|
cat = strip_or_none(video_player.get('courseCategory'))
|
||||||
|
if cat:
|
||||||
|
return [cat]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': lecture_id,
|
'id': lecture_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': self._og_search_description(webpage),
|
'description': clean_html(video_player.get('courseDescription')) or self._og_search_description(webpage),
|
||||||
'thumbnail': self._og_search_thumbnail(webpage),
|
|
||||||
'duration': int_or_none(video_player.get('duration'), invscale=60),
|
'duration': int_or_none(video_player.get('duration'), invscale=60),
|
||||||
'creator': clean_html(get_element_by_class('TeacherDetails-name', webpage)),
|
'thumbnail': url_or_none(video_player.get('thumbnail')) or self._og_search_thumbnail(webpage),
|
||||||
|
'timestamp': parse_iso8601(dict_get(video_player, ('dataModified', 'dataPublished'))),
|
||||||
|
'creator': strip_or_none(video_player.get('teacherName')) or clean_html(get_element_by_class('TeacherDetails-name', webpage)),
|
||||||
|
'comment_count': int_or_none(video_player.get('commentsNumber')),
|
||||||
|
'categories': categories(),
|
||||||
|
'series': strip_or_none(video_player.get('courseTitle')) or None,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user