Browse Source

Radiobrowser: Fix handling of request errors

milaq 5 năm trước cách đây
mục cha
commit
c3866440fa
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      ycast/radiobrowser.py

+ 3 - 2
ycast/radiobrowser.py

@@ -1,4 +1,5 @@
 import requests
+import logging
 
 import ycast.vtuner as vtuner
 
@@ -38,8 +39,8 @@ def request(url):
     headers = {'content-type': 'application/json', 'User-Agent': 'YCast'}
     response = requests.get('http://www.radio-browser.info/webservice/json/' + url, headers=headers)
     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()