Giter Site home page Giter Site logo

azlux / botamusique Goto Github PK

View Code? Open in Web Editor NEW
305.0 10.0 74.0 5.01 MB

Bot to play youtube / soundcloud / radio / local music on Mumble (using pymumble).

License: MIT License

Python 71.66% HTML 10.51% Shell 1.68% JavaScript 14.49% Dockerfile 0.27% SCSS 1.40%
mumble music-bot youtube soundcloud radio pymumble web-interface

botamusique's Introduction

botamusique

botamusique

Botamusique is a Mumble music bot. Predicted functionalities will be those people would expect from any classic music player.

Build Status

Features

  1. Support multiple music sources:
    • Music files in local folders (which can be uploaded through the web interface).
    • Youtube/Soundcloud URLs and playlists (everything supported by youtube-dl).
    • Radio stations from URL and http://www.radio-browser.info API.
  2. Modern and powerful web remote control interface. Powered by Flask. Which supports:
    • Playlist management.
    • Music library management, including uploading, browsing all files and edit tags, etc.
  3. Powerful command system. Commands and words the bot says are fully customizable. Support partial-match for commands.
  4. Ducking. The bot would automatically lower its volume if people are talking.
  5. Stereo sound. After Mumble 1.4.0, stereo output support has been added. Our bot is designed to work nicely with it naturally.
  6. Multilingual support. A list of supported languages can be found below.

Screenshots

botamusique in Mumble channel

botamusique web interface


Quick Start Guide

  1. Installation
  2. Configuration
  3. Run the bot
  4. Operate the bot
  5. Update
  6. Known issues
  7. Contributors

Installation

Dependencies

  1. Install python. We require a python version of 3.6 or higher.
  2. Install Opus Codec (which should be already installed if you installed Mumble or Murmur, or you may try to install opus-tools with your package manager).
  3. Install ffmpeg. If ffmpeg isn't in your package manager, you may need to find another source. I personally use this repository on my raspberry.

Docker

See https://github.com/azlux/botamusique/wiki/Docker-install

Both stable and nightly (developing) builds are available!

Manual install

Stable release (recommended)

This is current stable version, with auto-update support. To install the stable release, run these lines in your terminal:

curl -Lo botamusique.tar.gz http://packages.azlux.fr/botamusique/sources-stable.tar.gz
tar -xzf botamusique.tar.gz
cd botamusique
python3 -m venv venv
venv/bin/pip install wheel
venv/bin/pip install -r requirements.txt

Nightly build (developing version)

Click to expand!

This build reflects any newest change in the master branch, with auto-update support baked in. This version follow all commits into the master branch.

curl -Lo botamusique.tar.gz http://packages.azlux.fr/botamusique/sources-testing.tar.gz
tar -xzf botamusique.tar.gz
cd botamusique
python3 -m venv venv
venv/bin/pip install wheel
venv/bin/pip install -r requirements.txt

Build from source code

Click to expand!

You can checkout the master branch of our repo and compile everything by yourself. We will test new features in the master branch, maybe sometimes post some hotfixes. Please be noted that the builtin auto-update support doesn't track this version. If you have no idea what these descriptions mean to you, we recommend you install the stable version above.

git clone https://github.com/azlux/botamusique.git
cd botamusique
python3 -m venv venv
venv/bin/pip install wheel
venv/bin/pip install -r requirements.txt
(cd web && npm install && npm run build)
venv/bin/python3 ./scripts/translate_templates.py --lang-dir lang/ --template-dir web/templates/

Configuration

Please copy configuration.example.ini into configuration.ini, follow the instructions in that file and uncomment options you would like to modify. Not all sections are needed. You may just keep the options that matter to you. For example, if you only would like to set host, all you need you is keep

[server]
host=xxxxxx

in your configuration.ini.

Please DO NOT MODIFY configuration.default.ini, since if the bot realizes one option is undefined in configuration.ini, it will look into configuration.default.ini for the default value of that option. This file will be constantly overridden in each update.

We list some basic settings for you to quickly get things working.

Basic settings

  1. Usually, the first thing is to set the Murmur server you'd like the bot to connect to. You may also specify which channel the bot stays, and tokens used by the bot.
[server]
host = 127.0.0.1
port = 64738
  1. You need to specify a folder that stores your music files. The bot will look for music and upload files into that folder. You also need to specify a temporary folder to store music file downloads from URLs.
[bot]
music_folder = music_folder/
tmp_folder = /tmp/
  1. Web interface is disabled by default for performance and security reasons. It is extremely powerful, so we encourage you to have a try. To enable it, set
[webinterface]
enabled = True

Default binding address is

listening_addr = 127.0.0.1
listening_port = 8181

You can access the web interface through http://127.0.0.1:8181 if you keep it unchanged.

Note: Listening to address 127.0.0.1 will only accept requests from localhost. If you would like to connect from the public internet, you need to set it to 0.0.0.0, and set up username and password to impose access control. In addition, if the bot is behind a router, you should also properly set forwarding rules in you NAT configuration to forward requests to the bot.

  1. The default language is English, but you can change it in [bot] section:
[bot]
language=en_US

Available translations can be found inside lang/ folder. Currently, options are

  • en_US, English
  • es_ES, Spanish
  • fr_FR, French
  • it_IT, Italian
  • ja_JP, Japanese
  • zh_CN, Chinese
  1. Generate a certificate (Optional, but recommended)

By default, murmur server uses certificates to identify users. Without a valid certificate, you wouldn't able to register the bot into your Murmur server. Some server even refused users without a certificate. Therefore, it is recommended to generate a certificate for the bot. If you have a certificate (for say, botmusique.pem in the folder of the bot), you can specify its location in

[server]
certificate=botamusique.pem

If you don't have a certificate, you may generate one by: openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout botamusique.pem -out botamusique.pem -subj "/CN=botamusique"

Sections explained

  • server: configuration about the server. Will be overridden by the ./mumbleBot.py parameters.
  • bot: basic configuration of the bot, eg. name, comment, folder, default volume, etc.
  • webinterface: basic configuration about the web interface.
  • commands: you can customize the command you want for each action (eg. put help = helpme , the bot will respond to !helpme)
  • radio: a list of default radio (eg. play a jazz radio with the command !radio jazz)
  • debug: option to activate ffmpeg or pymumble debug output.

Run the bot

If you have set up everything in your configuration.ini, you can venv/bin/python mumbleBot.py --config configuration.ini

Or you can venv/bin/python mumbleBot.py -s HOST -u BOTNAME -P PASSWORD -p PORT -c CHANNEL -C /path/to/botamusique.pem

If you want information about auto-starting and auto-restarting of the bot, you can check out the wiki page Run botamusique as a daemon In the background.

For the detailed manual of using botamusique, please see the wiki.

Operate the bot

You can control the bot by both commands sent by text message and the web interface.

By default, all commands start with !. You can type !help in the text message to see the full list of commands supported, or see the examples on the wiki page.

The web interface can be used if you'd like an intuitive way of interacting with the bot. Through it is fairly straightforward, a walk-through can be found on the wiki page.

Update

If you enable auto_check_update, the bot will check for updates every time it starts. If you are using the recommended install, you can send !update to the bot (command by default).

If you are using git, you need to update manually:

git pull --all
git submodule update
venv/bin/pip install --upgrade -r requirements.txt

Known issues

  1. During installation, you may encounter the following error:
ImportError: libtiff.so.5: cannot open shared object file: No such file or directory

You need to install a missing library: apt install libtiff5

  1. In the beginning, you may encounter the following error even if you have installed all requirements:
Exception: Could not find opus library. Make sure it is installed.

You need to install the opus codec (not embedded in all system): apt install libopus0

  1. MacOS Users may encounter the following error:
ImportError: failed to find libmagic.  Check your installation

This is caused by missing libmagic binaries and can be solved by

brew install libmagic

One may also install python-magic-bin instead of python-magic.

  1. If you have a large amount of music files (>1000), it may take some time for the bot to boot, since it will build up the cache for the music library on booting. You may want to disable this auto-scanning by setting refresh_cache_on_startup=False in [bot] section and control the scanning manually by !rescan command and the Rescan Files button on the web interface.

  2. Alpine Linux requires some extra dependencies during the installation (in order to compile Pillow):

python3-dev musl-lib libmagic jpeg-dev zlib-dev gcc

For more information, see #122.

I need help!

If you ran into some problems in using the bot, or discovered bugs and want to talk to us, you may

  • Start a new issue,
  • Ask in the Matrix channel of Mumble #mumble:matrix.org (we are usually there to help).

Contributors

If you want to help us develop, you're welcome to fork and submit pull requests (fixes and new features). We are looking for people helping us translating the bot. If you'd like to add a new language or fix errors in existed translations, feel free to catch us in the IRC channel #mumble, or just email us!

The following people joined as collaborators for a faster development, big thanks to them:

  • @TerryGeng
  • @mertkutay

Feel free to ask me if you want to help actively without using pull requests.

botamusique's People

Contributors

ajmandourah avatar arvsindrarys avatar azlux avatar bafdyce avatar dadidji avatar dependabot[bot] avatar dexgs avatar duarm avatar eswcvlad avatar felix91gr avatar fsteffek avatar gunzinger avatar irets avatar kac- avatar lartza avatar lewark avatar luca0n avatar mariorossi77 avatar mweinelt avatar neodarz avatar p00rt avatar seerlite avatar slipenbois avatar snejpro avatar tainmart avatar tdurieux avatar terrygeng avatar tylervigario avatar w0rmsy avatar xenonpk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botamusique's Issues

!next does not work

Describe the bug
!next produces "Incorrect command"

Affected version
Current version

To Reproduce
Steps to reproduce the behavior:
Connect the bot and type !next

Expected behavior
Move to the next track in the playlist.

Bot can't play music from YouTube playlists

Describe the bug
Bot can't play playlists from YouTube

Affected version
Actually stable version when I'm writing this (27.01.2020)

To Reproduce
Steps to reproduce the behavior:

  1. Start a bot
  2. Issue command to start playing playlist from YouTube

[download] Finished downloading playlist: Vatikansky - 2138
2020-01-27 21:45:26: Async download next asked
2020-01-27 21:45:26: Current music wasn't ready, Downloading...
Traceback (most recent call last):
File "mumbleBot.py", line 888, in
botamusique = MumbleBot(args)
File "mumbleBot.py", line 151, in init
self.loop()
File "mumbleBot.py", line 795, in loop
self.launch_music()
File "mumbleBot.py", line 619, in launch_music
self.download_music(index=0)
File "mumbleBot.py", line 724, in download_music
'strings', "download_in_progress") % var.playlist[index]['title'])
KeyError: 'title'

Expected behavior
Can you fix that? I want to play music from playlist.

OS:

cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Stream -error- resume playback option

Is your feature request related to a problem? Please describe.
Partially - i have one stream source i use that errors from time to time (source problem)

Describe the solution you'd like
Auto-restart after a stream which was playing fails.

Describe alternatives you've considered
manual restart of the stream always works, its just annoying.

Additional context
Suggestion is to let the bot restart the stream ( define x amounts in ini) after failing (if possible)

  • when other stuff is in playlist move on to next item in playlist

Error received in log/console*

[http @ 0x561c223b2760] Stream ends prematurely at 11256986, should be 18446744073709551615
http://91.221.151.155/: Input/output error

Bad Parsing/Rendering of Queue

I noticed a bad rendering of the queue using !queue, this has probably something to do with titles parsing.

Playlist used: https://www.youtube.com/playlist?list=PLFSBmHmcw0y_p7eS3omeIX6E_f2GtQ6Ra

Cropped output of !queue command:

[02:58:20] (Channel) RYTHMISGAY: The next items in the queue are:
[1] (url) Adieu jolie Candy
[2] (url) Aline
[3] (url) Comme j'ai toujours envie d'aimer (version 2001)
[4] (url) Et tu danses avec lui
[5] ...

Full output here : https://pastebin.com/fY0As0J6

I am trying to investigate this playlist in order to give a more accurate guess at the thing causing the problem.

Preprocess urls before hitting them in the playlist, keep a more detailed playlist

Is your feature request related to a problem? Please describe.
Currently the bot keeps a list of urls as it's playlist, and processes the song when it hits it in the playlist.

Describe the solution you'd like
Add music to playlist only after it has been fully processed (with full information of the song, url, title and the path). Download songs the moment they are added and possibly keep a processing queue to prevent messing the processing with fast duplicate requests.

Describe alternatives you've considered
I haven't, feel free to have a think.

Additional context
Keeps playback interruptions to a minimum and I feel like would improve the flow of #15

Repeat function and playback youtube playlists

Is your feature request related to a problem? Please describe.
No.

  • 1. If possible add Repeat function for current track (url).
  • 2. If possible add ability to playback youtube playlists.

Versionning

  • Need version, release
  • Weekly check + send message to admin for new update.

Any advise about the second feature ?

improvement

make the notification of update reflect the botname that is configured instead of 'botamusique'

playlist

Python 3.6.8
OS Freebsd 11.2

when tryimg to play playlist from youtube or soundcloud, I get an error:
example playlist: https://soundcloud.com/melanus-anus/sets/audiomatic

[download] Finished downloading playlist: audiomatic
Exception in thread Thread-13:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "mumbleBot.py", line 261, in message_received
if media.playlist.get_playlist_info(url=self.get_url_from_input(parameter), start_index=offset, user=user):
File "/usr/home/jan/botamusique/media/playlist.py", line 16, in get_playlist_info
'title': info['entries'][j]['title'],
KeyError: 'title'

Radio streaming doesn't seem to work on local mpd http streams

Describe the bug
When attempting to play an mpd http stream from localhost, the bot gets stuck downloading and does not play anything.

Affected version
The exact version you're using (git commit id). You should always only report bugs which you can reproduce on the latest version (uif branch), however always state the current commit id here (in case there are new commits between your report and us looking at it)

3ead856 (master)

To Reproduce
Steps to reproduce the behavior:

  1. Launch the bot.
  2. Ensure that mpd is streaming to a local http server. (port 8090 in my case)
  3. Add the stream url via the !radio command. (!radio http://localhost:8090/mpd.mp3)

Expected behavior
The bot should properly play music from the stream.

Screenshots
1

Desktop (please complete the following information):

  • OS: Archlabs Linux (5.4.6-arch3-1)
  • Browser: Firefox
  • Version 72.0b11

Smartphone (please complete the following information):
Not applicable

Additional context
There was a point a while back where this actually worked.

I might try PRing a fix for this if I have time.

Problem starting the music bot in raspberry

Hi,
I can't start the bot in my Raspberry (Latest Raspbian (November 2018)) due to an python error that i can't solve or even find the error. Does anyone has any idea what is going on?

My python version is 3.(idk)

image

Random music playback

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Add a feature to allow the bot to automatically play music on it's own from stuff that it has previously downloaded and played. Toggleable to on and off and only play a random track when the playlist is empty.

Additionally a command to add a selection of random tracks to the playlist could be possible

Describe alternatives you've considered
None

Additional context
I am pretty confident this requires #15 or something similar to work fully and well

Last modified time (youtube-dl)

Is your feature request related to a problem? Please describe.
Youtube-dl get and save file with last modified time from server, and if remove /tmp... files with cron (delete files older than 3 days) are removed also new files..

Describe the solution you'd like
Add --no-mtime to params youtube-dl..

Some commands don't work, bot is crash

Describe the bug
Bot show error and crash (random), some commands don't work

Example:
!help (is not crash)

2019-01-13 17:04:24: Starting in DEBUG loglevel
2019-01-13 17:04:28: help -  by USER
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "mumbleBot.py", line 203, in message_received
    self.send_msg(var.config.get('strings', 'help'), text)
  File "mumbleBot.py", line 521, in send_msg
    own_channel.send_text_message(msg)
  File "/home/bot/mumble-tools/botamusique/pymumble/pymumble_py3/channels.py", line 175, in send_text_message
    raise TextTooLongError(self.mumble_object.get_max_message_length())
pymumble.pymumble_py3.errors.TextTooLongError: Maximum allowed length: 0

!url https://www.youtube.com/watch?v=nGVqz4fm_FA (is crash)

2019-01-13 17:43:09: Starting in DEBUG loglevel
2019-01-13 17:43:11: url - <a href="https://www.youtube.com/watch?v=nGVqz4fm_FA">https://www.youtube.com/watch?v=nGVqz4fm_FA</a> by USER
[{'type': 'url', 'user': 'USER', 'ready': 'validation', 'url': 'https://www.youtube.com/watch?v=nGVqz4fm_FA'}]
[youtube] nGVqz4fm_FA: Downloading webpage
[youtube] nGVqz4fm_FA: Downloading video info webpage
[youtube] Downloading just video nGVqz4fm_FA because of --no-playlist
2019-01-13 17:43:14: Async download next asked
2019-01-13 17:43:14: launch_music asked{'type': 'url', 'url': 'https://www.youtube.com/watch?v=nGVqz4fm_FA', 'ready': 'no', 'title': 'Hippie Sabotage - Devil Eyes', 'user': 'USER', 'duration': 2.2333333333333334}
2019-01-13 17:43:14: Current music wasn't ready, Downloading...
2019-01-13 17:43:14: Download index:0
2019-01-13 17:43:14: {'type': 'url', 'url': 'https://www.youtube.com/watch?v=nGVqz4fm_FA', 'ready': 'downloading', 'title': 'Hippie Sabotage - Devil Eyes', 'user': 'USER', 'duration': 2.2333333333333334}
Traceback (most recent call last):
  File "mumbleBot.py", line 563, in <module>
    botamusique = MumbleBot(args)
  File "mumbleBot.py", line 97, in __init__
    self.loop()
  File "mumbleBot.py", line 498, in loop
    self.launch_music()
  File "mumbleBot.py", line 351, in launch_music
    self.download_music(index=0)
  File "mumbleBot.py", line 440, in download_music
    self.send_msg(var.config.get('strings', "download_in_progress") % var.playlist[index]['title'])
  File "mumbleBot.py", line 521, in send_msg
    own_channel.send_text_message(msg)
  File "/home/bot/mumble-tools/botamusique/pymumble/pymumble_py3/channels.py", line 175, in send_text_message
    raise TextTooLongError(self.mumble_object.get_max_message_length())
pymumble.pymumble_py3.errors.TextTooLongError: Maximum allowed length: 0

Chat is clear, help text not show
Command is work: !radio, !file, !stop, !kill, !joinme
Not work: !help, !list, !queue, !v

Affected version
Latest version

To Reproduce
Steps to reproduce the behavior:

  1. Send to chat !help command
  2. See error

Additional context
Debian GNU/Linux 8.11 (jessie) x86
Mumble server version is 1.2.19
Mumble client version is 1.2.19 and latest 1.3.0

Manual install (bot not work without it):
from aptitude - libjpeg-dev
from venv/bin/pip - six werkzeug jinja2 click itsdangerous

$ venv/bin/pip install -r requirements.txt
Requirement already satisfied (use --upgrade to upgrade): opuslib==2.0.0 in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): protobuf==3.4.0 in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): flask in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): youtube-dl in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 4))
Requirement already satisfied (use --upgrade to upgrade): python-magic in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): mutagen in ./venv/lib/python3.4/site-packages (from -r requirements.txt (line 7))
Cleaning up...

w/o configuration.ini the same behavior

Bitrate setting

Is your feature request related to a problem? Please describe.
I want to get a setting for set a bitrate for a bot without change settings of Mumble server.

[ffmpeg] Adding metadata to '/tmp/xyz.mp3' - really slow

Is there a way to make the bot faster? I know it uses youtube-dl, but I do not get stuck on youtube-dl converting the video to mp3, but ffmpeg adding metadata. This is the line:
[ffmpeg] Adding metadata to '/tmp/1db427d063c1d15195f4c3ebbd246e75.mp3'

Is it really nessesary to have this metadata? Is it something that youtube-dl does on its own? Also contrary to when yt-dl is converting I do not see any load on the CPU nor the HDD during the "metadata adding".

Play direct url to mp3 is crash a bot

Describe the bug
If you pass a direct link to mp3 to the bot, the script will fail.

To Reproduce
Steps to reproduce the behavior:

  1. Say bot !url http://url.tld/123.mp3
  2. See error

Expected behavior
Play file from direct url

Additional context
Error log:

2018-06-04 23:06:48: play_url - <a href="http://192.168.1.123/123.mp3">http://192.168.1.123/123.mp3</a> by user
[generic] 123: Requesting header
WARNING: Falling back on generic information extractor.
[generic] 123: Downloading webpage
WARNING: URL could be a direct video link, returning it as such.
[download] Destination: /tmp/5cee745417c743389475785eec49c911.mp3
[download] 100% of 402.18KiB in 00:00
[ffmpeg] Post-process file /tmp/5cee745417c743389475785eec49c911.mp3 exists, skipping
Traceback (most recent call last):
  File "./mumbleBot.py", line 383, in <module>
    botamusique = MumbleBot(args)
  File "./mumbleBot.py", line 87, in __init__
    self.loop()
  File "./mumbleBot.py", line 332, in loop
    self.launch_next()
  File "./mumbleBot.py", line 255, in launch_next
    im = Image.open(var.config.get('bot', 'tmp_folder') + hashlib.md5(url.encode()).hexdigest() + '.jpg')
  File "/home/user/env_botamusique/lib/python3.4/site-packages/PIL/Image.py", line 2548, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/5cee745417c743389475785eec49c911.jpg'

REQ: Modular configuration file implementation

Is your feature request related to a problem? Please describe.
No, this is to minimize administration when running multiple instances.

Describe the solution you'd like
Possibility to use a construction of a Global configuration file (needed for minimal/global functionality) and to include/attatch an instance-specific add-on configuration so to say.

Describe alternatives you've considered
None that i could think of, now whenever i change something (like markup) i need to go thru all instance-ini - files.

Additional context
In my case i use a reference to an ini-file per-instance ie. configuration.ini
As this holds the full configuration if i were to change something of the parameters i would like to have on all instances i need to repeat it multiple times.
Preference would be that a 'global' configuration.ini can be used with a reference to a 'per-instance' configuration ini that would act as an addon, where instance-specific parameters can be set (and possibly even override settings from the global configuration)

startup of bot fails

Environment :

  • mumble server running v 1.2.19 on SuSE Linux Enterprise Server 12 SP2
  • bot running on Debian GNU/Linux 9 (stretch) ( same machine as MumbleRadioPlayer bot, which runs OK )

Fired up the bot after following instructions ( trying to replace upgrade from the old mumblebot)

when installing all requirements were fulfilled (without errors) , so dont know whats going on.
mumblebot-error.txt

Add to README info about generating certificate for a bot

Additional context
Can be to add information about manually generating a certificate for a bot?

Command for generate certificate:
$ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout botamusique.pem -out botamusique.pem -subj "/CN=botamusique"

Add to bot launch options:
-C /path/to/botamusique.pem

UDP: and maybe add param for path certificate in configuration.ini config?

Cant properly play all radio URLs

I tried e.g. this stream URL but it doesnt seem to work and crash botamusique because of the SSL verification.

Traceback (most recent call last):
File "/usr/lib/python3.7/urllib/request.py", line 1319, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.7/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/usr/lib/python3.7/http/client.py", line 1422, in connect
server_hostname=server_hostname)
File "/usr/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/usr/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/usr/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

Server info:
Nano Pi M1
Debian Bullseye

Doesn't skip current song

Describe the bug
When using the skip command, it skips the next song in the queue, but not the current song playing

Affected version
Version 3
commit: 3684f54

Expected behavior
The command skip should skip the current song playing

REQ: Command to reveal configured streams in configuration file

Is your feature request related to a problem? Please describe.
Configured streams in the configuration file ([radio] - section) are not known to users, and there is no command to give them insight into what is available.

Describe the solution you'd like
Suggestion is to extend the existing !radio command so that when no argument is passed it would show available stream-names from configuration-file.

Describe alternatives you've considered
no alternatives

Additional context
As to make it meaningfull (as the configured name itself does not always reveal the type of music) to extend the definition of the configured stream in the config file to :

[radio]
alias name = link +delimiter+ description

Write volume to config

Is your feature request related to a problem? Please describe.
Bot doesn't store the set volume to keep after a restart

Describe the solution you'd like
Write the volume to the configuration file.

Describe alternatives you've considered
None

Additional context
Unfortunately, ConfigParser can't write configs without losing comments as far as I can tell. So either a different library needs to be used or all documentation needs to be kept separate from the ini.

TODO

Features

  • Next song
  • Randomizer
  • Graphical interface
  • Playlist
  • Who add a music

Commands with the interface (disabled)

  • list
  • play
  • playfolder
  • random

Commands by message to the bot

  • volume
  • next
  • stop
  • joinme
  • go away
  • help
  • pause

Web Interface (disabled for now)

  • Primary functions
  • CSS

Ignore users, ignore users on different channels and ignore private messages

Is your feature request related to a problem? Please describe.
Stops people from trolling other people with music they aren't even going to listen, etc.

Describe the solution you'd like

  • Add an admin command to ignore and unignore users. Ignored users will not cause any response from the bot to any command. Keep a list of ignored users somehow.
  • Add a configuration option that if true, makes the bot ignore users that are not on the same channel as the bot and aren't admins. Exclude joinme from this condition.
  • Add a configuration option to make the bot ignore private messages that aren't from an admin. Exclude joinme from this too.

Describe alternatives you've considered
None

Additional context
People are jerks vol .2

Playing stream fills memory

Describe the bug
When the bot plays a stream memory is slowly being consumed.
In my case the (LXC) machine has 4Gb mem and 1Gb Swap, dedicaded for the bot.

When bot is idle (after a restart)
MiB Mem : 4096.0 total, 3362.9 free, 235.6 used, 497.6 buff/cache
MiB Swap: 5120.0 total, 5113.1 free, 6.9 used. 3860.4 avail Mem

As soon as bot is starting to stream the memory count drops by ~0.1 Mb / 12-15 seconds
This will continue to drop untill there is nothing left (mem and swap), bot will stop streaming/go unresponsive.
After ~10 minutes :
MiB Mem : 4096.0 total, 3303.3 free, 236.7 used, 556.0 buff/cache
MiB Swap: 5120.0 total, 5113.0 free, 7.0 used. 3859.3 avail Mem

Stopping the stream does not release consumed memory, only a reboot will really free it up.

Affected version
The exact version you're using (git commit id). You should always only report bugs which you can reproduce on the latest version (uif branch), however always state the current commit id here (in case there are new commits between your report and us looking at it)

To Reproduce
Steps to reproduce the behavior:

  1. start the bot
  2. issue command to start playing a stream like
  3. watch console 'top' memory slowly going down

Expected behavior
memory should be released after 'use', so no fillup/out of memory happens.

OS : cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

ffmpeg : ffmpeg -version
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)

If extra info is required just ask and i will provide

Embed metadata to files, use existing files before download

  • Write metadata to files on download

  • Check for an existing file and read it's metadata to obtain it's information

Old issue for reference:
Is your feature request related to a problem? Please describe.
Currently the bot can only cache the mp3 files it gets from youtube-dl to avoid redownloading them, but it doesn't really keep any track of them.

Describe the solution you'd like
Create an (optional?) database to hold record of every downloaded url.
Keep an unique id (urlhash?), the original URL, a file path and the title of the video or file in question.

Describe alternatives you've considered
Use youtube-dl's download_archive to keep a list of previously downloaded files, would still need to make server requests to fetch titles etc and editing the file wouldn't be nice. This wouldn't really be scalable in my opinion either.

Additional context
This feature allows some additional features, like playing random music from what has been previously played on the bot. I'm willing to implement this on myself but would like some feedback and suggestions in both functionality wise (what to store?) and implementation wise (sqlite only? use an ORM like peewee?)

configparser write

Hi @Lartza ,

I have on issue with your commit #22 , write volume change into the configuration have side effect.

  1. You cannot change the conf while the bot run (We will erase the change on stop).
  2. The write add all non defined value present into the default. This is annoying when you want minimal configuration.ini file.

Solution, We need the volume and blacklist user/url into a separated configparser file. (e.g. tmp.ini)

Maximum song duration and a blacklist of urls

Is your feature request related to a problem? Please describe.
Prevent, for example, 10 hour (configurable) videos automatically and other annoying videos manually.

Describe the solution you'd like

  • Add a max duration configuration option and a check to the bot that makes the bot ignore any songs that are over the set value.

  • Additionally keep a blacklist of videos (urlhashes?) that admins can add or delete to blacklist any unwanted songs. In the config file?

Describe alternatives you've considered
Keep track of the blacklist in a database. Ref #15

Additional context
People are jerks.

server / default connection transferred from startcommand to configuration-file ?

Is your feature request related to a problem? Please describe.
No

**A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Instead of passing (server-specific) parameters to start the bot on commandline if possible transfer them as configuration parameters to config-file

Describe the solution you'd like
If possible create the connection-parameters to be in configuration file :

[connection]
server = mumble.server.dns.name
port = 64738
botname = MusicBot
chan = default_channel to join ( enable escape with quotes for channels with spaces ie: "AFK or Busy"

**A clear and concise description of what you want to happen.
Setting the connection parameters in the config-file will make it easyer to start the bot (or run it as a daemon in background)

Describe alternatives you've considered
None yet

Additional context
None

Bot won't run

Describe the bug
When attempting to run the bot I get

Traceback (most recent call last):
  File "mumbleBot.py", line 888, in <module>
    botamusique = MumbleBot(args)
  File "mumbleBot.py", line 145, in __init__
    self.set_comment()
  File "mumbleBot.py", line 816, in set_comment
    self.mumble.users.myself.comment(var.config.get('bot', 'comment'))
AttributeError: 'NoneType' object has no attribute 'comment'

To Reproduce
Steps to reproduce the behavior:

  1. Setup the latest bot
  2. Copy config over to configuration.ini
  3. Run bot

Crash on Low Bandwidth Mumble Server

Describe the bug
Bot crashed on Low Bandwidth servers (18000)
See below for crash error

2019-01-21 12:35:15,314-PyMumble-DEBUG-Bandwidth is 18000, downgrading to -1600 due to the protocol overhead 2019-01-21 12:35:15: Bandwidth is 18000, downgrading to -1600 due to the protocol overhead Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/root/botamusique/pymumble/pymumble_py3/mumble.py", line 119, in run self.loop() File "/root/botamusique/pymumble/pymumble_py3/mumble.py", line 194, in loop self.read_control_messages() File "/root/botamusique/pymumble/pymumble_py3/mumble.py", line 268, in read_control_messages self.dispatch_control_message(type, message) File "/root/botamusique/pymumble/pymumble_py3/mumble.py", line 306, in dispatch_control_message self.set_bandwidth(mess.max_bandwidth) File "/root/botamusique/pymumble/pymumble_py3/mumble.py", line 440, in set_bandwidth self.sound_output.set_bandwidth(self.bandwidth) # communicate the update to the outgoing audio manager File "/root/botamusique/pymumble/pymumble_py3/soundoutput.py", line 133, in set_bandwidth self._set_bandwidth() File "/root/botamusique/pymumble/pymumble_py3/soundoutput.py", line 151, in _set_bandwidth self.encoder.bitrate = self.bandwidth - overhead_per_second File "/root/botamusique/venv/lib/python3.6/site-packages/opuslib/classes.py", line 167, in <lambda> self._state, opuslib.api.ctl.set_bitrate, x) File "/root/botamusique/venv/lib/python3.6/site-packages/opuslib/api/encoder.py", line 66, in ctl return request(_ctl, encoder, value) File "/root/botamusique/venv/lib/python3.6/site-packages/opuslib/api/ctl.py", line 62, in inner raise opuslib.exceptions.OpusError(result_code) opuslib.exceptions.OpusError: <unprintable OpusError object>

Affected version
Latest Version

To Reproduce
Run bot on a low bandwidth mumble server

Making the bot run in background

Hi, I want to set up botamusique on Raspberry Pi without a DE but when it's running, I can't enter any commands. Is it possible to run the bot without it "taking up" the terminal?

Crashes when choosing an nonexistent radio channel

Describe the bug
When selecting a radio channel !radio <channelname> that doesn't exist, the bot crashes completely.

Affected version
89b11d8

To Reproduce
Steps to reproduce the behavior:
!radio <nonexistent_name>

Expected behavior
Should output error e.g. "No radio titled X available"

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Debian 9

Additional context
Log:

2019-02-16 18:24:41: radio - sdaasd by bamtan
2019-02-16 18:24:41: Async download next asked
Traceback (most recent call last):
  File "mumbleBot.py", line 620, in <module>
    args = parser.parse_args()
  File "mumbleBot.py", line 100, in __init__
    self.mumble = pymumble.Mumble(host, user=self.username, port=port, password=password, tokens=tokens,
  File "mumbleBot.py", line 555, in loop
    self.mumble.sound_output.add_sound(audioop.mul(raw_music, 2, self.volume))
  File "mumbleBot.py", line 439, in launch_music

  File "/home/bam/botamusique/media/radio.py", line 11, in get_radio_server_description
    res = re.search(p, url)
  File "/usr/lib/python3.5/re.py", line 173, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

Support for user certificates

Is your feature request related to a problem? Please describe.
There is not enough support for user p12 or PEM certificates for authenticating as a registered user. To obtain privileges on the server and access to private channels.

Describe the solution you'd like
It would be nice if there was autogeneration of the certificate for authorization on the server, so you do not have to generate manually.

rtmp server destination as streaming output

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Stream requested audio output to rtmp server.
Maximize content quality, public fed, personal playback, path for video

Describe alternatives you've considered

Concept 20190423:
-mumbleBot.py
ln414: https://gist.github.com/Fr6jDJF/be94bd166b01a49ba82fec2a1c9c837f
-configuration.ini
https://gist.github.com/Fr6jDJF/73dd7c7274aafeeb474f71b19be792d0

Additional context

Some radio streams don't work

Describe the bug
Some direct streams do not play at all, such as the the ones below.

Affected version
fcad1db

To Reproduce
Add any of the following stream URLs into configuration.ini

RTRFM's (https://rtrfm.com.au/)
Direct stream: https://live.rtrfm.com.au/stream1

.m3u streams
Direct stream: http://dir.xiph.org/listen/2329973/listen.m3u (house music)

.pls streams
Direct stream: http://www.abc.net.au/res/streaming/audio/mp3/triplej.pls

Expected behavior
I expect it to play the stream

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Debian 9

Additional context
Logs:

2019-02-16 17:00:31: radio - rtr by bamtan
2019-02-16 17:00:31: Async download next asked
2019-02-16 17:00:32: TITLE FOUND SHOUTCAST:
2019-02-16 17:23:32: radio - house by bamtan
2019-02-16 17:23:32: Async download next asked
2019-02-16 17:23:41: skip -  by bamtan
2019-02-16 17:23:42: FFmpeg command : ffmpeg -v warning -nostdin -i http://dir.xiph.org/listen/2329973/listen.m3u -ac 1 -f s16le -ar 48000 -
2019-02-16 17:23:42: Async download next asked
http://dir.xiph.org/listen/2329973/listen.m3u: Invalid data found when processing input

Pull from Youtube music was a compilation and filled up /tmp

Is your feature request related to a problem? Please describe.
problem: user of the bot requested a 'compilation' - 2 hour compilation filing up /tmp completely

Describe the solution you'd like

  • a way to avoid /tmp to fill up when someone requests a file that would fill/overflow filesystem

Describe alternatives you've considered
A limit on filesize of a youtube file would be nice if possible.

Additional context
as i am runnig multiple instances i need a way to avoid filling up /tmp completely

Token Support

Adding the ability for users to pass a token or tokens when authenticating to the mumble server.

from pymumble API:

main Mumble object
    class Mumble(host, user, port=64738, password='', certfile=None, keyfile=None, reconnect=False, tokens=[], debug=False)

slow when lot of folers

Report from a user :

I have some suggestions for improving the performance of the bot:

  1. I noticed that when there are a lot of music files, the bot 'thinks' for a very long time. Apparently he reads all the files in all folders. It may be possible to have these actions performed by the team.
    For example: !scan_file >> botamusique scans the music folder and writes the names of the tracks (duration and path to the file) in its database.
    I think this should speed up the process of displaying all the songs on the list.
  2. By default, all music folders are opened in the web interface. Maybe it's better to make them minimized initially?

ducking function

Is your feature request related to a problem? Please describe.
When the bot is too loud, people's speech can not be heard. But when people are not talking, I still want to hear the music clearly.

Describe the solution you'd like
Dynamically adjusting the volume. If people are speaking, lower it down, otherwise, turn it back to normal again, which is usually called ducking.

A primitive implementation has been done on c5fa90b ,
and I'm planning to do the following:

  • Currently it is too sensitive. Try to implement a threshold.

  • This feature can be enabled in configure.ini

  • More parameters to control, including the volume on ducking

  • Can be controlled through chat messages

  • Can be controlled through web interface I don't think this is necessary anymore.

Now, people can set up the ducking function in the configuration.ini, and by typing !duck on/off and !duckvol to turn this function on, and set the volume when ducking is triggered. Also, !duckthres 5000 would set the threshold to activate ducking. I have tested, normally 3000-7000 works fine. I would include some descriptions in the help.

  • Add descriptions of this feature to help.

Describe alternatives you've considered

Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.