Expand remote media folder, playlist check for locale

This commit is contained in:
ABelliqueux 2022-11-15 16:00:33 +01:00
parent 82a67286ea
commit 48183de587
4 changed files with 15 additions and 11 deletions

16
app.py
View File

@ -78,7 +78,9 @@ cmd_server = [
# Configuration
debug = app.config['DEFAULT']['debug']
media_folder_remote = os.path.expanduser(app.config['DEFAULT']['media_folder_remote'])
pi_user = app.config['DEFAULT']['pi_user']
media_folder_remote = app.config['DEFAULT']['media_folder_remote']
media_folder_remote_expanded = media_folder_remote.replace("~/", "/home/{}/".format(pi_user))
media_folder_local = os.path.expanduser(app.config['DEFAULT']['media_folder_local'])
media_exts = app.config['DEFAULT']['media_exts']
auth = str(base64.b64encode(str(":" + app.config['DEFAULT']['vlc_auth']).encode('utf-8')), 'utf-8')
@ -307,8 +309,8 @@ def get_playlist(host, xml_data, m3u=0):
playlist = []
item_list = []
playlist_duration = 0
if xml_data.find("./node") and xml_data.find("./node").get('name') == _("Playlist"):
# VLC's playlist node name can change according to the locale on the client, so check for this too.
if xml_data.find("./node") and (xml_data.find("./node").get('name') == "Playlist" or xml_data.find("./node").get('name') == _("Playlist")):
print("HAHAHAH")
playlist = xml_data.findall("./node/leaf")
@ -363,7 +365,7 @@ def send_pilpil_command(host, arg0, arg1, arg2):
if debug:
print("Brosing {}".format(media_folder_remote))
# Browse remote media folder
media_folder_remote_URL = quote(media_folder_remote)
media_folder_remote_URL = quote(media_folder_remote_expanded)
HTTP_request = "/requests/browse.xml?uri=file://{}".format(media_folder_remote_URL)
if debug:
print("requesting url {} to {}:{}".format(HTTP_request, host, port_))
@ -387,7 +389,7 @@ def send_pilpil_command(host, arg0, arg1, arg2):
HTTP_request = HTTP_request + "&val=" + arg1
elif (arg0 == "enqueue") or (arg0 == "add") :
# Add 'input' url parameter
HTTP_request = HTTP_request + "&input=file://" + quote(media_folder_remote) + "/" + arg1
HTTP_request = HTTP_request + "&input=file://" + quote(media_folder_remote_expanded) + "/" + arg1
# Send request and get data response
data = send_HTTP_request(host, port_, time_out=3, request_=HTTP_request)
@ -473,11 +475,11 @@ def sync(host):
return str(current_upload)
elif host == "all":
for hostl in hosts_available:
size += sync_media_folder(media_folder_local, media_folder_remote, hostl, cmd_port)
size += sync_media_folder(media_folder_local, media_folder_remote_expanded, hostl, cmd_port)
# ~ th = threading.Thread(target=blink_pi, args=(16,))
# ~ th.start()
else:
size = sync_media_folder(media_folder_local, media_folder_remote, host, cmd_port)
size = sync_media_folder(media_folder_local, media_folder_remote_expanded, host, cmd_port)
return str(size)
@app.route("/<host>/<arg0>/", defaults = { "arg1": "null", "arg2": "null" })

View File

@ -62,6 +62,7 @@ sha256 :
# DONE :
* webgui : Increase live host scan when host first found
* webgui : Btn hover/press fixed
* webgui : file selection/enqueuing
* server : Disable ssl verif for isup()
* server : Add blink command
* client : rt8821cu driver back

View File

@ -1,5 +1,6 @@
[DEFAULT]
debug = 0
pi_user = "pil"
useSSL = false
CAfile = "selfCA.crt"
# scp, rsync, http

View File

@ -1,17 +1,17 @@
[DEFAULT]
debug = 1
useSSL = false
pi_user = "pil"
useSSL = true
CAfile = "selfCA.crt"
# scp, rsync, http
sync_facility = "http"
media_folder_local = "../medias"
media_folder_remote = "~/Vidéos"
media_folder_remote = "~/Videos"
media_exts = ["mp4", "avi", "mkv"]
vlc_auth = "secret"
# OnNlY3JldA==
cmd_auth = "secret"
#hosts = ["10.42.0.10", "10.42.0.11"]
hosts = ["127.0.0.1"]
hosts = ["10.42.0.10", "10.42.0.11"]
# VLC http LUA port
vlc_port = 8887
# Clients cmd port