From 1cd89ef312008dd0f663229a54335db9afbd6390 Mon Sep 17 00:00:00 2001 From: Maff Date: Wed, 1 May 2019 09:53:06 +0000 Subject: [PATCH] Update 'trashtalker.py' --- trashtalker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/trashtalker.py b/trashtalker.py index 04f1b3f..3ff64ef 100644 --- a/trashtalker.py +++ b/trashtalker.py @@ -2,7 +2,7 @@ import sys import pjsua as pj from time import sleep -from os import listdir +from os import listdir, getenv from signal import signal, SIGTERM from random import shuffle @@ -30,8 +30,8 @@ LOG_LEVEL=0 # You can have multiple copies of this script serving different playlists by simply duplicating it # ensuring you change the sourcepath and sipport accordingly. #TODO: make this configurable via a standard config file. -sourcepath="/opt/media/" -sipport=5062 +sourcepath=getenv('TT_MEDIA_SOURCE', '/opt/media/') +sipport=getenv('TT_LISTEN_PORT', 5062) # End configuration # Application scaffolding @@ -163,9 +163,14 @@ def main(): global mainloop global files global sipuri + global sourcepath mainloop=True signal(SIGTERM, sighandle) + assert sourcepath.startswith('/'), "Environment variable TT_MEDIA_PATH must be an absolute path!" try: + if not sourcepath.endswith('/'): + olog(1, "playlist-load", "appending trailing / to TT_MEDIA_PATH") + sourcepath=''.join(sourcepath, '/') files=listdir(sourcepath) files[:]=[sourcepath+file for file in files] assert (len(files) > 1), "Playlist path must contain more than one audio file"