From bfbd912886eba17b4aa9a40dcef2fddc685d85bf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 31 Jul 2019 15:57:32 +0200 Subject: Fix broken playlist api --- shared/extra-utils/server/jobs.ts | 5 ++--- shared/extra-utils/videos/video-playlists.ts | 8 ++++---- shared/models/videos/index.ts | 1 + .../videos/playlist/video-exist-in-playlist.model.ts | 1 + .../videos/playlist/video-playlist-element.model.ts | 19 +++++++++++++++++++ shared/models/videos/video.model.ts | 8 -------- 6 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 shared/models/videos/playlist/video-playlist-element.model.ts (limited to 'shared') diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 11b570f60..b3db885e8 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts @@ -2,7 +2,6 @@ import * as request from 'supertest' import { Job, JobState } from '../../models' import { wait } from '../miscs/miscs' import { ServerInfo } from './servers' -import { inspect } from 'util' function getJobsList (url: string, accessToken: string, state: JobState) { const path = '/api/v1/jobs/' + state @@ -37,11 +36,10 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { else servers = serversArg as ServerInfo[] const states: JobState[] = [ 'waiting', 'active', 'delayed' ] - let pendingRequests = false + let pendingRequests: boolean function tasksBuilder () { const tasks: Promise[] = [] - pendingRequests = false // Check if each server has pending request for (const server of servers) { @@ -62,6 +60,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { } do { + pendingRequests = false await Promise.all(tasksBuilder()) // Retry, in case of new jobs were created diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts index fd62bef19..cbb073fbc 100644 --- a/shared/extra-utils/videos/video-playlists.ts +++ b/shared/extra-utils/videos/video-playlists.ts @@ -196,11 +196,11 @@ function updateVideoPlaylistElement (options: { url: string, token: string, playlistId: number | string, - videoId: number | string, + playlistElementId: number | string, elementAttrs: VideoPlaylistElementUpdate, expectedStatus?: number }) { - const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.videoId + const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId return makePutBodyRequest({ url: options.url, @@ -215,10 +215,10 @@ function removeVideoFromPlaylist (options: { url: string, token: string, playlistId: number | string, - videoId: number | string, + playlistElementId: number, expectedStatus?: number }) { - const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.videoId + const path = '/api/v1/video-playlists/' + options.playlistId + '/videos/' + options.playlistElementId return makeDeleteRequest({ url: options.url, diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index e3d78220e..194ae1b96 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts @@ -19,6 +19,7 @@ export * from './playlist/video-playlist-privacy.model' export * from './playlist/video-playlist-type.model' export * from './playlist/video-playlist-update.model' export * from './playlist/video-playlist.model' +export * from './playlist/video-playlist-element.model' export * from './video-change-ownership.model' export * from './video-change-ownership-create.model' export * from './video-create.model' diff --git a/shared/models/videos/playlist/video-exist-in-playlist.model.ts b/shared/models/videos/playlist/video-exist-in-playlist.model.ts index 71240f51d..1b57257e2 100644 --- a/shared/models/videos/playlist/video-exist-in-playlist.model.ts +++ b/shared/models/videos/playlist/video-exist-in-playlist.model.ts @@ -1,5 +1,6 @@ export type VideoExistInPlaylist = { [videoId: number ]: { + playlistElementId: number playlistId: number startTimestamp?: number stopTimestamp?: number diff --git a/shared/models/videos/playlist/video-playlist-element.model.ts b/shared/models/videos/playlist/video-playlist-element.model.ts new file mode 100644 index 000000000..9a1203892 --- /dev/null +++ b/shared/models/videos/playlist/video-playlist-element.model.ts @@ -0,0 +1,19 @@ +import { Video } from '../video.model' + +export enum VideoPlaylistElementType { + REGULAR = 0, + DELETED = 1, + PRIVATE = 2, + UNAVAILABLE = 3 // Blacklisted, blocked by the user/instance, NSFW... +} + +export interface VideoPlaylistElement { + id: number + position: number + startTimestamp: number + stopTimestamp: number + + type: VideoPlaylistElementType + + video?: Video +} diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 0489147e4..e057b3e06 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -17,12 +17,6 @@ export interface VideoFile { fps: number } -export interface PlaylistElement { - position: number - startTimestamp: number - stopTimestamp: number -} - export interface Video { id: number uuid: string @@ -59,8 +53,6 @@ export interface Video { userHistory?: { currentTime: number } - - playlistElement?: PlaylistElement } export interface VideoDetails extends Video { -- cgit v1.2.3