mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-13 09:01:29 +03:00
Downloads restarted from home page now persist after restarting rather than disappearing
This commit is contained in:
@@ -905,7 +905,7 @@ paths:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/SuccessObject'
|
$ref: '#/components/schemas/RestartDownloadResponse'
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
@@ -1722,6 +1722,13 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
download:
|
download:
|
||||||
$ref: '#/components/schemas/Download'
|
$ref: '#/components/schemas/Download'
|
||||||
|
RestartDownloadResponse:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/components/schemas/SuccessObject'
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
new_download_uid:
|
||||||
|
type: string
|
||||||
GetAllDownloadsRequest:
|
GetAllDownloadsRequest:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -1765,8 +1765,8 @@ app.post('/api/resumeAllDownloads', optionalJwt, async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/restartDownload', optionalJwt, async (req, res) => {
|
app.post('/api/restartDownload', optionalJwt, async (req, res) => {
|
||||||
const download_uid = req.body.download_uid;
|
const download_uid = req.body.download_uid;
|
||||||
const success = await downloader_api.restartDownload(download_uid);
|
const new_download = await downloader_api.restartDownload(download_uid);
|
||||||
res.send({success: success});
|
res.send({success: !!new_download, new_download_uid: new_download ? new_download['uid'] : null});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/api/cancelDownload', optionalJwt, async (req, res) => {
|
app.post('/api/cancelDownload', optionalJwt, async (req, res) => {
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ exports.resumeDownload = async (download_uid) => {
|
|||||||
exports.restartDownload = async (download_uid) => {
|
exports.restartDownload = async (download_uid) => {
|
||||||
const download = await db_api.getRecord('download_queue', {uid: download_uid});
|
const download = await db_api.getRecord('download_queue', {uid: download_uid});
|
||||||
await exports.clearDownload(download_uid);
|
await exports.clearDownload(download_uid);
|
||||||
const success = !!(await exports.createDownload(download['url'], download['type'], download['options'], download['user_uid']));
|
const new_download = await exports.createDownload(download['url'], download['type'], download['options'], download['user_uid']);
|
||||||
|
|
||||||
should_check_downloads = true;
|
should_check_downloads = true;
|
||||||
return success;
|
return new_download;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.cancelDownload = async (download_uid) => {
|
exports.cancelDownload = async (download_uid) => {
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export { NotificationType } from './models/NotificationType';
|
|||||||
export type { Playlist } from './models/Playlist';
|
export type { Playlist } from './models/Playlist';
|
||||||
export type { RegisterRequest } from './models/RegisterRequest';
|
export type { RegisterRequest } from './models/RegisterRequest';
|
||||||
export type { RegisterResponse } from './models/RegisterResponse';
|
export type { RegisterResponse } from './models/RegisterResponse';
|
||||||
|
export type { RestartDownloadResponse } from './models/RestartDownloadResponse';
|
||||||
export type { RestoreDBBackupRequest } from './models/RestoreDBBackupRequest';
|
export type { RestoreDBBackupRequest } from './models/RestoreDBBackupRequest';
|
||||||
export { Schedule } from './models/Schedule';
|
export { Schedule } from './models/Schedule';
|
||||||
export type { SetConfigRequest } from './models/SetConfigRequest';
|
export type { SetConfigRequest } from './models/SetConfigRequest';
|
||||||
|
|||||||
9
src/api-types/models/RestartDownloadResponse.ts
Normal file
9
src/api-types/models/RestartDownloadResponse.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/* istanbul ignore file */
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
import type { SuccessObject } from './SuccessObject';
|
||||||
|
|
||||||
|
export type RestartDownloadResponse = (SuccessObject & {
|
||||||
|
new_download_uid?: string;
|
||||||
|
});
|
||||||
@@ -41,7 +41,7 @@ import { Download } from 'api-types';
|
|||||||
})
|
})
|
||||||
export class DownloadsComponent implements OnInit, OnDestroy {
|
export class DownloadsComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Input() uids = null;
|
@Input() uids: string[] = null;
|
||||||
|
|
||||||
downloads_check_interval = 1000;
|
downloads_check_interval = 1000;
|
||||||
downloads = [];
|
downloads = [];
|
||||||
@@ -200,6 +200,10 @@ export class DownloadsComponent implements OnInit, OnDestroy {
|
|||||||
this.postsService.restartDownload(download_uid).subscribe(res => {
|
this.postsService.restartDownload(download_uid).subscribe(res => {
|
||||||
if (!res['success']) {
|
if (!res['success']) {
|
||||||
this.postsService.openSnackBar($localize`Failed to restart download! See server logs for more info.`);
|
this.postsService.openSnackBar($localize`Failed to restart download! See server logs for more info.`);
|
||||||
|
} else {
|
||||||
|
if (this.uids && res['new_download_uid']) {
|
||||||
|
this.uids.push(res['new_download_uid']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ import {
|
|||||||
GetArchivesResponse,
|
GetArchivesResponse,
|
||||||
ImportArchiveRequest,
|
ImportArchiveRequest,
|
||||||
Archive,
|
Archive,
|
||||||
Subscription
|
Subscription,
|
||||||
|
RestartDownloadResponse
|
||||||
} from '../api-types';
|
} from '../api-types';
|
||||||
import { isoLangs } from './settings/locales_list';
|
import { isoLangs } from './settings/locales_list';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
@@ -621,7 +622,7 @@ export class PostsService implements CanActivate {
|
|||||||
|
|
||||||
restartDownload(download_uid: string) {
|
restartDownload(download_uid: string) {
|
||||||
const body: GetDownloadRequest = {download_uid: download_uid};
|
const body: GetDownloadRequest = {download_uid: download_uid};
|
||||||
return this.http.post<SuccessObject>(this.path + 'restartDownload', body, this.httpOptions);
|
return this.http.post<RestartDownloadResponse>(this.path + 'restartDownload', body, this.httpOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelDownload(download_uid: string) {
|
cancelDownload(download_uid: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user