diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-30 21:50:27 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-30 21:50:27 +0200 |
commit | 1c5189ab844f71cc65dcf5f1f214e0793976ff50 (patch) | |
tree | a90cb18704d8b62a918855272f036cd145e81aad /newspipe | |
parent | removed debug log (diff) | |
download | newspipe-1c5189ab844f71cc65dcf5f1f214e0793976ff50.tar.gz newspipe-1c5189ab844f71cc65dcf5f1f214e0793976ff50.tar.bz2 newspipe-1c5189ab844f71cc65dcf5f1f214e0793976ff50.zip |
catch exception with trying to fetch feed icon with requests
Diffstat (limited to 'newspipe')
-rw-r--r-- | newspipe/controllers/icon.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/newspipe/controllers/icon.py b/newspipe/controllers/icon.py index d5dd7fe6..b0fad5ac 100644 --- a/newspipe/controllers/icon.py +++ b/newspipe/controllers/icon.py @@ -2,6 +2,7 @@ import base64 import requests +from newspipe.lib.utils import newspipe_get from newspipe.models import Icon from .abstract import AbstractController @@ -13,14 +14,17 @@ class IconController(AbstractController): def _build_from_url(self, attrs): if "url" in attrs and "content" not in attrs: - resp = requests.get(attrs["url"], verify=False) - attrs.update( - { - "url": resp.url, - "mimetype": resp.headers.get("content-type", None), - "content": base64.b64encode(resp.content).decode("utf8"), - } - ) + try: + resp = newspipe_get(attrs["url"], timeout=5) + attrs.update( + { + "url": resp.url, + "mimetype": resp.headers.get("content-type", None), + "content": base64.b64encode(resp.content).decode("utf8"), + } + ) + except requests.exceptions.ConnectionError: + pass return attrs def create(self, **attrs): |