diff --git a/configuration.default.ini b/configuration.default.ini index cd520af..85d83fe 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -32,6 +32,8 @@ comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. # default volume from 0 to 1. volume = 0.1 stereo = True +# bandwidth used by the bot +bandwidth = 96000 # playback mode should be one of "one-shot", "repeat", "random", "autoplay" playback_mode = one-shot autoplay_length = 5 diff --git a/configuration.example.ini b/configuration.example.ini index a56a2a8..f969f71 100644 --- a/configuration.example.ini +++ b/configuration.example.ini @@ -49,6 +49,11 @@ port = 64738 # This option will be overridden by value in the database. #volume = 0.1 +# 'bandwidth' is the number of bits per second used by the bot when streaming audio. Enabling this +# option will allow you to set it higher than the default value. If the value exceeds the servers +# bitrate, the bitrate used by the bot will match the servers. +#bandwidth = 200000 + # 'playback_mode' defined the playback mode of the bot. # it should be one of "one-shot" (remove item once played), "repeat" (looping through the playlist), # or "random" (randomize the playlist), "autoplay" (randomly grab something from the music library). diff --git a/entrypoint.sh b/entrypoint.sh index c4ec935..5e8b9dc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,6 +41,10 @@ if [ -n "$BAM_VERBOSE" ]; then command+=( "--verbose" ) fi +if [ -n "$BAM_BANDWIDTH" ]; then + command+=( "--bandwidth" "$BAM_BANDWIDTH") +fi + if [ -n "$BAM_CONFIG_file" ]; then if [ ! -f "$BAM_CONFIG_file" ]; then cp "/botamusique/configuration.example.ini" "$BAM_CONFIG_file" diff --git a/mumbleBot.py b/mumbleBot.py index b2a197e..1a46c2a 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -108,6 +108,11 @@ class MumbleBot: else: self.username = var.config.get("bot", "username") + if args.bandwidth: + self.bandwidth = args.bandwidth + else: + self.bandwidth = var.config.getint("bot", "bandwidth") + self.mumble = pymumble.Mumble(host, user=self.username, port=port, password=password, tokens=tokens, stereo=self.stereo, debug=var.config.getboolean('debug', 'mumbleConnection'), @@ -124,7 +129,7 @@ class MumbleBot: self.set_comment() self.mumble.users.myself.unmute() # by sure the user is not muted self.join_channel() - self.mumble.set_bandwidth(200000) + self.mumble.set_bandwidth(self.bandwidth) # ====== Volume ====== self.volume_helper = util.VolumeHelper() @@ -759,6 +764,8 @@ if __name__ == '__main__': type=str, help="Default channel for the bot") parser.add_argument("-C", "--cert", dest="certificate", type=str, default=None, help="Certificate file") + parser.add_argument("-b", "--bandwidth", dest="bandwidth", + type=int, help="Bandwidth used by the bot") args = parser.parse_args()