diff --git a/unshackle/core/utilities.py b/unshackle/core/utilities.py index 3182326..17b7441 100644 --- a/unshackle/core/utilities.py +++ b/unshackle/core/utilities.py @@ -20,6 +20,7 @@ import requests from construct import ValidationError from langcodes import Language, closest_match from pymp4.parser import Box +from requests.adapters import HTTPAdapter from unidecode import unidecode from unshackle.core.cacher import Cacher @@ -241,7 +242,10 @@ def get_ip_info(session: Optional[requests.Session] = None) -> dict: If you provide a Requests Session with a Proxy, that proxies IP information is what will be returned. """ - return (session or requests.Session()).get("https://ipinfo.io/json").json() + request = session or requests.Session() + request.adapters["http://"] = HTTPAdapter(max_retries=3) + request.adapters["https://"] = HTTPAdapter(max_retries=3) + return request.get("https://ipinfo.io/json", timeout=1).json() def get_cached_ip_info(session: Optional[requests.Session] = None) -> Optional[dict]: