diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5647b9a --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ +# Created by .ignore support plugin (hsz.mobi) +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + diff --git a/README.md b/README.md index 1316df7..c9d9882 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ====== Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output. -Predicted functionnalities will be the one you could expect from any classic music player. +Predicted functionalities will be ones you could expect from any classic music player. Bot the can play : - Radio url @@ -14,25 +14,25 @@ Bot the can play : * Disable * I need to work on it. Since I use this bot for radio, youtube/soundcloud and folder music, the web interace isn't ready. You need to create a folder for all your music. Organize your music by subfolder. -The main folder need to be declare into the config (with a '/' at the end) +The main folder needs to be declared in the config (with a '/' at the end) #### Installation 1. You need python 3 with opuslib and protobuf (look at the requirement of pymumble) -2. The Bot use ffmpeg, so you know what you have to do if ffmpeg aren't in your package manager. I personally use [this repository](http://repozytorium.mati75.eu/) on my raspberry. +2. The Bot uses ffmpeg, so you know what you have to do if ffmpeg isn't in your package manager. I personally use [this repository](http://repozytorium.mati75.eu/) on my raspberry. -commands (don't forget the sudo mode): +Example installation commands for Debian and Ubuntu: ``` -apt install python3-pip -apt install ffmpeg -apt install youtube-dl -git clone --recurse-submodules https://github.com/azlux/botamusique.git -cd ./botamusique -pip3 install -r requirements.txt -chmod +x ./mumbleBot.py +# apt install python3-venv +# apt install ffmpeg +$ git clone --recurse-submodules https://github.com/azlux/botamusique.git +$ cd botamusique +$ python3 -m venv venv +$ venv/bin/pip install wheel +$ venv/bin/pip install -r requirements.txt ``` #### Starting the bot -`./mumbleBot.py -s HOST -u BOTNAME -P PASSWORD -p PORT -c CHANNEL` +`$ venv/bin/python mumbleBot.py -s HOST -u BOTNAME -P PASSWORD -p PORT -c CHANNEL` The bot listen to the 8181 port so you should redirect to this one in you NAT configuration to let others peoples access the web interface. (DISABLED) @@ -41,7 +41,7 @@ You can copy the file `configuration.default.ini` to `configuration.ini` and cus you have the section : - bot : basic configuration of the bot : comment, folder, volume at start .... - command : you can customize the command you want for each action (if you put `help = helpme` , the bot will response to `!helpme` ) -- readio : here you can have a list of default radio ( I can play a jazz radio with the command `!radio jazz`) +- radio : here you can have a list of default radio ( I can play a jazz radio with the command `!radio jazz`) - strings : you can customize all string the bot can say. diff --git a/configuration.default.ini b/configuration.default.ini index d4b68f1..2e89aee 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -12,7 +12,7 @@ admin = User1;User2; # Allow user to kill the bot music_folder = /home/azlux/botamusique/music_folder/ tmp_folder = /tmp/ -# in Mo, 0 for no cache, -1 for illimited size +# in MB, 0 for no cache, -1 for unlimited size tmp_folder_max_size = 10 ignored_folders = tmp @@ -53,9 +53,9 @@ change_volume = volume : %d%% by %s bad_command = Incorrect command not_admin = You are not an admin ! not_playing = No music right now -bad_file = Bad file asked -no_file = Not file here -bad_url = Bad URL asked +bad_file = Bad file requested +no_file = File not found +bad_url = Bad URL requested multiple_matches = Track not found! Possible candidates: queue_contents = The next items in the queue are: queue_empty = No more music in the playlist! diff --git a/interface.py b/interface.py index e94f19a..1b3bae3 100644 --- a/interface.py +++ b/interface.py @@ -5,7 +5,6 @@ import variables as var import util from datetime import datetime import os.path -from os import listdir import random from werkzeug.utils import secure_filename import errno diff --git a/media.py b/media.py index 30c512a..d403132 100644 --- a/media.py +++ b/media.py @@ -65,7 +65,7 @@ def get_radio_title(url): return title.decode() except (urllib.error.URLError, urllib.error.HTTPError): pass - return 'Impossible to get the music title' + return 'Unable to get the music title' def get_url(string): diff --git a/mumbleBot.py b/mumbleBot.py index 63db1b4..d83af28 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import unicode_literals -import re import threading import time import sys @@ -11,7 +9,6 @@ import audioop import subprocess as sp import argparse import os.path -from os import listdir import pymumble.pymumble_py3 as pymumble import interface import variables as var @@ -62,6 +59,7 @@ class MumbleBot: self.exit = False self.nb_exit = 0 self.thread = None + self.playing = False if var.config.getboolean("webinterface", "enabled"): wi_addr = var.config.get("webinterface", "listening_addr") @@ -105,7 +103,7 @@ class MumbleBot: self.loop() def ctrl_caught(self, signal, frame): - logging.info("\ndeconnection asked") + logging.info("\nSIGINT caught, quitting") self.exit = True self.stop() if self.nb_exit > 1: @@ -389,11 +387,11 @@ if __name__ == '__main__': parser.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only Error logs") # Mumble arguments - parser.add_argument("-s", "--server", dest="host", type=str, help="The server's hostame of a mumble server") - parser.add_argument("-u", "--user", dest="user", type=str, help="Username you wish, Default=abot") - parser.add_argument("-P", "--password", dest="password", type=str, help="Password if server requires one") - parser.add_argument("-p", "--port", dest="port", type=int, help="Port for the mumble server") - parser.add_argument("-c", "--channel", dest="channel", type=str, help="Default chanel for the bot") + parser.add_argument("-s", "--server", dest="host", type=str, help="Hostname of the Mumble server") + parser.add_argument("-u", "--user", dest="user", type=str, help="Username for the bot") + parser.add_argument("-P", "--password", dest="password", type=str, help="Server password, if required") + parser.add_argument("-p", "--port", dest="port", type=int, help="Port for the Mumble server") + parser.add_argument("-c", "--channel", dest="channel", type=str, help="Default channel for the bot") args = parser.parse_args() config = configparser.ConfigParser(interpolation=None, allow_no_value=True) diff --git a/util.py b/util.py index 70ab20b..c569fea 100644 --- a/util.py +++ b/util.py @@ -150,4 +150,4 @@ class Dir(object): for key, val in self.subdirs.items(): val.render_text(ident + 1) for file in self.files: - print('{}{}'.format(' ' * ((ident + 1)) * 4, file)) + print('{}{}'.format(' ' * (ident + 1) * 4, file))