Skip to content

Commit

Permalink
Merge pull request #587 from PikuZheng/download-multi
Browse files Browse the repository at this point in the history
Download multiple files from MeTube
  • Loading branch information
alexta69 authored Feb 7, 2025
2 parents d437d95 + 4d145ba commit 2e0ff2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneClearCompleted (click)="clearCompletedDownloads()"><fa-icon [icon]="faCheckCircle"></fa-icon>&nbsp; Clear completed</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneClearFailed (click)="clearFailedDownloads()"><fa-icon [icon]="faTimesCircle"></fa-icon>&nbsp; Clear failed</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneRetryFailed (click)="retryFailedDownloads()"><fa-icon [icon]="faRedoAlt"></fa-icon>&nbsp; Retry failed</button>
<button type="button" class="btn btn-link text-decoration-none px-0 me-4" disabled #doneDownloadSelected (click)="downloadSelectedFiles()"><fa-icon [icon]="faDownload"></fa-icon>&nbsp; Download Selected</button>
</div>
<div class="overflow-auto">
<table class="table">
Expand Down
16 changes: 16 additions & 0 deletions ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class AppComponent implements AfterViewInit {
@ViewChild('doneClearCompleted') doneClearCompleted: ElementRef;
@ViewChild('doneClearFailed') doneClearFailed: ElementRef;
@ViewChild('doneRetryFailed') doneRetryFailed: ElementRef;
@ViewChild('doneDownloadSelected') doneDownloadSelected: ElementRef;

faTrashAlt = faTrashAlt;
faCheckCircle = faCheckCircle;
Expand Down Expand Up @@ -186,6 +187,7 @@ export class AppComponent implements AfterViewInit {

doneSelectionChanged(checked: number) {
this.doneDelSelected.nativeElement.disabled = checked == 0;
this.doneDownloadSelected.nativeElement.disabled = checked == 0;
}

setQualities() {
Expand Down Expand Up @@ -254,6 +256,20 @@ export class AppComponent implements AfterViewInit {
});
}

downloadSelectedFiles() {
this.downloads.done.forEach((dl, key) => {
if (dl.status === 'finished' && dl.checked) {
const link = document.createElement('a');
link.href = this.buildDownloadLink(dl);
link.setAttribute('download', dl.filename);
link.setAttribute('target', '_self');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
});
}

buildDownloadLink(download: Download) {
let baseDir = this.downloads.configuration["PUBLIC_HOST_URL"];
if (download.quality == 'audio' || download.filename.endsWith('.mp3')) {
Expand Down

0 comments on commit 2e0ff2b

Please sign in to comment.