From 2a798864f8c1731a6217ca4ebcd01b4b41d1c6dc Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Mon, 16 Nov 2020 12:43:14 +0100 Subject: [PATCH] summary: fix bitstamp api 404 --- summary/summary.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/summary/summary.py b/summary/summary.py index ec1b2ca..90504e9 100755 --- a/summary/summary.py +++ b/summary/summary.py @@ -61,7 +61,14 @@ class PriceThread(threading.Thread): def run(self): while True: try: - r = requests.get('https://www.bitstamp.net/api/v2/ticker/BTC{}'.format(plugin.currency), proxies=self.proxies) + # NOTE: Bitstamp has a DNS/Proxy issues that can return 404 + # Workaround: retry up to 5 times with a delay + for _ in range(5): + r = requests.get('https://www.bitstamp.net/api/v2/ticker/BTC{}'.format(plugin.currency), proxies=self.proxies) + if not r.status_code == 200: + time.sleep(1) + continue + break plugin.fiat_per_btc = float(r.json()['last']) except Exception as ex: plugin.log("[PriceThread] " + str(ex), 'warn')