diff options
Diffstat (limited to 'newspipe/controllers/icon.py')
-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): |