catche certificate errors for thumbnails

pull/94/head
eric 2020-04-29 21:19:48 -04:00
parent ac8741de5f
commit 22b06107bb
1 changed files with 6 additions and 5 deletions

View File

@ -1,10 +1,11 @@
import logging
import math
import re
import unicodedata
import uuid
from decimal import Decimal
import unicodedata
from ssl import CertificateError
from urllib.parse import urlparse
import requests
@ -891,7 +892,7 @@ class Edition(models.Model):
im = get_thumbnail(self.cover_image, 'x550', crop='noop', quality=95)
if im.exists():
return im.url
except (IOError, OSError):
except (IOError, OSError, CertificateError):
pass
elif self.googlebooks_id:
url = "https://encrypted.google.com/books?id=%s&printsec=frontcover&img=1&zoom=0" % self.googlebooks_id
@ -902,7 +903,7 @@ class Edition(models.Model):
im = get_thumbnail(url, 'x550', crop='noop', quality=95)
if im.exists():
return im.url
except (IOError, OSError):
except (IOError, OSError, CertificateError):
pass
return ''
@ -913,7 +914,7 @@ class Edition(models.Model):
im = get_thumbnail(self.cover_image, 'x80', crop='noop', quality=95)
if im.exists():
return im.url
except (IOError, OSError):
except (IOError, OSError, CertificateError):
pass
if self.googlebooks_id:
return "https://encrypted.google.com/books?id=%s&printsec=frontcover&img=1&zoom=5" % self.googlebooks_id
@ -926,7 +927,7 @@ class Edition(models.Model):
im = get_thumbnail(self.cover_image, '128', crop='noop', quality=95)
if im.exists():
return im.url
except (IOError, OSError):
except (IOError, OSError, CertificateError):
pass
if self.googlebooks_id:
return "https://encrypted.google.com/books?id=%s&printsec=frontcover&img=1&zoom=1" % self.googlebooks_id