fixed freezing if suddenly it was not possible to get an image

This commit is contained in:
Random 2024-05-03 13:10:19 +03:00
parent 3b00e730f6
commit 49c9a84f93

View file

@ -93,9 +93,12 @@ def load_image(path):
domain = '.'.join(parse.urlparse(url).netloc.split(".")[-2:])
img = exif_rotated_image()
if domain == 'pinterest.com':
page_data = request.urlopen(url).read()
root = etree.HTML(page_data)
url = root.xpath("//img")[0].get('src')
try:
page_data = request.urlopen(url).read()
root = etree.HTML(page_data)
url = root.xpath("//img")[0].get('src')
except Exception as e:
logger.debug(f'Pinterest image download failed: {e}')
try:
imgdata = request.urlopen(url).read()
except URLError as e: