mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-18 02:30:55 +03:00
Fixed issue where errored downloads would result in an infinite loop of error messages in the home page
Added dialog to view error from an errored out download
This commit is contained in:
@@ -545,7 +545,7 @@ async function getVideoInfoByURL(url, args = [], download_uid = null) {
|
||||
const error = `Error while retrieving info on video with URL ${url} with the following message: output JSON could not be parsed. Output JSON: ${output}`;
|
||||
logger.error(error);
|
||||
if (download_uid) {
|
||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {error: error, paused: true, running: false});
|
||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {error: error, finished: true, running: false});
|
||||
}
|
||||
resolve(null);
|
||||
}
|
||||
@@ -556,7 +556,7 @@ async function getVideoInfoByURL(url, args = [], download_uid = null) {
|
||||
}
|
||||
if (download_uid) {
|
||||
const error = 'Failed to get info, see server logs for specific error.';
|
||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {error: err.stderr ? err.stderr : error, paused: true, running: false});
|
||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {error: err.stderr ? err.stderr : error, finished: true, running: false});
|
||||
}
|
||||
resolve(null);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
<button *ngIf="!element.paused" (click)="cancelDownload(element.uid)" mat-icon-button matTooltip="Cancel" i18n-matTooltip="Cancel"><mat-icon>cancel</mat-icon></button>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="element.finished">
|
||||
<button (click)="watchContent(element)" mat-icon-button matTooltip="Watch content" i18n-matTooltip="Watch content"><mat-icon>smart_display</mat-icon></button>
|
||||
<button *ngIf="!element.error" (click)="watchContent(element)" mat-icon-button matTooltip="Watch content" i18n-matTooltip="Watch content"><mat-icon>smart_display</mat-icon></button>
|
||||
<button *ngIf="element.error" (click)="showError(element)" mat-icon-button matTooltip="Show error" i18n-matTooltip="Show error"><mat-icon>warning</mat-icon></button>
|
||||
<button (click)="restartDownload(element.uid)" mat-icon-button matTooltip="Restart" i18n-matTooltip="Restart"><mat-icon>restart_alt</mat-icon></button>
|
||||
</ng-container>
|
||||
<button *ngIf="element.finished || element.paused" (click)="clearDownload(element.uid)" mat-icon-button matTooltip="Clear" i18n-matTooltip="Clear"><mat-icon>delete</mat-icon></button>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit, OnDestroy, ViewChild, Input } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ViewChild, Input, EventEmitter } from '@angular/core';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
import { trigger, transition, animateChild, stagger, query, style, animate } from '@angular/animations';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -7,6 +7,7 @@ import { MatTableDataSource } from '@angular/material/table';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ConfirmDialogComponent } from 'app/dialogs/confirm-dialog/confirm-dialog.component';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { Clipboard } from '@angular/cdk/clipboard';
|
||||
|
||||
@Component({
|
||||
selector: 'app-downloads',
|
||||
@@ -54,10 +55,10 @@ export class DownloadsComponent implements OnInit, OnDestroy {
|
||||
running_download_exists = false;
|
||||
|
||||
STEP_INDEX_TO_LABEL = {
|
||||
0: 'Creating download',
|
||||
1: 'Getting info',
|
||||
2: 'Downloading file',
|
||||
3: 'Complete'
|
||||
0: $localize`Creating download`,
|
||||
1: $localize`Getting info`,
|
||||
2: $localize`Downloading file`,
|
||||
3: $localize`Complete`
|
||||
}
|
||||
|
||||
displayedColumns: string[] = ['date', 'title', 'stage', 'subscription', 'progress', 'actions'];
|
||||
@@ -72,7 +73,7 @@ export class DownloadsComponent implements OnInit, OnDestroy {
|
||||
return result;
|
||||
}
|
||||
|
||||
constructor(public postsService: PostsService, private router: Router, private dialog: MatDialog) { }
|
||||
constructor(public postsService: PostsService, private router: Router, private dialog: MatDialog, private clipboard: Clipboard) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.postsService.initialized) {
|
||||
@@ -229,6 +230,27 @@ export class DownloadsComponent implements OnInit, OnDestroy {
|
||||
|
||||
return downloads_old;
|
||||
}
|
||||
|
||||
showError(download) {
|
||||
const copyToClipboardEmitter = new EventEmitter<boolean>();
|
||||
this.dialog.open(ConfirmDialogComponent, {
|
||||
data: {
|
||||
dialogTitle: $localize`Error for ${download['url']}:url:`,
|
||||
dialogText: download['error'],
|
||||
submitText: $localize`Copy to clipboard`,
|
||||
cancelText: $localize`Close`,
|
||||
closeOnSubmit: false,
|
||||
onlyEmitOnDone: true,
|
||||
doneEmitter: copyToClipboardEmitter
|
||||
}
|
||||
});
|
||||
copyToClipboardEmitter.subscribe(done => {
|
||||
if (done) {
|
||||
this.postsService.openSnackBar($localize`Copied to clipboard!`);
|
||||
this.clipboard.copy(download['error']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface Download {
|
||||
|
||||
@@ -11,5 +11,8 @@
|
||||
<mat-spinner [diameter]="25"></mat-spinner>
|
||||
</div>
|
||||
<span class="spacer"></span>
|
||||
<button style="float: right;" mat-stroked-button mat-dialog-close>Cancel</button>
|
||||
<button style="float: right;" mat-stroked-button mat-dialog-close>
|
||||
<ng-container *ngIf="cancelText">{{cancelText}}</ng-container>
|
||||
<ng-container *ngIf="!cancelText" i18n="Cancel">Cancel</ng-container>
|
||||
</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -11,18 +11,23 @@ export class ConfirmDialogComponent implements OnInit {
|
||||
dialogTitle = 'Confirm';
|
||||
dialogText = 'Would you like to confirm?';
|
||||
submitText = 'Yes'
|
||||
cancelText = null;
|
||||
submitClicked = false;
|
||||
closeOnSubmit = true;
|
||||
|
||||
doneEmitter: EventEmitter<any> = null;
|
||||
doneEmitter: EventEmitter<boolean> = null;
|
||||
onlyEmitOnDone = false;
|
||||
|
||||
warnSubmitColor = false;
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<ConfirmDialogComponent>) {
|
||||
if (this.data.dialogTitle) { this.dialogTitle = this.data.dialogTitle };
|
||||
if (this.data.dialogText) { this.dialogText = this.data.dialogText };
|
||||
if (this.data.submitText) { this.submitText = this.data.submitText };
|
||||
if (this.data.warnSubmitColor) { this.warnSubmitColor = this.data.warnSubmitColor };
|
||||
if (this.data.dialogTitle !== undefined) { this.dialogTitle = this.data.dialogTitle }
|
||||
if (this.data.dialogText !== undefined) { this.dialogText = this.data.dialogText }
|
||||
if (this.data.submitText !== undefined) { this.submitText = this.data.submitText }
|
||||
if (this.data.cancelText !== undefined) { this.cancelText = this.data.cancelText }
|
||||
if (this.data.warnSubmitColor !== undefined) { this.warnSubmitColor = this.data.warnSubmitColor }
|
||||
if (this.data.warnSubmitColor !== undefined) { this.warnSubmitColor = this.data.warnSubmitColor }
|
||||
if (this.data.closeOnSubmit !== undefined) { this.closeOnSubmit = this.data.closeOnSubmit }
|
||||
|
||||
// checks if emitter exists, if so don't autoclose as it should be handled by caller
|
||||
if (this.data.doneEmitter) {
|
||||
@@ -34,9 +39,9 @@ export class ConfirmDialogComponent implements OnInit {
|
||||
confirmClicked() {
|
||||
if (this.onlyEmitOnDone) {
|
||||
this.doneEmitter.emit(true);
|
||||
this.submitClicked = true;
|
||||
if (this.closeOnSubmit) this.submitClicked = true;
|
||||
} else {
|
||||
this.dialogRef.close(true);
|
||||
if (this.closeOnSubmit) this.dialogRef.close(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -915,11 +915,15 @@ export class MainComponent implements OnInit {
|
||||
this.current_download = res['download'];
|
||||
this.percentDownloaded = this.current_download.percent_complete;
|
||||
|
||||
if (this.current_download['finished']) {
|
||||
if (this.current_download['finished'] && !this.current_download['error']) {
|
||||
const container = this.current_download['container'];
|
||||
const is_playlist = this.current_download['file_uids'].length > 1;
|
||||
this.downloadHelper(container, this.current_download['type'], is_playlist, false);
|
||||
this.current_download = null;
|
||||
} else if (this.current_download['finished'] && this.current_download['error']) {
|
||||
this.downloadingfile = false;
|
||||
this.current_download = null;
|
||||
this.openSnackBar('Download failed!', 'OK.');
|
||||
}
|
||||
} else {
|
||||
// console.log('failed to get new download');
|
||||
|
||||
Reference in New Issue
Block a user