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