From c5f7cd1874b12e35b7731fb712f7926299f180c6 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Tue, 28 Sep 2021 21:36:36 -0600 Subject: [PATCH] Converted input on the home page to textarea, maintaining same style but allowing an arbitrary number of urls to be entered --- src/app/app.module.ts | 2 ++ src/app/main/main.component.css | 9 ++++++ src/app/main/main.component.html | 6 ++-- src/app/main/main.component.ts | 50 ++++++++++++++++++++++---------- 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 410a412..9277a4f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -30,6 +30,7 @@ import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { ClipboardModule } from '@angular/cdk/clipboard'; +import { TextFieldModule } from '@angular/cdk/text-field'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; @@ -175,6 +176,7 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible MatChipsModule, DragDropModule, ClipboardModule, + TextFieldModule, NgxFileDropModule, AvatarModule, ContentLoaderModule, diff --git a/src/app/main/main.component.css b/src/app/main/main.component.css index 5a712ae..0242439 100644 --- a/src/app/main/main.component.css +++ b/src/app/main/main.component.css @@ -151,4 +151,13 @@ mat-form-field.mat-form-field { .download-progress-bar { width: 125px; } +} + +.url-input { + padding-right: 25px; + overflow-y: hidden; +} + +.url-input::-webkit-scrollbar { + display: none; } \ No newline at end of file diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html index 18a4ea9..e8d14a8 100644 --- a/src/app/main/main.component.html +++ b/src/app/main/main.component.html @@ -8,9 +8,9 @@
- + - +
@@ -65,7 +65,7 @@ Only Audio - + Autoplay diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 93a8d53..6d57250 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -406,24 +406,28 @@ export class MainComponent implements OnInit { const selected_quality = this.selectedQuality; this.selectedQuality = ''; - this.downloadingfile = true; - this.postsService.downloadFile(this.url, type, (selected_quality === '' ? null : selected_quality), - customQualityConfiguration, customArgs, additionalArgs, customOutput, youtubeUsername, youtubePassword, cropFileSettings).subscribe(res => { - this.current_download = res['download']; - this.downloads.push(res['download']); - this.download_uids.push(res['download']['uid']); - }, () => { // can't access server - this.downloadingfile = false; - this.current_download = null; - this.postsService.openSnackBar('Download failed!', 'OK.'); - }); - if (!this.autoplay) { - const download_queued_message = $localize`Download for ${this.url}:url: has been queued!`; - this.postsService.openSnackBar(download_queued_message); - this.url = ''; + const urls = this.getURLArray(this.url); + for (let i = 0; i < urls.length; i++) { + const url = urls[i]; + this.postsService.downloadFile(url, type, (selected_quality === '' ? null : selected_quality), + customQualityConfiguration, customArgs, additionalArgs, customOutput, youtubeUsername, youtubePassword, cropFileSettings).subscribe(res => { + this.current_download = res['download']; + this.downloads.push(res['download']); + this.download_uids.push(res['download']['uid']); + }, () => { // can't access server this.downloadingfile = false; + this.current_download = null; + this.postsService.openSnackBar('Download failed!', 'OK.'); + }); + + if (!this.autoplay && urls.length === 1) { + const download_queued_message = $localize`Download for ${url}:url: has been queued!`; + this.postsService.openSnackBar(download_queued_message); + this.url = ''; + this.downloadingfile = false; + } } } @@ -540,6 +544,13 @@ export class MainComponent implements OnInit { // checks if url is a valid URL ValidURL(str: string): boolean { + // mark multiple urls as valid but don't get additional info + const urls = this.getURLArray(str); + if (urls.length > 1) { + this.autoplay = false; + return true; + } + // tslint:disable-next-line: max-line-length const strRegex = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/; const re = new RegExp(strRegex); @@ -587,6 +598,9 @@ export class MainComponent implements OnInit { } getSimulatedOutput(): void { + const urls = this.getURLArray(this.url); + if (urls.length > 1) return; + // this function should be very similar to downloadClicked() const customArgs = (this.customArgsEnabled && this.replaceArgs ? this.customArgs : null); const additionalArgs = (this.customArgsEnabled && !this.replaceArgs ? this.customArgs : null); @@ -807,4 +821,10 @@ export class MainComponent implements OnInit { reloadRecentVideos(): void { this.postsService.files_changed.next(true); } + + getURLArray(url_str: string): Array { + let lines = url_str.split('\n'); + lines = lines.filter(line => line); + return lines; + } }