Radiobrowser: Fix handling of request errors

This commit is contained in:
milaq 2019-08-14 16:06:07 +02:00
parent 1316bb65d0
commit c3866440fa

View file

@ -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") logging.error("Could not fetch data from Radiobrowser (%s)", response.status_code)
return None return {}
return response.json() return response.json()