1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-26 04:02:11 +00:00

[nytimes] Tolerate missing metadata (Closes #8952)

This commit is contained in:
Sergey M․ 2016-03-24 23:28:24 +06:00
parent 369e7e3ff0
commit 993271da0a

View file

@ -18,8 +18,9 @@ class NYTimesBaseIE(InfoExtractor):
description = video_data.get('summary') description = video_data.get('summary')
duration = float_or_none(video_data.get('duration'), 1000) duration = float_or_none(video_data.get('duration'), 1000)
uploader = video_data['byline'] uploader = video_data.get('byline')
timestamp = parse_iso8601(video_data['publication_date'][:-8]) publication_date = video_data.get('publication_date')
timestamp = parse_iso8601(publication_date[:-8]) if publication_date else None
def get_file_size(file_size): def get_file_size(file_size):
if isinstance(file_size, int): if isinstance(file_size, int):
@ -37,7 +38,7 @@ class NYTimesBaseIE(InfoExtractor):
'width': int_or_none(video.get('width')), 'width': int_or_none(video.get('width')),
'height': int_or_none(video.get('height')), 'height': int_or_none(video.get('height')),
'filesize': get_file_size(video.get('fileSize')), 'filesize': get_file_size(video.get('fileSize')),
} for video in video_data['renditions'] } for video in video_data['renditions'] if video.get('url')
] ]
self._sort_formats(formats) self._sort_formats(formats)
@ -46,7 +47,7 @@ class NYTimesBaseIE(InfoExtractor):
'url': 'http://www.nytimes.com/%s' % image['url'], 'url': 'http://www.nytimes.com/%s' % image['url'],
'width': int_or_none(image.get('width')), 'width': int_or_none(image.get('width')),
'height': int_or_none(image.get('height')), 'height': int_or_none(image.get('height')),
} for image in video_data['images'] } for image in video_data.get('images', []) if image.get('url')
] ]
return { return {