summary: fix bitstamp api 404

This commit is contained in:
Michael Schmoock
2020-11-16 12:43:14 +01:00
committed by Christian Decker
parent 5d274f67c4
commit 2a798864f8

View File

@@ -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')