diff options
author | Sergey M. <dstftw@gmail.com> | 2014-12-29 01:53:59 +0600 |
---|---|---|
committer | Sergey M. <dstftw@gmail.com> | 2014-12-29 01:53:59 +0600 |
commit | 0fa629d05bb521133f808b373fd92c9835275e48 (patch) | |
tree | feaaceeb68c18609b50349abc6bb1664bfbed7fc /youtube_dl/extractor/archiveorg.py | |
parent | 5a1840305746b7242c8d8307e945b9f889603a8b (diff) | |
parent | ff7a07d5c4d260a8b27fa7bf523c405725f9cb20 (diff) |
Merge pull request #4590 from derrotebaron/master
[archiveorg] most metadata fields are optional
Diffstat (limited to 'youtube_dl/extractor/archiveorg.py')
-rw-r--r-- | youtube_dl/extractor/archiveorg.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/youtube_dl/extractor/archiveorg.py b/youtube_dl/extractor/archiveorg.py index 34ce8429b..ba94b5454 100644 --- a/youtube_dl/extractor/archiveorg.py +++ b/youtube_dl/extractor/archiveorg.py @@ -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): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') @@ -33,10 +39,12 @@ class ArchiveOrgIE(InfoExtractor): json_data = self._download_webpage(json_url, video_id) data = json.loads(json_data) - title = data['metadata']['title'][0] - description = data['metadata']['description'][0] - uploader = data['metadata']['creator'][0] - upload_date = unified_strdate(data['metadata']['date'][0]) + title = self.get_optional_metadata(data, 'title') + description = self.get_optional_metadata(data, 'description') + uploader = self.get_optional_metadata(data, 'creator') + upload_date = self.get_optional_metadata(data, 'date') + if upload_date: + upload_date = unified_strdate(upload_date) formats = [ { |