diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/app.py b/app.py
index 74f4eca..2602271 100755
--- a/app.py
+++ b/app.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-import sys, os
+import sys, os, base64, toml
import http.client
import xml.etree.ElementTree as ET
from flask import Flask, render_template, request, make_response, jsonify
@@ -9,21 +9,17 @@ from waitress import serve
app = Flask(__name__)
-DEBUG = 0
-video_folder = "/home/pi"
-media_ext = [ "mp4", "avi", "mkv" ]
-# ~ video_folder = "/media/"
-## base64 encoded ":secret""
-# import base64
-# passwd = "foo"
-# passswd64 = str(base64.b64encode(passwd.encode('utf-8')), 'utf-8')
-auth = "OnNlY3JldA=="
-cmd_auth = "OnNlY3JldA=="
-hosts = [ "10.42.0.135", "10.42.0.156" ]
-# VLC http LUA port
-port = 8080
-# Clients cmd port
-cmd_port = 5000
+# Load config defaults, then look for other config files
+app.config.from_file("defaults.toml", load=toml.load)
+config_locations = ["./", "~/.", "~/.config/"]
+for location in config_locations:
+ # Optional config files, ~ is expanded to $HOME on *nix, %USERPROFILE% on windows
+ # ~ app.config.from_file("videopi.toml", load=toml.load, silent=True)
+ if app.config.from_file(os.path.expanduser( location + "videopi.toml"), load=toml.load, silent=True):
+ print("Found configuration file in " + os.path.expanduser( location ))
+ # ~ app.config.from_file(os.path.expanduser("~/.config/videopi.toml"), load=toml.load, silent=True)
+
+###
hosts_available, hosts_unavailable = [],[]
@@ -64,6 +60,18 @@ cmd = {
}
+# Set configuration
+
+DEBUG = app.config['DEFAULT']['DEBUG']
+media_folder_remote = app.config['DEFAULT']['media_folder_remote']
+media_folder_local = app.config['DEFAULT']['media_folder_local']
+media_ext = app.config['DEFAULT']['media_ext']
+auth = str(base64.b64encode(str(":" + app.config['DEFAULT']['auth']).encode('utf-8')), 'utf-8')
+cmd_auth = str(base64.b64encode(str(":" + app.config['DEFAULT']['cmd_auth']).encode('utf-8')), 'utf-8')
+hosts = app.config['DEFAULT']['hosts']
+port = app.config['DEFAULT']['port']
+cmd_port = app.config['DEFAULT']['cmd_port']
+
# Network/link utilities
# https://www.metageek.com/training/resources/understanding-rssi/
@@ -153,7 +161,7 @@ def sendCommand(host, arg0, arg1, arg2):
elif arg0 == "seek" :
req = req + "&val=" + arg1
elif (arg0 == "enqueue") or (arg0 == "add") :
- req = req + "&input=file://" + video_folder + "/" + arg1
+ req = req + "&input=file://" + media_folder_remote + "/" + arg1
# Send request
conn = http.client.HTTPConnection( host + ":" + str(portl), timeout=3 )
try:
@@ -187,14 +195,22 @@ def sendCommand(host, arg0, arg1, arg2):
cur_time = int(xml.find('time').text)
cur_length_fmtd = sec2min(cur_length)
cur_time_fmtd = sec2min(cur_time)
+ cur_id = int(xml.find('currentplid').text)
+ cur_pos = xml.find('position').text
+ cur_loop = xml.find('loop').text
+ cur_repeat = xml.find('repeat').text
response_dict = {
'host': host,
'file': filename,
'time': cur_time_fmtd,
'leng': cur_length_fmtd,
- 'pos': xml.find('position').text,
- 'loop': xml.find('loop').text,
- 'repeat': xml.find('repeat').text,
+ 'pos': cur_pos,
+ 'loop': cur_loop,
+ 'repeat': cur_repeat,
+ # ~ 'pos': xml.find('position').text,
+ # ~ 'loop': xml.find('loop').text,
+ # ~ 'repeat': xml.find('repeat').text,
+ 'id': cur_id,
}
return response_dict
@@ -248,7 +264,7 @@ def scan():
@app.route("/browse")
def browse():
- files = listMediaFiles("../");
+ files = listMediaFiles(media_folder_local);
return files;
diff --git a/defaults.toml b/defaults.toml
new file mode 100644
index 0000000..1316eb4
--- /dev/null
+++ b/defaults.toml
@@ -0,0 +1,12 @@
+[DEFAULT]
+DEBUG = 0
+media_folder_local = "~/Videos"
+media_folder_remote = "~/Videos"
+media_ext = []
+auth = ""
+cmd_auth = ""
+hosts = []
+# VLC http LUA port
+port = 0
+# Clients cmd port
+cmd_port = 0
\ No newline at end of file
diff --git a/static/script.js b/static/script.js
index 4b84966..f96ba56 100644
--- a/static/script.js
+++ b/static/script.js
@@ -2,7 +2,12 @@
const tl_cont_attr = {id:"tl_cont", ondrop: "drop(event, this)", ondragover:"allowDrop(event)"};
const tl_drag_attr = {id:"tl_drag", draggable:"true", ondragstart:"drag(event, this)"};
+// Config
+var timeline_color_cursor = "#FF8839";
+var timeline_color_bg = "#2EB8E6";
+
var src_id = "";
+var medias_status = {};
function updatePlaylist(){
var new_list = [];
@@ -72,7 +77,17 @@ function adjustTl() {
}
};
-function addElement(type, attr, meta = [], j = 0){
+function addAttr(id, attr, val , child=-1) {
+ var elem = document.getElementById(id);
+ if (child>-1){
+ elem = elem.children[child];
+ }
+ var att = document.createAttribute(attr);
+ att.value = val;
+ elem.setAttributeNode(att);
+};
+
+function addElement(type, attr, meta = 0, j = 0){
var elem = document.createElement(type);
var keys_array = Object.keys(attr);
for (i=0, l=keys_array.length;i
{{status_message}}
- Signal: + Link: @@ -56,18 +59,6 @@