mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-12 15:50:57 +03:00
Added support for download error notifications
Style improvements
This commit is contained in:
@@ -107,9 +107,10 @@ exports.clearDownload = async (download_uid) => {
|
||||
return await db_api.removeRecord('download_queue', {uid: download_uid});
|
||||
}
|
||||
|
||||
async function handleDownloadError(download_uid, error_message) {
|
||||
if (!download_uid) return;
|
||||
await db_api.updateRecord('download_queue', {uid: download_uid}, {error: error_message, finished: true, running: false});
|
||||
async function handleDownloadError(download, error_message) {
|
||||
if (!download || !download['uid']) return;
|
||||
notifications_api.sendDownloadErrorNotification(download, download['user_uid']);
|
||||
await db_api.updateRecord('download_queue', {uid: download['uid']}, {error: error_message, finished: true, running: false});
|
||||
}
|
||||
|
||||
async function setupDownloads() {
|
||||
@@ -273,14 +274,14 @@ async function downloadQueuedFile(download_uid) {
|
||||
clearInterval(download_checker);
|
||||
if (err) {
|
||||
logger.error(err.stderr);
|
||||
await handleDownloadError(download_uid, err.stderr);
|
||||
await handleDownloadError(download, err.stderr);
|
||||
resolve(false);
|
||||
return;
|
||||
} else if (output) {
|
||||
if (output.length === 0 || output[0].length === 0) {
|
||||
// ERROR!
|
||||
const error_message = `No output received for video download, check if it exists in your archive.`;
|
||||
await handleDownloadError(download_uid, error_message);
|
||||
await handleDownloadError(download, error_message);
|
||||
logger.warn(error_message);
|
||||
resolve(false);
|
||||
return;
|
||||
@@ -366,7 +367,7 @@ async function downloadQueuedFile(download_uid) {
|
||||
} else {
|
||||
const error_message = 'Downloaded file failed to result in metadata object.';
|
||||
logger.error(error_message);
|
||||
await handleDownloadError(download_uid, error_message);
|
||||
await handleDownloadError(download, error_message);
|
||||
}
|
||||
|
||||
const file_uids = file_objs.map(file_obj => file_obj.uid);
|
||||
@@ -562,7 +563,8 @@ exports.getVideoInfoByURL = async (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 handleDownloadError(download_uid, error);
|
||||
const download = await db_api.getRecord('download_queue', {uid: download_uid});
|
||||
await handleDownloadError(download, error);
|
||||
}
|
||||
resolve(null);
|
||||
}
|
||||
@@ -571,7 +573,8 @@ exports.getVideoInfoByURL = async (url, args = [], download_uid = null) => {
|
||||
if (err.stderr) error_message += `\n\n${err.stderr}`;
|
||||
logger.error(error_message);
|
||||
if (download_uid) {
|
||||
await handleDownloadError(download_uid, error_message);
|
||||
const download = await db_api.getRecord('download_queue', {uid: download_uid});
|
||||
await handleDownloadError(download, error_message);
|
||||
}
|
||||
resolve(null);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div *ngFor="let notification of notifications; let i = index;">
|
||||
<mat-divider class="notification-divider"></mat-divider>
|
||||
<div style="display: inline-block">
|
||||
<div class="notification-text">
|
||||
<ng-container *ngIf="NOTIFICATION_PREFIX[notification.type]">
|
||||
{{NOTIFICATION_PREFIX[notification.type]}}
|
||||
</ng-container>
|
||||
@@ -8,10 +8,10 @@
|
||||
{{notification['data'][NOTIFICATION_SUFFIX_KEY[notification.type]]}}
|
||||
</ng-container>
|
||||
</div>
|
||||
<div style="margin-left: 10px; float: right;" *ngIf="notification.actions?.length > 0">
|
||||
<button (click)="emitDeleteNotification(notification.uid)" mat-icon-button><mat-icon>close</mat-icon></button>
|
||||
<div *ngIf="notification.actions?.length > 0">
|
||||
<button matTooltip="Remove" i18n-matTooltip="Remove" (click)="emitDeleteNotification(notification.uid)" mat-icon-button><mat-icon>close</mat-icon></button>
|
||||
<span *ngFor="let action of notification.actions">
|
||||
<button [matTooltip]="NOTIFICATION_ACTION_TO_STRING[action]" (click)="emitNotificationAction(notification)" mat-icon-button><mat-icon>{{NOTIFICATION_ICON[action]}}</mat-icon></button>
|
||||
<button [matTooltip]="NOTIFICATION_ACTION_TO_STRING[action]" (click)="emitNotificationAction(notification, action)" mat-icon-button><mat-icon>{{NOTIFICATION_ICON[action]}}</mat-icon></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -21,7 +21,7 @@ export class NotificationsListComponent {
|
||||
// Attaches string to the end of the notification text
|
||||
NOTIFICATION_SUFFIX_KEY: { [key in NotificationType]: string } = {
|
||||
download_complete: 'file_title',
|
||||
download_error: 'file_url'
|
||||
download_error: 'download_url'
|
||||
}
|
||||
|
||||
NOTIFICATION_ACTION_TO_STRING: { [key in NotificationAction]: string } = {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<h4 *ngIf="notifications !== null && notifications.length === 0 && read_notifications.length === 0" style="text-align: center; margin: 10px;" i18n="No notifications available">No notifications available</h4>
|
||||
<strong *ngIf="notifications !== null && notifications.length === 0 && read_notifications.length === 0" style="text-align: center; margin: 10px; position: relative; top: 8px;" i18n="No notifications available">No notifications available</strong>
|
||||
<div style="margin: 10px;" *ngIf="notifications?.length > 0">
|
||||
<h4 class="notification-title" i18n="New notifications">New notifications</h4>
|
||||
<strong class="notification-title" i18n="New notifications">New notifications</strong>
|
||||
<app-notifications-list (notificationAction)="notificationAction($event)" (deleteNotification)="deleteNotification($event)" [notifications]="notifications"></app-notifications-list>
|
||||
</div>
|
||||
|
||||
<div style="margin: 10px;" *ngIf="read_notifications?.length > 0">
|
||||
<h4 class="notification-title" i18n="Old notifications">Old notifications</h4>
|
||||
<strong class="notification-title" i18n="Old notifications">Old notifications</strong>
|
||||
<app-notifications-list (notificationAction)="notificationAction($event)" (deleteNotification)="deleteNotification($event)" [notifications]="read_notifications"></app-notifications-list>
|
||||
</div>
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { MatMenuTrigger } from '@angular/material/menu';
|
||||
import { Component, ElementRef, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
import { Notification } from 'api-types';
|
||||
|
||||
Reference in New Issue
Block a user