mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-22 04:03:21 +03:00
Use named arguments with download file
This commit is contained in:
@@ -127,6 +127,8 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/GetFileResponse'
|
$ref: '#/components/schemas/GetFileResponse'
|
||||||
|
'401':
|
||||||
|
description: User is not authorized to view the file.
|
||||||
security:
|
security:
|
||||||
- Auth query parameter: []
|
- Auth query parameter: []
|
||||||
/api/enableSharing:
|
/api/enableSharing:
|
||||||
@@ -441,6 +443,8 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: 'The file itself is in the response, as well as an options object.'
|
description: 'The file itself is in the response, as well as an options object.'
|
||||||
|
'401':
|
||||||
|
description: User is not authorized to view the file.
|
||||||
security:
|
security:
|
||||||
- Auth query parameter: []
|
- Auth query parameter: []
|
||||||
/api/deleteFile:
|
/api/deleteFile:
|
||||||
@@ -1254,8 +1258,12 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
uuid:
|
uuid:
|
||||||
type: string
|
type: string
|
||||||
|
uid:
|
||||||
|
type: string
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
subscriptionName:
|
subscriptionName:
|
||||||
type: boolean
|
type: string
|
||||||
description: Only used for subscriptions
|
description: Only used for subscriptions
|
||||||
subPlaylist:
|
subPlaylist:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ export interface DownloadFileRequest {
|
|||||||
outputName?: string;
|
outputName?: string;
|
||||||
fullPathProvided?: boolean;
|
fullPathProvided?: boolean;
|
||||||
uuid?: string;
|
uuid?: string;
|
||||||
|
uid?: string;
|
||||||
|
id?: string;
|
||||||
/**
|
/**
|
||||||
* Only used for subscriptions
|
* Only used for subscriptions
|
||||||
*/
|
*/
|
||||||
subscriptionName?: boolean;
|
subscriptionName?: string;
|
||||||
/**
|
/**
|
||||||
* Only used for subscriptions
|
* Only used for subscriptions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export class CustomPlaylistsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadPlaylist(fileNames, type, zipName = null, playlistID = null) {
|
downloadPlaylist(fileNames, type, zipName = null, playlistID = null) {
|
||||||
this.postsService.downloadFileFromServer(fileNames, type, zipName).subscribe(res => {
|
this.postsService.downloadFileFromServer(fileNames, type, {outputName: zipName}).subscribe(res => {
|
||||||
if (playlistID) { this.downloading_content[type][playlistID] = false };
|
if (playlistID) { this.downloading_content[type][playlistID] = false };
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, zipName + '.zip');
|
saveAs(blob, zipName + '.zip');
|
||||||
|
|||||||
@@ -190,8 +190,10 @@ export class RecentVideosComponent implements OnInit {
|
|||||||
const type = (file.isAudio ? 'audio' : 'video') as FileType;
|
const type = (file.isAudio ? 'audio' : 'video') as FileType;
|
||||||
const ext = type === 'audio' ? '.mp3' : '.mp4'
|
const ext = type === 'audio' ? '.mp3' : '.mp4'
|
||||||
const sub = this.postsService.getSubscriptionByID(file.sub_id);
|
const sub = this.postsService.getSubscriptionByID(file.sub_id);
|
||||||
this.postsService.downloadFileFromServer(file.id, type, null, null, sub.name, sub.isPlaylist,
|
this.postsService.downloadFileFromServer(
|
||||||
this.postsService.user ? this.postsService.user.uid : null, null).subscribe(res => {
|
file.id, type,
|
||||||
|
{subscriptionName: sub.name, subPlaylist: sub.isPlaylist, uid: this.postsService.user ? this.postsService.user.uid : null}
|
||||||
|
).subscribe(res => {
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, file.id + ext);
|
saveAs(blob, file.id + ext);
|
||||||
}, err => {
|
}, err => {
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ export class MainComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadPlaylist(fileNames, type, zipName = null, playlistID = null) {
|
downloadPlaylist(fileNames, type, zipName = null, playlistID = null) {
|
||||||
this.postsService.downloadFileFromServer(fileNames, type, zipName).subscribe(res => {
|
this.postsService.downloadFileFromServer(fileNames, type, {outputName: zipName}).subscribe(res => {
|
||||||
if (playlistID) { this.downloading_content[type][playlistID] = false };
|
if (playlistID) { this.downloading_content[type][playlistID] = false };
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, zipName + '.zip');
|
saveAs(blob, zipName + '.zip');
|
||||||
|
|||||||
@@ -318,8 +318,10 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
const zipName = fileNames[0].split(' ')[0] + fileNames[1].split(' ')[0];
|
const zipName = fileNames[0].split(' ')[0] + fileNames[1].split(' ')[0];
|
||||||
this.downloading = true;
|
this.downloading = true;
|
||||||
this.postsService.downloadFileFromServer(fileNames, this.type, zipName, null, null, null, null,
|
this.postsService.downloadFileFromServer(
|
||||||
!this.uuid ? this.postsService.user.uid : this.uuid, this.id).subscribe(res => {
|
fileNames, this.type,
|
||||||
|
{outputName: zipName, uuid: !this.uuid ? this.postsService.user.uid : this.uuid, id: this.id}
|
||||||
|
).subscribe(res => {
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, zipName + '.zip');
|
saveAs(blob, zipName + '.zip');
|
||||||
@@ -333,8 +335,10 @@ export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const ext = (this.type === 'audio') ? '.mp3' : '.mp4';
|
const ext = (this.type === 'audio') ? '.mp3' : '.mp4';
|
||||||
const filename = this.playlist[0].title;
|
const filename = this.playlist[0].title;
|
||||||
this.downloading = true;
|
this.downloading = true;
|
||||||
this.postsService.downloadFileFromServer(filename, this.type, null, null, this.subscriptionName, this.subPlaylist,
|
this.postsService.downloadFileFromServer(
|
||||||
this.is_shared ? this.db_file['uid'] : null, this.uuid).subscribe(res => {
|
filename, this.type,
|
||||||
|
{subscriptionName: this.subscriptionName, subPlaylist: this.subPlaylist, uid: this.is_shared ? this.db_file['uid'] : null, uuid: this.uuid}
|
||||||
|
).subscribe(res => {
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, filename + ext);
|
saveAs(blob, filename + ext);
|
||||||
|
|||||||
@@ -282,8 +282,14 @@ export class PostsService implements CanActivate {
|
|||||||
return this.http.post<GetAllFilesResponse>(this.path + 'getAllFiles', {}, this.httpOptions);
|
return this.http.post<GetAllFilesResponse>(this.path + 'getAllFiles', {}, this.httpOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadFileFromServer(fileName: string | string[], type: FileType, outputName: string = null, fullPathProvided: boolean = null, subscriptionName: boolean = null, subPlaylist: boolean = null,
|
downloadFileFromServer(
|
||||||
uid = null, uuid: string = null, id = null) {
|
fileName: string | string[], type: FileType,
|
||||||
|
options: {outputName?: string, fullPathProvided?: boolean, subscriptionName?: string, subPlaylist?: boolean, uid?: string, uuid?: string, id?: string} = {}
|
||||||
|
) {
|
||||||
|
const {outputName = null, fullPathProvided = null,
|
||||||
|
subscriptionName = null, subPlaylist = null,
|
||||||
|
uid = null, uuid = null, id = null} = options;
|
||||||
|
|
||||||
const body: DownloadFileRequest = {fileNames: fileName,
|
const body: DownloadFileRequest = {fileNames: fileName,
|
||||||
type: type,
|
type: type,
|
||||||
zip_mode: Array.isArray(fileName),
|
zip_mode: Array.isArray(fileName),
|
||||||
@@ -291,11 +297,11 @@ export class PostsService implements CanActivate {
|
|||||||
fullPathProvided: fullPathProvided,
|
fullPathProvided: fullPathProvided,
|
||||||
subscriptionName: subscriptionName,
|
subscriptionName: subscriptionName,
|
||||||
subPlaylist: subPlaylist,
|
subPlaylist: subPlaylist,
|
||||||
|
uid: uid,
|
||||||
uuid: uuid,
|
uuid: uuid,
|
||||||
id: id,
|
id: id,
|
||||||
};
|
};
|
||||||
return this.http.post(this.path + 'downloadFile', body,
|
return this.http.post(this.path + 'downloadFile', body, {responseType: 'blob', params: this.httpOptions.params});
|
||||||
{responseType: 'blob', params: this.httpOptions.params});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadCookiesFile(fileFormData) {
|
uploadCookiesFile(fileFormData) {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class SubscriptionComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.downloading = true;
|
this.downloading = true;
|
||||||
this.postsService.downloadFileFromServer(fileNames, 'video' as FileType, this.subscription.name, true).subscribe(res => {
|
this.postsService.downloadFileFromServer(fileNames, 'video' as FileType, {outputName: this.subscription.name, fullPathProvided: true}).subscribe(res => {
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
const blob: Blob = res;
|
const blob: Blob = res;
|
||||||
saveAs(blob, this.subscription.name + '.zip');
|
saveAs(blob, this.subscription.name + '.zip');
|
||||||
|
|||||||
Reference in New Issue
Block a user