Empty playlist now reflects on timeline, fix file sync CA path

This commit is contained in:
ABelliqueux 2022-10-18 19:54:18 +02:00
parent f4682a5640
commit 703083fa66
3 changed files with 37 additions and 13 deletions

12
app.py
View File

@ -85,7 +85,6 @@ def isup(host_l, port):
import socket import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if useSSL: if useSSL:
#sslcontext = ssl.create_default_context(cafile=host_l + ".crt")
sslcontext = ssl.create_default_context() sslcontext = ssl.create_default_context()
if os.path.exists(CAfile): if os.path.exists(CAfile):
sslcontext.load_verify_locations(cafile=CAfile) sslcontext.load_verify_locations(cafile=CAfile)
@ -101,7 +100,7 @@ def isup(host_l, port):
return 1 return 1
except (socket.error, socket.timeout) as e: except (socket.error, socket.timeout) as e:
if DEBUG: if DEBUG:
print("Error on connect to " + host_l + ": %s" % e) print("Error on connect to " + host_l + ":" + str(port) + ": %s" % e)
return 0 return 0
finally: finally:
s.close() s.close()
@ -136,8 +135,7 @@ def httpUpload(filename, hostl, trailing_slash=1):
filename = "/" + filename filename = "/" + filename
files = { "file":( filename, open( media_folder_local + filename, "rb"), "multipart/form-data") } files = { "file":( filename, open( media_folder_local + filename, "rb"), "multipart/form-data") }
print(files) print(files)
# ~ resp = requests.post(url, files=files, auth=('', auth ), verify=hostl + ".crt") resp = requests.post(url, files=files, headers=headers, verify=CAfile)
resp = requests.post(url, files=files, headers=headers, verify=hostl + ".crt")
print(resp.text) print(resp.text)
if resp.ok: if resp.ok:
return 1 return 1
@ -203,7 +201,6 @@ def sec2min(duration):
# VLC lua utilities # VLC lua utilities
def sendCommand(host, arg0, arg1, arg2): def sendCommand(host, arg0, arg1, arg2):
#conn = http.client.HTTPConnection( host + ":" + str(port), timeout=3 )
portl = port portl = port
# Build request # Build request
req = "/requests/status.xml" req = "/requests/status.xml"
@ -233,20 +230,16 @@ def sendCommand(host, arg0, arg1, arg2):
req = req + "&input=file://" + media_folder_remote + "/" + arg1 req = req + "&input=file://" + media_folder_remote + "/" + arg1
# Send request # Send request
if useSSL: if useSSL:
#sslcontext = ssl.create_default_context(cafile=host_l + ".crt")
sslcontext = ssl.create_default_context() sslcontext = ssl.create_default_context()
if os.path.exists(CAfile): if os.path.exists(CAfile):
sslcontext.load_verify_locations(cafile=CAfile) sslcontext.load_verify_locations(cafile=CAfile)
else: else:
sslcontext.check_hostname = False sslcontext.check_hostname = False
sslcontext.verify_mode = ssl.CERT_NONE sslcontext.verify_mode = ssl.CERT_NONE
# ~ if useSSL:
# ~ sslcontext = ssl.create_default_context(cafile=host + ".crt")
conn = http.client.HTTPSConnection( host + ":" + str(portl), timeout=3, context = sslcontext ) conn = http.client.HTTPSConnection( host + ":" + str(portl), timeout=3, context = sslcontext )
else: else:
conn = http.client.HTTPConnection( host + ":" + str(portl), timeout=3 ) conn = http.client.HTTPConnection( host + ":" + str(portl), timeout=3 )
try: try:
# ~ conn.request( "GET", req, headers={"Authorization":"Basic " + auth} )
conn.request( "GET", req, headers = headers ) conn.request( "GET", req, headers = headers )
except: except:
return "Connection to " + host + " was refused on port " + str(portl) return "Connection to " + host + " was refused on port " + str(portl)
@ -366,7 +359,6 @@ def sync(host):
def action(host, arg0, arg1, arg2): def action(host, arg0, arg1, arg2):
status_message = "Idle" status_message = "Idle"
if arg0 not in cmd: if arg0 not in cmd:
# ~ return "<p>Wrong command</p>"
status_message = "<p>Wrong command</p>" status_message = "<p>Wrong command</p>"
elif host == "all": elif host == "all":
resp = [] resp = []

View File

@ -6,7 +6,29 @@ services: # add
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "8080:8080" - "8080:8080"
command: "sh -c 'pip install -r requirements.txt && python app.py'" - "8887:8887"
- "8888:8888"
#~ command: "sh -c 'sleep 3600'"
command: "sh -c 'pip install -r requirements.txt && sleep 3600'"
volumes: volumes:
- .:/app - .:/app
- ../medias:/medias - ../medias:/medias
networks:
- dockervlan
networks:
dockervlan:
name: dockervlan
driver: macvlan
driver_opts:
parent: wlo1
ipam:
config:
- subnet: "10.42.0.1/24"
ip_range: "10.42.0.1/26"
gateway: "10.42.0.1"
#~ docker network create -d macvlan \
#~ --subnet=10.42.0.1/24 \
#~ --gateway=10.42.0.1 \
#~ -o parent=wlo1 \
#~ vpi-macvlan-net

View File

@ -129,7 +129,7 @@ addEventListener("DOMContentLoaded", function() {
// On recupere la valeur de value="" sur le bouton // On recupere la valeur de value="" sur le bouton
var clickedButton = event.currentTarget; var clickedButton = event.currentTarget;
var command = clickedButton.value; var command = clickedButton.value;
if (( command == "/10.42.0.135/reboot" ) || ( command == "/10.42.0.135/poweroff" )) { if ( command.indexOf("/reboot" ) > -1 || command.indexOf("/poweroff") > -1 ) {
if ( !confirm("Êtes vous certain de vouloir effectuer cette action ?") ) { if ( !confirm("Êtes vous certain de vouloir effectuer cette action ?") ) {
return 0; return 0;
} }
@ -202,6 +202,14 @@ function parseResult(command, infos_array) {
document.getElementById("playlist_"+infos_array[i].host).innerHTML = infos_array[i].leng + " item(s) in playlist - " + infos_array[i].duration; document.getElementById("playlist_"+infos_array[i].host).innerHTML = infos_array[i].leng + " item(s) in playlist - " + infos_array[i].duration;
// Build html table and timeline // Build html table and timeline
var items_array = Array.from(infos_array[i].items); var items_array = Array.from(infos_array[i].items);
console.log(items_array.length);
if (items_array.length == 0){
var child_list = Array.from(document.getElementById("timeline").children);
for(i=0,l=child_list.length;i<l;i++){
document.getElementById("timeline").removeChild(child_list[i]);
};
break;
}
var html_table = "<table>" + var html_table = "<table>" +
"<tr>" + "<tr>" +
"<th>Id</th>" + "<th>Id</th>" +
@ -222,9 +230,11 @@ function parseResult(command, infos_array) {
addAttr("timeline", "length", len); addAttr("timeline", "length", len);
if ( len < items_array.length ) { if ( len < items_array.length ) {
document.getElementById("timeline").appendChild( addElement("div", tl_cont_attr, 0, len) ); document.getElementById("timeline").appendChild( addElement("div", tl_cont_attr, 0, len) );
} }
document.getElementById(tl_cont_attr.id + j).replaceChildren(child_node); document.getElementById(tl_cont_attr.id + j).replaceChildren(child_node);
// Adjust elements width
adjustTl(); adjustTl();
// Highlight currently playing element
if (item_meta[3] != ""){ if (item_meta[3] != ""){
document.getElementById(tl_cont_attr.id + j).children[0].style.borderBottom = "4px solid " + timeline_color_cursor; document.getElementById(tl_cont_attr.id + j).children[0].style.borderBottom = "4px solid " + timeline_color_cursor;
document.getElementById(tl_cont_attr.id + j).children[0].style.fontWeight = "bold"; document.getElementById(tl_cont_attr.id + j).children[0].style.fontWeight = "bold";