Update 'trashtalker.py'
This commit is contained in:
parent
664cf3beb2
commit
1cd89ef312
|
@ -2,7 +2,7 @@
|
||||||
import sys
|
import sys
|
||||||
import pjsua as pj
|
import pjsua as pj
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from os import listdir
|
from os import listdir, getenv
|
||||||
from signal import signal, SIGTERM
|
from signal import signal, SIGTERM
|
||||||
from random import shuffle
|
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
|
# You can have multiple copies of this script serving different playlists by simply duplicating it
|
||||||
# ensuring you change the sourcepath and sipport accordingly.
|
# ensuring you change the sourcepath and sipport accordingly.
|
||||||
#TODO: make this configurable via a standard config file.
|
#TODO: make this configurable via a standard config file.
|
||||||
sourcepath="/opt/media/"
|
sourcepath=getenv('TT_MEDIA_SOURCE', '/opt/media/')
|
||||||
sipport=5062
|
sipport=getenv('TT_LISTEN_PORT', 5062)
|
||||||
# End configuration
|
# End configuration
|
||||||
|
|
||||||
# Application scaffolding
|
# Application scaffolding
|
||||||
|
@ -163,9 +163,14 @@ def main():
|
||||||
global mainloop
|
global mainloop
|
||||||
global files
|
global files
|
||||||
global sipuri
|
global sipuri
|
||||||
|
global sourcepath
|
||||||
mainloop=True
|
mainloop=True
|
||||||
signal(SIGTERM, sighandle)
|
signal(SIGTERM, sighandle)
|
||||||
|
assert sourcepath.startswith('/'), "Environment variable TT_MEDIA_PATH must be an absolute path!"
|
||||||
try:
|
try:
|
||||||
|
if not sourcepath.endswith('/'):
|
||||||
|
olog(1, "playlist-load", "appending trailing / to TT_MEDIA_PATH")
|
||||||
|
sourcepath=''.join(sourcepath, '/')
|
||||||
files=listdir(sourcepath)
|
files=listdir(sourcepath)
|
||||||
files[:]=[sourcepath+file for file in files]
|
files[:]=[sourcepath+file for file in files]
|
||||||
assert (len(files) > 1), "Playlist path must contain more than one audio file"
|
assert (len(files) > 1), "Playlist path must contain more than one audio file"
|
||||||
|
|
Loading…
Reference in New Issue