aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/main.py15
-rw-r--r--ui/src/app/app.component.sass3
-rw-r--r--ui/src/app/downloads.service.ts10
3 files changed, 25 insertions, 3 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
diff --git a/ui/src/app/app.component.sass b/ui/src/app/app.component.sass
index 656fac2..d95fc0d 100644
--- a/ui/src/app/app.component.sass
+++ b/ui/src/app/app.component.sass
@@ -15,6 +15,9 @@
button.add-url
width: 100%
+.folder-dropdown-menu
+ width: 500px
+
$metube-section-color-bg: rgba(0,0,0,.07)
.metube-section-header
diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts
index eb7bac3..018f225 100644
--- a/ui/src/app/downloads.service.ts
+++ b/ui/src/app/downloads.service.ts
@@ -34,6 +34,7 @@ export class DownloadsService {
queueChanged = new Subject();
doneChanged = new Subject();
configuration = {};
+ custom_directories = {};
constructor(private http: HttpClient, private socket: MeTubeSocket) {
socket.fromEvent('all').subscribe((strdata: string) => {
@@ -76,10 +77,15 @@ export class DownloadsService {
this.doneChanged.next(null);
});
socket.fromEvent('configuration').subscribe((strdata: string) => {
- let data: string = JSON.parse(strdata);
+ let data = JSON.parse(strdata);
console.debug("got configuration:", data);
this.configuration = data;
- })
+ });
+ socket.fromEvent('custom_directories').subscribe((strdata: string) => {
+ let data = JSON.parse(strdata);
+ console.debug("got custom_directories:", data);
+ this.custom_directories = data["directories"];
+ });
}
handleHTTPError(error: HttpErrorResponse) {
bgstack15