From d7ac887f939bbe2ac3d47e6e956b54d8a1124283 Mon Sep 17 00:00:00 2001 From: Canuma Date: Tue, 23 Nov 2021 20:55:11 +0100 Subject: [PATCH 1/3] bugfix: added exception handling for server.get_station_by_id --- ycast/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ycast/server.py b/ycast/server.py index 6d963da..a3c1c13 100644 --- a/ycast/server.py +++ b/ycast/server.py @@ -106,8 +106,11 @@ def get_station_by_id(stationid, additional_info=False): elif station_id_prefix == radiobrowser.ID_PREFIX: station = radiobrowser.get_station_by_id(generic.get_stationid_without_prefix(stationid)) if additional_info: - station.get_playable_url() - return station + try: + station.get_playable_url() + return station + except AttributeError: + return None return None From e02cd6a85ffec9595e6a06aa8aecd336f98fbdd1 Mon Sep 17 00:00:00 2001 From: Canuma Date: Wed, 24 Nov 2021 07:29:47 +0100 Subject: [PATCH 2/3] Revert "bugfix: added exception handling for server.get_station_by_id" This reverts commit d7ac887f939bbe2ac3d47e6e956b54d8a1124283. --- ycast/server.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ycast/server.py b/ycast/server.py index a3c1c13..6d963da 100644 --- a/ycast/server.py +++ b/ycast/server.py @@ -106,11 +106,8 @@ def get_station_by_id(stationid, additional_info=False): elif station_id_prefix == radiobrowser.ID_PREFIX: station = radiobrowser.get_station_by_id(generic.get_stationid_without_prefix(stationid)) if additional_info: - try: - station.get_playable_url() - return station - except AttributeError: - return None + station.get_playable_url() + return station return None From 87ef25f4824a46a8f7b3dfbfb6cc589a54af513f Mon Sep 17 00:00:00 2001 From: Canuma Date: Wed, 24 Nov 2021 07:32:20 +0100 Subject: [PATCH 3/3] Sorry, fix broke actually more than it fixed. Adding AttributeError in radiobrowser.get_playable_url exception should fix that. --- ycast/radiobrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ycast/radiobrowser.py b/ycast/radiobrowser.py index fa50541..b2418dd 100644 --- a/ycast/radiobrowser.py +++ b/ycast/radiobrowser.py @@ -42,7 +42,7 @@ def get_playable_url(self): try: playable_url_json = request('url/' + generic.get_stationid_without_prefix(self.id))[0] self.url = playable_url_json['url'] - except (IndexError, KeyError): + except (IndexError, KeyError,AttributeError): logging.error("Could not retrieve first playlist item for station with id '%s'", self.id)