mirror of
https://source.netsyms.com/Mirrors/youtube-dl
synced 2024-11-03 03:40:20 +00:00
[nytimes] Improve file size extraction
This commit is contained in:
parent
3b1dfc0f2f
commit
6515778305
@ -38,6 +38,14 @@ class NYTimesIE(InfoExtractor):
|
|||||||
uploader = video_data['byline']
|
uploader = video_data['byline']
|
||||||
timestamp = parse_iso8601(video_data['publication_date'][:-8])
|
timestamp = parse_iso8601(video_data['publication_date'][:-8])
|
||||||
|
|
||||||
|
def get_file_size(file_size):
|
||||||
|
if isinstance(file_size, int):
|
||||||
|
return file_size
|
||||||
|
elif isinstance(file_size, dict):
|
||||||
|
return int(file_size.get('value', 0))
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
formats = [
|
formats = [
|
||||||
{
|
{
|
||||||
'url': video['url'],
|
'url': video['url'],
|
||||||
@ -45,7 +53,7 @@ class NYTimesIE(InfoExtractor):
|
|||||||
'vcodec': video['video_codec'],
|
'vcodec': video['video_codec'],
|
||||||
'width': video['width'],
|
'width': video['width'],
|
||||||
'height': video['height'],
|
'height': video['height'],
|
||||||
'filesize': video['fileSize'],
|
'filesize': get_file_size(video['fileSize']),
|
||||||
} for video in video_data['renditions']
|
} for video in video_data['renditions']
|
||||||
]
|
]
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
Loading…
Reference in New Issue
Block a user