aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJames Woglom <j@wogloms.net>2022-08-29 20:41:21 -0400
committerJames Woglom <j@wogloms.net>2022-08-29 20:41:21 -0400
commitf79c8fa7542822cd3edd542d646fc5881d3bb80e (patch)
tree286b2562995d0d5a8fd05fb13e678725266fa719 /app
parentPropagate configuration on load via downloads socket (diff)
downloadmetube-f79c8fa7542822cd3edd542d646fc5881d3bb80e.tar.gz
metube-f79c8fa7542822cd3edd542d646fc5881d3bb80e.tar.bz2
metube-f79c8fa7542822cd3edd542d646fc5881d3bb80e.zip
pass custom_directories from server to client
Diffstat (limited to 'app')
-rw-r--r--app/main.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/main.py b/app/main.py
index bbdfc87..56adc00 100644
--- a/app/main.py
+++ b/app/main.py
@@ -7,6 +7,7 @@ from aiohttp import web
import socketio
import logging
import json
+import pathlib
from ytdl import DownloadQueueNotifier, DownloadQueue
@@ -100,6 +101,18 @@ async def delete(request):
async def connect(sid, environ):
await sio.emit('all', serializer.encode(dqueue.get()), to=sid)
await sio.emit('configuration', serializer.encode(config), to=sid)
+ if config.CUSTOM_DIR:
+ await sio.emit('custom_directories', serializer.encode(get_custom_directories()), to=sid)
+
+def get_custom_directories():
+ path = pathlib.Path(config.DOWNLOAD_DIR)
+ # Recursively lists all subdirectories, and converts PosixPath objects to string
+ dirs = list(map(str, path.glob('**')))
+
+ if '.' in dirs:
+ dirs.remove('.')
+
+ return {"directories": dirs}
@routes.get(config.URL_PREFIX)
def index(request):
@@ -121,7 +134,7 @@ try:
app.add_routes(routes)
except ValueError as e:
if 'ui/dist/metube' in str(e):
- raise RuntimeError('Could not find the frontend UI static assets. Please run `node_modules/.bin/ng build`') from e
+ raise RuntimeError('Could not find the frontend UI static assets. Please run `node_modules/.bin/ng build` inside the ui folder') from e
raise e
bgstack15