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