From cf9d56ada755e94e232568272a40c45d2d033cdb Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 13:22:43 +0300 Subject: [PATCH 1/8] Language fixes and improvements --- README.md | 8 ++++---- configuration.default.ini | 8 ++++---- media.py | 2 +- mumbleBot.py | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1316df7..cb8a863 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,11 +14,11 @@ 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): ``` @@ -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 f519775..49f1617 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -5,7 +5,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 @@ -46,9 +46,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/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 9447fc3..f2d6780 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -87,7 +87,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: @@ -371,11 +371,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, required=True, help="The server's hostame of a mumble server") - parser.add_argument("-u", "--user", dest="user", type=str, required=True, help="Username you wish, Default=abot") - parser.add_argument("-P", "--password", dest="password", type=str, default="", help="Password if server requires one") - parser.add_argument("-p", "--port", dest="port", type=int, default=64738, help="Port for the mumble server") - parser.add_argument("-c", "--channel", dest="channel", type=str, default="", help="Default chanel for the bot") + parser.add_argument("-s", "--server", dest="host", type=str, required=True, help="Hostname of the Mumble server") + parser.add_argument("-u", "--user", dest="user", type=str, required=True, help="Username for the bot, Default=abot") + parser.add_argument("-P", "--password", dest="password", type=str, default="", help="Server password, if required") + parser.add_argument("-p", "--port", dest="port", type=int, default=64738, help="Port for the Mumble server") + parser.add_argument("-c", "--channel", dest="channel", type=str, default="", help="Default channel for the bot") args = parser.parse_args() config = configparser.ConfigParser(interpolation=None) From 03a1b00e1e99c918afe210b77528fe5fe6bb3eea Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 13:26:38 +0300 Subject: [PATCH 2/8] Missing instance attribute definition --- mumbleBot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mumbleBot.py b/mumbleBot.py index f2d6780..b8499f6 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -62,6 +62,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") From e6af06b8dc2f9027237f5ebefa8a87dfb2e4cb5b Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 13:31:57 +0300 Subject: [PATCH 3/8] Unused imports --- interface.py | 1 - mumbleBot.py | 3 --- util.py | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) 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/mumbleBot.py b/mumbleBot.py index b8499f6..805c18a 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 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)) From b747aff075f0f2422becdd7c3d9b850b6072e743 Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 13:38:38 +0300 Subject: [PATCH 4/8] .gitignore --- .gitignore | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 .gitignore 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/ + From 4c02c29ec70aeb787a1181474de911e218805a6a Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 13:51:40 +0300 Subject: [PATCH 5/8] venv instructions --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cb8a863..a10361b 100644 --- a/README.md +++ b/README.md @@ -20,19 +20,19 @@ The main folder needs to be declared in the config (with a '/' at the end) 1. You need python 3 with opuslib and protobuf (look at the requirement of pymumble) 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-pip python3-venv +# apt install ffmpeg +# apt install youtube-dl +$ git clone --recurse-submodules https://github.com/azlux/botamusique.git +$ cd botamusique +$ python -m venv venv +$ 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) From 286e219fd898ce00f082c38abf73e66ec396a87b Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 15:30:03 +0300 Subject: [PATCH 6/8] Don't apt install pip or youtube-dl --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index a10361b..648ee59 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,8 @@ The main folder needs to be declared in the config (with a '/' at the end) Example installation commands for Debian and Ubuntu: ``` -# apt install python3-pip python3-venv +# apt install python3-venv # apt install ffmpeg -# apt install youtube-dl $ git clone --recurse-submodules https://github.com/azlux/botamusique.git $ cd botamusique $ python -m venv venv From 554bf5467732c17d8f6a1a7e333f1c832292b932 Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 15:49:55 +0300 Subject: [PATCH 7/8] python3 not python here --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 648ee59..9f6b955 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Example installation commands for Debian and Ubuntu: # apt install ffmpeg $ git clone --recurse-submodules https://github.com/azlux/botamusique.git $ cd botamusique -$ python -m venv venv +$ python3 -m venv venv $ venv/bin/pip install -r requirements.txt ``` From 0f38e8b8cf04fbba81d5a858a411e47e26527d62 Mon Sep 17 00:00:00 2001 From: Lartza Date: Mon, 18 Jun 2018 15:58:55 +0300 Subject: [PATCH 8/8] Need wheel to install some of the requirements --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9f6b955..c9d9882 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Example installation commands for Debian and Ubuntu: $ 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 ```