mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-15 22:24:32 +01:00
Merge pull request #4590 from derrotebaron/master
[archiveorg] most metadata fields are optional
This commit is contained in:
commit
0fa629d05b
@ -25,6 +25,12 @@ class ArchiveOrgIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_optional_metadata(self, data, field):
|
||||||
|
try:
|
||||||
|
return data['metadata'][field][0]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
@ -33,10 +39,12 @@ class ArchiveOrgIE(InfoExtractor):
|
|||||||
json_data = self._download_webpage(json_url, video_id)
|
json_data = self._download_webpage(json_url, video_id)
|
||||||
data = json.loads(json_data)
|
data = json.loads(json_data)
|
||||||
|
|
||||||
title = data['metadata']['title'][0]
|
title = self.get_optional_metadata(data, 'title')
|
||||||
description = data['metadata']['description'][0]
|
description = self.get_optional_metadata(data, 'description')
|
||||||
uploader = data['metadata']['creator'][0]
|
uploader = self.get_optional_metadata(data, 'creator')
|
||||||
upload_date = unified_strdate(data['metadata']['date'][0])
|
upload_date = self.get_optional_metadata(data, 'date')
|
||||||
|
if upload_date:
|
||||||
|
upload_date = unified_strdate(upload_date)
|
||||||
|
|
||||||
formats = [
|
formats = [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user