From 4a9f55adda55a35c67c5e6699aa71fa56295c9b4 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Mon, 29 Aug 2022 20:27:34 -0400 Subject: Propagate configuration on load via downloads socket --- ui/src/app/downloads.service.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 8580a70..eb7bac3 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -33,6 +33,7 @@ export class DownloadsService { done = new Map(); queueChanged = new Subject(); doneChanged = new Subject(); + configuration = {}; constructor(private http: HttpClient, private socket: MeTubeSocket) { socket.fromEvent('all').subscribe((strdata: string) => { @@ -74,6 +75,11 @@ export class DownloadsService { this.done.delete(data); this.doneChanged.next(null); }); + socket.fromEvent('configuration').subscribe((strdata: string) => { + let data: string = JSON.parse(strdata); + console.debug("got configuration:", data); + this.configuration = data; + }) } handleHTTPError(error: HttpErrorResponse) { -- cgit From f79c8fa7542822cd3edd542d646fc5881d3bb80e Mon Sep 17 00:00:00 2001 From: James Woglom Date: Mon, 29 Aug 2022 20:41:21 -0400 Subject: pass custom_directories from server to client --- ui/src/app/downloads.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ui/src/app/downloads.service.ts') 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) { -- cgit From 8abacc2a3610701e6258d9c79ee0c577ad2b2376 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Mon, 29 Aug 2022 21:52:54 -0400 Subject: almost functional with selectize --- ui/src/app/downloads.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 018f225..42ffe6d 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -33,8 +33,8 @@ export class DownloadsService { done = new Map(); queueChanged = new Subject(); doneChanged = new Subject(); + customDirsChanged = new Subject(); configuration = {}; - custom_directories = {}; constructor(private http: HttpClient, private socket: MeTubeSocket) { socket.fromEvent('all').subscribe((strdata: string) => { @@ -84,7 +84,8 @@ export class DownloadsService { socket.fromEvent('custom_directories').subscribe((strdata: string) => { let data = JSON.parse(strdata); console.debug("got custom_directories:", data); - this.custom_directories = data["directories"]; + let customDirectories = data["directories"]; + this.customDirsChanged.next(customDirectories); }); } -- cgit From ba712fc071398e615ead822c8bd81aad42a90c8f Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 30 Aug 2022 00:55:16 -0400 Subject: Fill in download_dir or audio_download_dir on launch --- ui/src/app/downloads.service.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 42ffe6d..1fd75e3 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpErrorResponse } from '@angular/common/http'; -import { of, Subject } from 'rxjs'; +import { Observable, of, Subject } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { MeTubeSocket } from './metube-socket'; @@ -33,7 +33,7 @@ export class DownloadsService { done = new Map(); queueChanged = new Subject(); doneChanged = new Subject(); - customDirsChanged = new Subject(); + customDirs = new Subject>(); configuration = {}; constructor(private http: HttpClient, private socket: MeTubeSocket) { @@ -81,11 +81,10 @@ export class DownloadsService { console.debug("got configuration:", data); this.configuration = data; }); - socket.fromEvent('custom_directories').subscribe((strdata: string) => { + socket.fromEvent('custom_dirs').subscribe((strdata: string) => { let data = JSON.parse(strdata); - console.debug("got custom_directories:", data); - let customDirectories = data["directories"]; - this.customDirsChanged.next(customDirectories); + console.debug("got custom_dirs:", data); + this.customDirs.next(data); }); } -- cgit From 52e3307d99b6f809c6a7a281b2a33bbc67c0e006 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 30 Aug 2022 00:58:19 -0400 Subject: switch between audio and default custom directories on change --- ui/src/app/downloads.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 1fd75e3..a2ea912 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -33,8 +33,10 @@ export class DownloadsService { done = new Map(); queueChanged = new Subject(); doneChanged = new Subject(); - customDirs = new Subject>(); + customDirsChanged = new Subject(); + configuration = {}; + customDirs = {}; constructor(private http: HttpClient, private socket: MeTubeSocket) { socket.fromEvent('all').subscribe((strdata: string) => { @@ -84,7 +86,8 @@ export class DownloadsService { socket.fromEvent('custom_dirs').subscribe((strdata: string) => { let data = JSON.parse(strdata); console.debug("got custom_dirs:", data); - this.customDirs.next(data); + this.customDirs = data; + this.customDirsChanged.next(data); }); } -- cgit From 63baa1fc25a7ee02832b043bb38470fe611cfb01 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 30 Aug 2022 01:22:24 -0400 Subject: Link to audio files and those with custom folders properly --- ui/src/app/downloads.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index a2ea912..77d2fed 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -9,13 +9,14 @@ export interface Status { msg?: string; } -interface Download { +export interface Download { id: string; title: string; url: string, status: string; msg: string; filename: string; + folder: string; quality: string; percent: number; speed: number; @@ -96,8 +97,8 @@ export class DownloadsService { return of({status: 'error', msg: msg}) } - public add(url: string, quality: string, format: string) { - return this.http.post('add', {url: url, quality: quality, format: format}).pipe( + public add(url: string, quality: string, format: string, folder: string) { + return this.http.post('add', {url: url, quality: quality, format: format, folder: folder}).pipe( catchError(this.handleHTTPError) ); } -- cgit From 18466312ff5b114f9d79f1282e12a386feb1edf7 Mon Sep 17 00:00:00 2001 From: Chris Kanich Date: Fri, 3 Feb 2023 10:33:51 -0600 Subject: unique downloads of identically named videos --- ui/src/app/downloads.service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ui/src/app/downloads.service.ts') diff --git a/ui/src/app/downloads.service.ts b/ui/src/app/downloads.service.ts index 77d2fed..e1a134d 100644 --- a/ui/src/app/downloads.service.ts +++ b/ui/src/app/downloads.service.ts @@ -52,20 +52,20 @@ export class DownloadsService { }); socket.fromEvent('added').subscribe((strdata: string) => { let data: Download = JSON.parse(strdata); - this.queue.set(data.id, data); + this.queue.set(data.url, data); this.queueChanged.next(null); }); socket.fromEvent('updated').subscribe((strdata: string) => { let data: Download = JSON.parse(strdata); - let dl: Download = this.queue.get(data.id); + let dl: Download = this.queue.get(data.url); data.checked = dl.checked; data.deleting = dl.deleting; - this.queue.set(data.id, data); + this.queue.set(data.url, data); }); socket.fromEvent('completed').subscribe((strdata: string) => { let data: Download = JSON.parse(strdata); - this.queue.delete(data.id); - this.done.set(data.id, data); + this.queue.delete(data.url); + this.done.set(data.url, data); this.queueChanged.next(null); this.doneChanged.next(null); }); @@ -110,7 +110,7 @@ export class DownloadsService { public delByFilter(where: string, filter: (dl: Download) => boolean) { let ids: string[] = []; - this[where].forEach((dl: Download) => { if (filter(dl)) ids.push(dl.id) }); + this[where].forEach((dl: Download) => { if (filter(dl)) ids.push(dl.url) }); return this.delById(where, ids); } } -- cgit