Explorar o código

Radiobrowser: Fix handling of request errors

milaq %!s(int64=5) %!d(string=hai) anos
pai
achega
c3866440fa
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      ycast/radiobrowser.py

+ 3 - 2
ycast/radiobrowser.py

@@ -1,4 +1,5 @@
 import requests
 import requests
+import logging
 
 
 import ycast.vtuner as vtuner
 import ycast.vtuner as vtuner
 
 
@@ -38,8 +39,8 @@ def request(url):
     headers = {'content-type': 'application/json', 'User-Agent': 'YCast'}
     headers = {'content-type': 'application/json', 'User-Agent': 'YCast'}
     response = requests.get('http://www.radio-browser.info/webservice/json/' + url, headers=headers)
     response = requests.get('http://www.radio-browser.info/webservice/json/' + url, headers=headers)
     if response.status_code != 200:
     if response.status_code != 200:
-        print("error")
-        return None
+        logging.error("Could not fetch data from Radiobrowser (%s)", response.status_code)
+        return {}
     return response.json()
     return response.json()