aboutsummaryrefslogtreecommitdiff
path: root/ui/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/app')
-rw-r--r--ui/src/app/app.component.html4
-rw-r--r--ui/src/app/app.component.ts36
-rw-r--r--ui/src/app/downloads.service.ts7
3 files changed, 33 insertions, 14 deletions
diff --git a/ui/src/app/app.component.html b/ui/src/app/app.component.html
index 23dccce..4ca9a07 100644
--- a/ui/src/app/app.component.html
+++ b/ui/src/app/app.component.html
@@ -129,11 +129,11 @@
<fa-icon *ngIf="download.value.status == 'finished'" [icon]="faCheckCircle" style="color: green;"></fa-icon>
<fa-icon *ngIf="download.value.status == 'error'" [icon]="faTimesCircle" style="color: red;"></fa-icon>
</div>
- <span ngbTooltip="{{download.value.msg}}"><a *ngIf="!!download.value.filename; else noDownloadLink" href="download/{{download.value.filename | encodeURIComponent}}" target="_blank">{{ download.value.title }}</a></span>
+ <span ngbTooltip="{{download.value.msg}}"><a *ngIf="!!download.value.filename; else noDownloadLink" href="{{buildDownloadLink(download.value)}}" target="_blank">{{ download.value.title }}</a></span>
<ng-template #noDownloadLink>{{ download.value.title }}</ng-template>
</td>
<td>
- <button *ngIf="download.value.status == 'error'" type="button" class="btn btn-link" (click)="retryDownload(download.key, download.value.url, download.value.quality)"><fa-icon [icon]="faRedoAlt"></fa-icon></button>
+ <button *ngIf="download.value.status == 'error'" type="button" class="btn btn-link" (click)="retryDownload(download.key, download.value.url, download.value.quality, download.value.folder)"><fa-icon [icon]="faRedoAlt"></fa-icon></button>
</td>
<td>
<a href="{{download.value.url}}" target="_blank"><fa-icon [icon]="faExternalLinkAlt"></fa-icon></a>
diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts
index cdcd8f6..97ff020 100644
--- a/ui/src/app/app.component.ts
+++ b/ui/src/app/app.component.ts
@@ -4,7 +4,7 @@ import { faRedoAlt, faSun, faMoon, faExternalLinkAlt } from '@fortawesome/free-s
import { CookieService } from 'ngx-cookie-service';
import { map, Observable, of } from 'rxjs';
-import { DownloadsService, Status } from './downloads.service';
+import { Download, DownloadsService, Status } from './downloads.service';
import { MasterCheckboxComponent } from './master-checkbox.component';
import { Formats, Format, Quality } from './formats';
@@ -89,15 +89,19 @@ export class AppComponent implements AfterViewInit {
return this.downloads.configuration['CREATE_DIRS'] == 'true';
}
+ isAudioType() {
+ return this.quality == 'audio' || this.format == 'mp3';
+ }
+
getMatchingCustomDir() : Observable<string[]> {
return this.downloads.customDirsChanged.asObservable().pipe(map((output) => {
// Keep logic consistent with app/ytdl.py
- if (this.quality != 'audio' && this.format != 'mp3') {
- console.debug("Showing default download directories");
- return output["download_dir"];
- } else {
+ if (this.isAudioType()) {
console.debug("Showing audio-specific download directories");
return output["audio_download_dir"];
+ } else {
+ console.debug("Showing default download directories");
+ return output["download_dir"];
}
}));
}
@@ -146,13 +150,14 @@ export class AppComponent implements AfterViewInit {
this.quality = exists ? this.quality : 'best'
}
- addDownload(url?: string, quality?: string, format?: string) {
+ addDownload(url?: string, quality?: string, format?: string, folder?: string) {
url = url ?? this.addUrl
quality = quality ?? this.quality
format = format ?? this.format
+ folder = folder ?? this.folder
this.addInProgress = true;
- this.downloads.add(url, quality, format).subscribe((status: Status) => {
+ this.downloads.add(url, quality, format, folder).subscribe((status: Status) => {
if (status.status === 'error') {
alert(`Error adding URL: ${status.msg}`);
} else {
@@ -162,8 +167,8 @@ export class AppComponent implements AfterViewInit {
});
}
- retryDownload(key: string, url: string, quality: string, format: string) {
- this.addDownload(url, quality, format);
+ retryDownload(key: string, url: string, quality: string, format: string, folder: string) {
+ this.addDownload(url, quality, format, folder);
this.downloads.delById('done', [key]).subscribe();
}
@@ -182,4 +187,17 @@ export class AppComponent implements AfterViewInit {
clearFailedDownloads() {
this.downloads.delByFilter('done', dl => dl.status === 'error').subscribe();
}
+
+ buildDownloadLink(download: Download) {
+ let baseDir = 'download/';
+ if (download.quality == 'audio' || download.filename.endsWith('.mp3')) {
+ baseDir = 'audio_download/';
+ }
+
+ if (download.folder) {
+ baseDir += download.folder + '/';
+ }
+
+ return baseDir + encodeURIComponent(download.filename);
+ }
}
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<Status>('add', {url: url, quality: quality, format: format}).pipe(
+ public add(url: string, quality: string, format: string, folder: string) {
+ return this.http.post<Status>('add', {url: url, quality: quality, format: format, folder: folder}).pipe(
catchError(this.handleHTTPError)
);
}
bgstack15