catche certificate errors for thumbnails
parent
ac8741de5f
commit
22b06107bb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue