diff options
author | asuyou <asuyou@users.noreply.github.com> | 2021-10-28 11:19:17 +0100 |
---|---|---|
committer | asuyou <asuyou@users.noreply.github.com> | 2021-10-28 11:19:17 +0100 |
commit | d0518142599d326bac12a66e0173eb0e2da2c66d (patch) | |
tree | 636f6f54b93deda350af0389e93283e4a08af660 /ui/src/app/app.component.ts | |
parent | Added simple MP3 support (diff) | |
download | metube-d0518142599d326bac12a66e0173eb0e2da2c66d.tar.gz metube-d0518142599d326bac12a66e0173eb0e2da2c66d.tar.bz2 metube-d0518142599d326bac12a66e0173eb0e2da2c66d.zip |
Added quality choice based on format
Diffstat (limited to 'ui/src/app/app.component.ts')
-rw-r--r-- | ui/src/app/app.component.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index a86bbe1..28b9539 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -5,6 +5,7 @@ import { CookieService } from 'ngx-cookie-service'; import { DownloadsService, Status } from './downloads.service'; import { MasterCheckboxComponent } from './master-checkbox.component'; +import { Formats, Format, Quality } from './formats'; @Component({ selector: 'app-root', @@ -13,20 +14,9 @@ import { MasterCheckboxComponent } from './master-checkbox.component'; }) export class AppComponent implements AfterViewInit { addUrl: string; - qualities: Array<Object> = [ - {id: "best", text: "Best"}, - {id: "1440p", text: "1440p"}, - {id: "1080p", text: "1080p"}, - {id: "720p", text: "720p"}, - {id: "480p", text: "480p"}, - {id: "audio", text: "Audio only"} - ]; + formats: Format[] = Formats; + qualities: Quality[]; quality: string; - formats: Array<Object> = [ - {id: "any", text: "Any"}, - {id: "mp4", text: "MP4"}, - {id: "mp3", text: "MP3"} - ]; format: string; addInProgress = false; @@ -45,6 +35,8 @@ export class AppComponent implements AfterViewInit { constructor(public downloads: DownloadsService, private cookieService: CookieService) { this.quality = cookieService.get('metube_quality') || 'best'; this.format = cookieService.get('metube_format') || 'any'; + // Needs to be set or qualities won't automatically be set + this.setQualities() } ngAfterViewInit() { @@ -77,6 +69,8 @@ export class AppComponent implements AfterViewInit { formatChanged() { this.cookieService.set('metube_format', this.format, { expires: 3650 }); + // Updates to use qualities available + this.setQualities() } queueSelectionChanged(checked: number) { @@ -87,6 +81,11 @@ export class AppComponent implements AfterViewInit { this.doneDelSelected.nativeElement.disabled = checked == 0; } + setQualities() { + // qualities for specific format + this.qualities = this.formats.find(el => el.id == this.format).qualities + } + addDownload(url?: string, quality?: string, format?: string) { url = url ?? this.addUrl quality = quality ?? this.quality |