From afbf71aa0806b9e4df6d07742122952d99a18db9 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 9 Jan 2023 22:46:59 -0800 Subject: [PATCH] allow maxBitRate=0 as some clients set it as the default --- pysonic/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pysonic/api.py b/pysonic/api.py index b3dea97..c17745f 100644 --- a/pysonic/api.py +++ b/pysonic/api.py @@ -189,8 +189,9 @@ class PysonicSubsonicApi(object): @cherrypy.expose def stream_view(self, id, maxBitRate="256", **kwargs): - maxBitRate = int(maxBitRate) - assert maxBitRate >= 32 and maxBitRate <= 320 + maxBitRate = int(maxBitRate) or 256 + if maxBitRate < 32 or maxBitRate > 320: + raise cherrypy.HTTPError(400, message=f"invalid maxBitRate: {maxBitRate}. Must be between 32 and 320.") song = self.db.get_songs(id=int(id))[0] fpath = os.path.join(song["root"], song["file"]) media_bitrate = song.get("bitrate") / 1024 if song.get("bitrate") else 320