allow maxBitRate=0 as some clients set it as the default #2

Merged
dave merged 1 commits from dpedu/maxbitrate-default into master 2023-01-09 23:12:12 -08:00
1 changed files with 3 additions and 2 deletions
Showing only changes of commit afbf71aa08 - Show all commits

View File

@ -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