diff --git a/README.rst b/README.rst index 4ce90ab..b672238 100644 --- a/README.rst +++ b/README.rst @@ -13,14 +13,14 @@ Requirements .. code:: - apt install espeak omxplayer python3.4 python3-pip + apt install espeak omxplayer python3.4 python3-pip python3-dbus pip3 install virtualenv youtube-dl It is highly recommended to install the soundboard and its dependencies into a virtual environment to keep the system clean. To do so first create a new virtual environment in the desired folder and install the remaining Python dependencies via the `pip` of the virtualenv: .. code:: - virtualenv py + virtualenv --system-site-packages py py/bin/pip install -r requirements.txt Apache @@ -83,4 +83,4 @@ Keyboard shortcuts Live version ============ -A list of sound requests and already added sounds can be found here: https://pad.wiai.de/p/soundboardTodos \ No newline at end of file +A list of sound requests and already added sounds can be found here: https://pad.wiai.de/p/soundboardTodos diff --git a/requirements.txt b/requirements.txt index 6aee249..0dcc2b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,14 @@ +certifi==2017.7.27.1 +chardet==3.0.4 click==6.7 +decorator==4.2.1 +evento==1.0.1 Flask==0.12.2 +idna==2.6 itsdangerous==0.24 Jinja2==2.9.6 MarkupSafe==1.0 +omxplayer-wrapper==0.2.5 +requests==2.18.4 +urllib3==1.22 Werkzeug==0.12.2 diff --git a/soundboard.py b/soundboard.py index 40c5dfe..d073bd8 100644 --- a/soundboard.py +++ b/soundboard.py @@ -5,6 +5,7 @@ import subprocess import sqlite3 from flask import Flask, render_template, request, redirect, url_for, send_from_directory, g, jsonify +from omxplayer import * import config @@ -54,7 +55,7 @@ def index(sound=None, text=None, video=None): tags = queryDB("SELECT name FROM tag ORDER BY name COLLATE NOCASE") if sound is not None and sound in sounds: - subprocess.Popen(["omxplayer", os.path.join(config.path, sound).encode("utf-8")], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + player.OMXPlayer(os.path.join(config.path, sound).encode("utf-8")) if text is None: text = request.form.get("text") @@ -74,11 +75,11 @@ def index(sound=None, text=None, video=None): if video is not None: if video[-4:] == ".mp3": - subprocess.Popen(["omxplayer", video], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + player.OMXPlayer(video) else: - url = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode() - subprocess.Popen(["omxplayer", url.split("\n")[1]]) - subprocess.Popen(["omxplayer", "-b", url.split("\n")[0]]) + urls = subprocess.check_output(["youtube-dl", "-g", "-f", "mp4", video]).decode().split("\n") + for url in urls: + player.OMXPlayer(url) killvideo = request.args.get("killvideo") @@ -153,7 +154,7 @@ def sounds(name): def play_random(): sounds = [os.fsencode(file).decode() for file in os.listdir(config.path)] random_sound = random.sample(sounds, 1)[0] - subprocess.Popen(["omxplayer", os.path.join(config.path, random_sound).encode("utf-8")], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + player.OMXPlayer(os.path.join(config.path, random_sound).encode("utf-8")) return render_template("index.html") @app.route("/tags/")