catch http errors when fetching images

This commit is contained in:
Ed Summers
2020-11-24 21:45:10 +00:00
parent fb914c7510
commit 29f416d7a4
2 changed files with 13 additions and 9 deletions

View File

@ -164,6 +164,7 @@ def collect_images(entry, generator=None):
for u in urls) for u in urls)
images = [] images = []
for url in urls: for url in urls:
try:
resp = http.request('GET', url, preload_content=False) resp = http.request('GET', url, preload_content=False)
if resp.headers['content-type'].startswith(("image/", "video/")): if resp.headers['content-type'].startswith(("image/", "video/")):
images.append(resp) images.append(resp)
@ -172,6 +173,9 @@ def collect_images(entry, generator=None):
break break
else: else:
resp.release_conn() resp.release_conn()
except urllib3.exceptions.HTTPError:
# ignore http errors, maybe they should be logged?
pass
return images return images

View File

@ -5,7 +5,7 @@ with open("README.md") as f:
setup( setup(
name='feediverse', name='feediverse',
version='0.1.3', version='0.1.4',
python_requires='>=3.3', python_requires='>=3.3',
url='https://github.com/edsu/feediverse', url='https://github.com/edsu/feediverse',
author='Ed Summers', author='Ed Summers',