Added music_dir config

rr/dockerize
Will Hunt 2016-03-22 10:20:06 +00:00
parent eb20683bd9
commit 76cf22a5e3
3 changed files with 7 additions and 5 deletions

View File

@ -14,8 +14,10 @@ class CmdListener:
client = None
stream_url = ""
cmd_queue = None
music_dir = "/tmp/"
def __init__(self,config):
self.mpc = MPCClient(config["mpc"]["host"],config["mpc"]["port"])
music_dir = config["mpc"]["music_dir"]
self.cmd_queue = Queue()
try:
@ -112,7 +114,7 @@ class CmdListener:
elif "youtube.com/" in parts[0]:
try:
url = cmd_regular.strip().split(" ")[0]
status,fname = download_youtube(url,self.__newfile_play)
status,fname = download_youtube(url,self.music_dir,self.__newfile_play)
except Exception as e:
print(e)
room.send_text("Couldn't download the file :(")

View File

@ -4,7 +4,6 @@ from os.path import getctime, basename,exists
from glob import iglob
from threading import Lock
YT_OUTPUTDIR="/tmp/"
yt_mutex = Lock()
__yt_callback = None
@ -21,7 +20,7 @@ def yt_hook(status):
if exists(fname):
__yt_callback(basename(fname))
def download_youtube(url,callback):
def download_youtube(url,outputdir,callback):
global __yt_callback
yt_mutex.acquire()
path = False
@ -30,7 +29,7 @@ def download_youtube(url,callback):
try:
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': YT_OUTPUTDIR+'%(title)s.tmp',
'outtmpl': outputdir+'%(title)s.tmp',
'add-metadata':True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',

View File

@ -21,6 +21,7 @@ def default_config(path):
config["mpc"]["host"] = "localhost"
config["mpc"]["port"] = "6600"
config["mpc"]["streamurl"] = "http://localhost:8000"
config["mpc"]["music_dir"] = "/var/lib/mpd/music"
config["matrix"]["host"] = "https://localhost:8448"
config["matrix"]["user"] = "username"
@ -37,7 +38,7 @@ def read_config(path):
print("Error, missing mpc section")
return False
keys = ["host","port","streamurl"]
keys = ["host","port","streamurl","music_dir"]
for key in keys:
if key not in config["mpc"].keys():
print("Error, missing",key,"from mpc section")