Merge pull request #13 from Lartza/qol

Small improvements and virtualenvs
This commit is contained in:
azlux
2018-06-18 22:56:24 +02:00
committed by GitHub
7 changed files with 133 additions and 29 deletions

107
.gitignore vendored Normal file
View File

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

View File

@@ -3,7 +3,7 @@
====== ======
Botamusique is a mumble bot which goal is to allow users to listen music together with its audio output. 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 : Bot the can play :
- Radio url - 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. * 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. 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 #### Installation
1. You need python 3 with opuslib and protobuf (look at the requirement of pymumble) 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 python3-venv
apt install ffmpeg # apt install ffmpeg
apt install youtube-dl $ git clone --recurse-submodules https://github.com/azlux/botamusique.git
git clone --recurse-submodules https://github.com/azlux/botamusique.git $ cd botamusique
cd ./botamusique $ python3 -m venv venv
pip3 install -r requirements.txt $ venv/bin/pip install wheel
chmod +x ./mumbleBot.py $ venv/bin/pip install -r requirements.txt
``` ```
#### Starting the bot #### 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) 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 : you have the section :
- bot : basic configuration of the bot : comment, folder, volume at start .... - 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` ) - 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. - strings : you can customize all string the bot can say.

View File

@@ -12,7 +12,7 @@ admin = User1;User2; # Allow user to kill the bot
music_folder = /home/azlux/botamusique/music_folder/ music_folder = /home/azlux/botamusique/music_folder/
tmp_folder = /tmp/ 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 tmp_folder_max_size = 10
ignored_folders = tmp ignored_folders = tmp
@@ -53,9 +53,9 @@ change_volume = volume : %d%% by %s
bad_command = Incorrect command bad_command = Incorrect command
not_admin = You are not an admin ! not_admin = You are not an admin !
not_playing = No music right now not_playing = No music right now
bad_file = Bad file asked bad_file = Bad file requested
no_file = Not file here no_file = File not found
bad_url = Bad URL asked bad_url = Bad URL requested
multiple_matches = Track not found! Possible candidates: multiple_matches = Track not found! Possible candidates:
queue_contents = The next items in the queue are: queue_contents = The next items in the queue are:
queue_empty = No more music in the playlist! queue_empty = No more music in the playlist!

View File

@@ -5,7 +5,6 @@ import variables as var
import util import util
from datetime import datetime from datetime import datetime
import os.path import os.path
from os import listdir
import random import random
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
import errno import errno

View File

@@ -65,7 +65,7 @@ def get_radio_title(url):
return title.decode() return title.decode()
except (urllib.error.URLError, urllib.error.HTTPError): except (urllib.error.URLError, urllib.error.HTTPError):
pass pass
return 'Impossible to get the music title' return 'Unable to get the music title'
def get_url(string): def get_url(string):

View File

@@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import unicode_literals
import re
import threading import threading
import time import time
import sys import sys
@@ -11,7 +9,6 @@ import audioop
import subprocess as sp import subprocess as sp
import argparse import argparse
import os.path import os.path
from os import listdir
import pymumble.pymumble_py3 as pymumble import pymumble.pymumble_py3 as pymumble
import interface import interface
import variables as var import variables as var
@@ -62,6 +59,7 @@ class MumbleBot:
self.exit = False self.exit = False
self.nb_exit = 0 self.nb_exit = 0
self.thread = None self.thread = None
self.playing = False
if var.config.getboolean("webinterface", "enabled"): if var.config.getboolean("webinterface", "enabled"):
wi_addr = var.config.get("webinterface", "listening_addr") wi_addr = var.config.get("webinterface", "listening_addr")
@@ -105,7 +103,7 @@ class MumbleBot:
self.loop() self.loop()
def ctrl_caught(self, signal, frame): def ctrl_caught(self, signal, frame):
logging.info("\ndeconnection asked") logging.info("\nSIGINT caught, quitting")
self.exit = True self.exit = True
self.stop() self.stop()
if self.nb_exit > 1: 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") parser.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only Error logs")
# Mumble arguments # Mumble arguments
parser.add_argument("-s", "--server", dest="host", type=str, help="The server's hostame of a mumble server") 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 you wish, Default=abot") parser.add_argument("-u", "--user", dest="user", type=str, help="Username for the bot")
parser.add_argument("-P", "--password", dest="password", type=str, help="Password if server requires one") 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("-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("-c", "--channel", dest="channel", type=str, help="Default channel for the bot")
args = parser.parse_args() args = parser.parse_args()
config = configparser.ConfigParser(interpolation=None, allow_no_value=True) config = configparser.ConfigParser(interpolation=None, allow_no_value=True)

View File

@@ -150,4 +150,4 @@ class Dir(object):
for key, val in self.subdirs.items(): for key, val in self.subdirs.items():
val.render_text(ident + 1) val.render_text(ident + 1)
for file in self.files: for file in self.files:
print('{}{}'.format(' ' * ((ident + 1)) * 4, file)) print('{}{}'.format(' ' * (ident + 1) * 4, file))