From c03f72b47c1d78222544f25304be75459094b3e3 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 25 Jan 2016 15:51:54 +0530 Subject: [PATCH] dont fail parsing parts of the pdf --- oml/media/pdf.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/oml/media/pdf.py b/oml/media/pdf.py index 3bf9de5..f32460b 100644 --- a/oml/media/pdf.py +++ b/oml/media/pdf.py @@ -131,7 +131,10 @@ def info(pdf): toc = parse_tableofcontents(pdfreader) if toc: data['tableofcontents'] = toc - info = pdfreader.getDocumentInfo() + try: + info = pdfreader.getDocumentInfo() + except: + info = None if info: for key in info: if info[key]: @@ -144,8 +147,10 @@ def info(pdf): data[key[1:].lower()] = value except: pass - - xmp = pdfreader.getXmpMetadata() + try: + xmp = pdfreader.getXmpMetadata() + except: + xmp = None if xmp: for key in dir(xmp): if key.startswith('dc_'):