From 706e181358548825677dc6423d464770e240c198 Mon Sep 17 00:00:00 2001 From: Doctor Date: Wed, 19 Apr 2023 18:44:09 +0200 Subject: [PATCH] fix sources parsing if there is only one source --- plugins/icecast/icecast2_stats_ | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/icecast/icecast2_stats_ b/plugins/icecast/icecast2_stats_ index 6d333880..a714526a 100755 --- a/plugins/icecast/icecast2_stats_ +++ b/plugins/icecast/icecast2_stats_ @@ -108,9 +108,17 @@ def _get_json_statistics(): def get_sources(): sources = [] - for source in _get_json_statistics()["icestats"]["source"]: + if type(_get_json_statistics()["icestats"]["source"]) == dict: + source = _get_json_statistics()["icestats"]["source"] path_name = source["listenurl"].split("/")[-1] sources.append({"name": path_name, + "fieldname": clean_fieldname(path_name), + "listeners": source["listeners"], + "duration_days": get_iso8601_age_days(source["stream_start_iso8601"])}) + else: + for source in _get_json_statistics()["icestats"]["source"]: + path_name = source["listenurl"].split("/")[-1] + sources.append({"name": path_name, "fieldname": clean_fieldname(path_name), "listeners": source["listeners"], "duration_days": get_iso8601_age_days(source["stream_start_iso8601"])})