Open PeterBremer-at-Philips opened 2 years ago
A solution which works for me is to add verify=False in function called at line 22 of radios.py:
def get(self, url, **kwargs):
resp = self._session.get(url, headers=self._headers,
verify=False,
params=kwargs)
if resp.status_code == 200:
return resp.json()
return resp.raise_for_status()
@PeterBremer-Ph I have no time to investigate what is going on, it seems to be a problem with the upstream servers. Anyway, following your suggestion, as soon as possible I will add a way to disable ssl directly in the main class.
rb = RadioBrowser(ssl=False)
Great! Perhaps than also make sure that the following is or will be added (optionally?): from requests.packages import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Done, changed radios.py (version 1.0.2)
from requests.packages import urllib3
class Request: def __init__(self, headers=None, session=None, ssl_verify=True): self._headers = headers self._session = self._init_session(session) self.ssl_verify = ssl_verify
... def get(self, url, kwargs): resp = self._session.get(url, headers=self._headers, verify=self.ssl_verify,** params=kwargs) if resp.status_code == 200: return resp.json() return resp.raise_for_status()
Radiobrowser:
def __init__(self, session=None, ssl_verify=True, diswarn=True, kwargs): if diswarn and not ssl_verify: urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) self.base_url = pick_base_url() self._fmt = 'json' self.client = Request(headers=self.headers, session=session, ssl_verify=ssl_verify**)
The initial tests as published, just do not work: from pyradios import RadioBrowser rb = RadioBrowser() rb.search(name="BBC Radio 1", name_exact=True)
Gives SSLError: HTTPSConnectionPool(host='at1.api.radio-browser.info', port=443): Max retries exceeded with url: /json/stations/search?name=BBC+Radio+1&nameExact=true (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))