metadata: Do not raise an exception if a PDF file has empty metadata

Check explicitly for `info is None`, since an empty dict also evaluates
to false. Otherwise it raises an exception when there is no metadata,
and prevents from generating the cover.

This has started to happen recently with some arxiv PDF's, like this
one: https://arxiv.org/pdf/1605.02391v2
This commit is contained in:
Abdo Roig-Maranges 2016-09-08 16:49:27 +02:00
parent 62a5d9c4d2
commit 432aa7e21d

View File

@ -95,7 +95,7 @@ def get_metadata(stream, cover=True):
raw = f.read().strip()
if raw:
prints(raw)
if not info:
if info is None:
raise ValueError('Could not read info dict from PDF')
covpath = os.path.join(pdfpath, 'cover.jpg')
cdata = None