aboutsummaryrefslogtreecommitdiff
path: root/ui/src/app/app.component.ts
diff options
context:
space:
mode:
authorAlex Shnitman <alexta69@gmail.com>2021-09-13 20:25:32 +0300
committerAlex Shnitman <alexta69@gmail.com>2021-09-13 20:25:32 +0300
commitee0fcc39937ce0598329ce246c17947ec7cac7fd (patch)
treea025b02a80abc6b0d1fd74e93e4866a8c92270d4 /ui/src/app/app.component.ts
parentupgrade to angular 12 (diff)
downloadmetube-ee0fcc39937ce0598329ce246c17947ec7cac7fd.tar.gz
metube-ee0fcc39937ce0598329ce246c17947ec7cac7fd.tar.bz2
metube-ee0fcc39937ce0598329ce246c17947ec7cac7fd.zip
allow selecting MP4 in the GUI
Diffstat (limited to 'ui/src/app/app.component.ts')
-rw-r--r--ui/src/app/app.component.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts
index 8b668c6..55f7e6e 100644
--- a/ui/src/app/app.component.ts
+++ b/ui/src/app/app.component.ts
@@ -1,6 +1,7 @@
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { faTrashAlt, faCheckCircle, faTimesCircle } from '@fortawesome/free-regular-svg-icons';
import { faRedoAlt } from '@fortawesome/free-solid-svg-icons';
+import { CookieService } from 'ngx-cookie-service';
import { DownloadsService, Status } from './downloads.service';
import { MasterCheckboxComponent } from './master-checkbox.component';
@@ -20,7 +21,12 @@ export class AppComponent implements AfterViewInit {
{id: "480p", text: "480p"},
{id: "audio", text: "Audio only"}
];
- quality: string = "best";
+ quality: string;
+ formats: Array<Object> = [
+ {id: "any", text: "Any"},
+ {id: "mp4", text: "MP4"}
+ ];
+ format: string;
addInProgress = false;
@ViewChild('queueMasterCheckbox') queueMasterCheckbox: MasterCheckboxComponent;
@@ -35,7 +41,9 @@ export class AppComponent implements AfterViewInit {
faTimesCircle = faTimesCircle;
faRedoAlt = faRedoAlt;
- constructor(public downloads: DownloadsService) {
+ constructor(public downloads: DownloadsService, private cookieService: CookieService) {
+ this.quality = cookieService.get('metube_quality') || 'best';
+ this.format = cookieService.get('metube_format') || 'any';
}
ngAfterViewInit() {
@@ -62,6 +70,14 @@ export class AppComponent implements AfterViewInit {
return 1;
}
+ qualityChanged() {
+ this.cookieService.set('metube_quality', this.quality, { expires: 3650 });
+ }
+
+ formatChanged() {
+ this.cookieService.set('metube_format', this.format, { expires: 3650 });
+ }
+
queueSelectionChanged(checked: number) {
this.queueDelSelected.nativeElement.disabled = checked == 0;
}
@@ -70,12 +86,13 @@ export class AppComponent implements AfterViewInit {
this.doneDelSelected.nativeElement.disabled = checked == 0;
}
- addDownload(url?: string, quality?: string) {
+ addDownload(url?: string, quality?: string, format?: string) {
url = url ?? this.addUrl
quality = quality ?? this.quality
+ format = format ?? this.format
this.addInProgress = true;
- this.downloads.add(url, quality).subscribe((status: Status) => {
+ this.downloads.add(url, quality, format).subscribe((status: Status) => {
if (status.status === 'error') {
alert(`Error adding URL: ${status.msg}`);
} else {
@@ -85,8 +102,8 @@ export class AppComponent implements AfterViewInit {
});
}
- retryDownload(key: string, quality:string){
- this.addDownload(key, quality);
+ retryDownload(key: string, quality: string, format: string) {
+ this.addDownload(key, quality, format);
this.downloads.delById('done', [key]).subscribe();
}
bgstack15