Catch pyPDF2 key error
This commit is contained in:
parent
c1b4d3154d
commit
e9c2dc90d5
@ -20,8 +20,9 @@ def get_pdf_information(mediafile):
|
|||||||
try:
|
try:
|
||||||
pdf = PdfFileReader(mediafile)
|
pdf = PdfFileReader(mediafile)
|
||||||
result["pages"] = pdf.getNumPages()
|
result["pages"] = pdf.getNumPages()
|
||||||
except PdfReadError:
|
except (PdfReadError, KeyError):
|
||||||
# File could be encrypted but not be detected by PyPDF.
|
# File could be encrypted but not be detected by PyPDF.
|
||||||
|
# KeyError: https://github.com/mstamy2/PyPDF2/issues/353 Very rare to occur, but do not raise a 500
|
||||||
result["pages"] = 0
|
result["pages"] = 0
|
||||||
result["encrypted"] = True
|
result["encrypted"] = True
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user