Don't log MyRadio API keys
This commit is contained in:
parent
7912b2c697
commit
1bd5779b8a
1 changed files with 25 additions and 5 deletions
|
@ -94,12 +94,20 @@ class MyRadioAPI:
|
||||||
self._logException("Invalid API version. Request not sent.")
|
self._logException("Invalid API version. Request not sent.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
url_without_api_key = url
|
||||||
|
|
||||||
if "?" in url:
|
if "?" in url:
|
||||||
url += "&api_key={}".format(self.config.get()["myradio_api_key"])
|
url += "&api_key={}".format(self.config.get()["myradio_api_key"])
|
||||||
|
url_without_api_key += "&api_key=REDACTED"
|
||||||
else:
|
else:
|
||||||
url += "?api_key={}".format(self.config.get()["myradio_api_key"])
|
url += "?api_key={}".format(self.config.get()["myradio_api_key"])
|
||||||
|
url_without_api_key += "?api_key=REDACTED"
|
||||||
|
|
||||||
self._log("Requesting API V2 URL with method {}: {}".format(method, url))
|
self._log(
|
||||||
|
"Requesting API V2 URL with method {}: {}".format(
|
||||||
|
method, url_without_api_key
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
request = None
|
request = None
|
||||||
try:
|
try:
|
||||||
|
@ -107,7 +115,9 @@ class MyRadioAPI:
|
||||||
request = await self.async_call(url, method="GET", timeout=timeout)
|
request = await self.async_call(url, method="GET", timeout=timeout)
|
||||||
elif method == "POST":
|
elif method == "POST":
|
||||||
self._log("POST data: {}".format(data))
|
self._log("POST data: {}".format(data))
|
||||||
request = await self.async_call(url, data=data, method="POST", timeout=timeout)
|
request = await self.async_call(
|
||||||
|
url, data=data, method="POST", timeout=timeout
|
||||||
|
)
|
||||||
elif method == "PUT":
|
elif method == "PUT":
|
||||||
request = await self.async_call(url, method="PUT", timeout=timeout)
|
request = await self.async_call(url, method="PUT", timeout=timeout)
|
||||||
else:
|
else:
|
||||||
|
@ -131,12 +141,20 @@ class MyRadioAPI:
|
||||||
self._logException("Invalid API version. Request not sent.")
|
self._logException("Invalid API version. Request not sent.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
url_without_api_key = url
|
||||||
|
|
||||||
if "?" in url:
|
if "?" in url:
|
||||||
url += "&api_key={}".format(self.config.get()["myradio_api_key"])
|
url += "&api_key={}".format(self.config.get()["myradio_api_key"])
|
||||||
|
url_without_api_key += "&api_key=REDACTED"
|
||||||
else:
|
else:
|
||||||
url += "?api_key={}".format(self.config.get()["myradio_api_key"])
|
url += "?api_key={}".format(self.config.get()["myradio_api_key"])
|
||||||
|
url_without_api_key += "?api_key=REDACTED"
|
||||||
|
|
||||||
self._log("Requesting API V2 URL with method {}: {}".format(method, url))
|
self._log(
|
||||||
|
"Requesting API V2 URL with method {}: {}".format(
|
||||||
|
method, url_without_api_key
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
request = None
|
request = None
|
||||||
if method == "GET":
|
if method == "GET":
|
||||||
|
@ -209,7 +227,9 @@ class MyRadioAPI:
|
||||||
|
|
||||||
# Audio Library
|
# Audio Library
|
||||||
|
|
||||||
async def get_filename(self, item: PlanItem, did_download: bool = False, redownload=False):
|
async def get_filename(
|
||||||
|
self, item: PlanItem, did_download: bool = False, redownload=False
|
||||||
|
):
|
||||||
format = "mp3" # TODO: Maybe we want this customisable?
|
format = "mp3" # TODO: Maybe we want this customisable?
|
||||||
if item.trackid:
|
if item.trackid:
|
||||||
itemType = "track"
|
itemType = "track"
|
||||||
|
@ -317,7 +337,7 @@ class MyRadioAPI:
|
||||||
async def get_playlist_aux_items(self, library_id: str):
|
async def get_playlist_aux_items(self, library_id: str):
|
||||||
# Sometimes they have "aux-<ID>", we only need the index.
|
# Sometimes they have "aux-<ID>", we only need the index.
|
||||||
if library_id.index("-") > -1:
|
if library_id.index("-") > -1:
|
||||||
library_id = library_id[library_id.index("-") + 1:]
|
library_id = library_id[library_id.index("-") + 1 :]
|
||||||
|
|
||||||
url = "/nipswebPlaylist/{}/items".format(library_id)
|
url = "/nipswebPlaylist/{}/items".format(library_id)
|
||||||
request = await self.async_api_call(url)
|
request = await self.async_api_call(url)
|
||||||
|
|
Loading…
Reference in a new issue