catch PDFNotImplementedErrors
This commit is contained in:
parent
5fbeedd76b
commit
05669229c4
@ -101,7 +101,11 @@ def download(phenny, input, verbose=True):
|
|||||||
data = response.content
|
data = response.content
|
||||||
|
|
||||||
if "pdf" in response.headers["content-type"]:
|
if "pdf" in response.headers["content-type"]:
|
||||||
|
try:
|
||||||
data = pdfparanoia.scrub(StringIO(data))
|
data = pdfparanoia.scrub(StringIO(data))
|
||||||
|
except:
|
||||||
|
# this is to avoid a PDFNotImplementedError
|
||||||
|
pass
|
||||||
|
|
||||||
# grr..
|
# grr..
|
||||||
title = title.encode("ascii", "ignore")
|
title = title.encode("ascii", "ignore")
|
||||||
@ -256,7 +260,11 @@ def download_url(url):
|
|||||||
path = os.path.join("/home/bryan/public_html/papers2/paperbot/", title + extension)
|
path = os.path.join("/home/bryan/public_html/papers2/paperbot/", title + extension)
|
||||||
|
|
||||||
if extension in [".pdf", "pdf"]:
|
if extension in [".pdf", "pdf"]:
|
||||||
|
try:
|
||||||
content = pdfparanoia.scrub(StringIO(content))
|
content = pdfparanoia.scrub(StringIO(content))
|
||||||
|
except:
|
||||||
|
# this is to avoid a PDFNotImplementedError
|
||||||
|
pass
|
||||||
|
|
||||||
file_handler = open(path, "w")
|
file_handler = open(path, "w")
|
||||||
file_handler.write(content)
|
file_handler.write(content)
|
||||||
|
Loading…
Reference in New Issue
Block a user