diff --git a/Public API v1.yaml b/Public API v1.yaml index 70d56c5..866493e 100644 --- a/Public API v1.yaml +++ b/Public API v1.yaml @@ -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 diff --git a/src/api-types/models/DownloadFileRequest.ts b/src/api-types/models/DownloadFileRequest.ts index 18c6cac..61816c9 100644 --- a/src/api-types/models/DownloadFileRequest.ts +++ b/src/api-types/models/DownloadFileRequest.ts @@ -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 */ diff --git a/src/app/components/custom-playlists/custom-playlists.component.ts b/src/app/components/custom-playlists/custom-playlists.component.ts index d2d65d6..3212708 100644 --- a/src/app/components/custom-playlists/custom-playlists.component.ts +++ b/src/app/components/custom-playlists/custom-playlists.component.ts @@ -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'); diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts index 11a6dcc..b90fee5 100644 --- a/src/app/components/recent-videos/recent-videos.component.ts +++ b/src/app/components/recent-videos/recent-videos.component.ts @@ -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) { diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index c0bb894..e524057 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -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'); diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts index 57e2ea4..c6fb53d 100644 --- a/src/app/player/player.component.ts +++ b/src/app/player/player.component.ts @@ -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); diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 976298c..be2f39e 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -282,8 +282,14 @@ export class PostsService implements CanActivate { return this.http.post(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) { diff --git a/src/app/subscription/subscription/subscription.component.ts b/src/app/subscription/subscription/subscription.component.ts index eb2f35b..2c8f9dd 100644 --- a/src/app/subscription/subscription/subscription.component.ts +++ b/src/app/subscription/subscription/subscription.component.ts @@ -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');