X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Futils%2Fvideos%2Fvideos.ts;h=2c09f008604556cdc226a79f37047b4f33fe9545;hb=418d092afa81e2c8fe8ac6838fc4b5eb0af6a782;hp=39c808d1f3f4d7d3ac014d6ba89af824e0c7dd37;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts index 39c808d1f..2c09f0086 100644 --- a/shared/utils/videos/videos.ts +++ b/shared/utils/videos/videos.ts @@ -31,6 +31,7 @@ type VideoAttributes = { downloadEnabled?: boolean waitTranscoding?: boolean description?: string + originallyPublishedAt?: string tags?: string[] channelId?: number privacy?: VideoPrivacy @@ -222,6 +223,28 @@ function getVideoChannelVideos ( }) } +function getPlaylistVideos ( + url: string, + accessToken: string, + playlistId: number | string, + start: number, + count: number, + query: { nsfw?: boolean } = {} +) { + const path = '/api/v1/video-playlists/' + playlistId + '/videos' + + return makeGetRequest({ + url, + path, + query: immutableAssign(query, { + start, + count + }), + token: accessToken, + statusCodeExpected: 200 + }) +} + function getVideosListPagination (url: string, start: number, count: number, sort?: string) { const path = '/api/v1/videos' @@ -369,6 +392,10 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg } } + if (attributes.originallyPublishedAt !== undefined) { + req.field('originallyPublishedAt', attributes.originallyPublishedAt) + } + return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture)) .expect(specialStatus) } @@ -384,6 +411,7 @@ function updateVideo (url: string, accessToken: string, id: number | string, att if (attributes.nsfw !== undefined) body['nsfw'] = JSON.stringify(attributes.nsfw) if (attributes.commentsEnabled !== undefined) body['commentsEnabled'] = JSON.stringify(attributes.commentsEnabled) if (attributes.downloadEnabled !== undefined) body['downloadEnabled'] = JSON.stringify(attributes.downloadEnabled) + if (attributes.originallyPublishedAt !== undefined) body['originallyPublishedAt'] = attributes.originallyPublishedAt if (attributes.description) body['description'] = attributes.description if (attributes.tags) body['tags'] = attributes.tags if (attributes.privacy) body['privacy'] = attributes.privacy @@ -453,6 +481,7 @@ async function completeVideoCheck ( description: string publishedAt?: string support: string + originallyPublishedAt?: string, account: { name: string host: string @@ -510,6 +539,12 @@ async function completeVideoCheck ( expect(video.publishedAt).to.equal(attributes.publishedAt) } + if (attributes.originallyPublishedAt) { + expect(video.originallyPublishedAt).to.equal(attributes.originallyPublishedAt) + } else { + expect(video.originallyPublishedAt).to.be.null + } + const res = await getVideo(url, video.uuid) const videoDetails: VideoDetails = res.body @@ -588,5 +623,6 @@ export { parseTorrentVideo, getLocalVideos, completeVideoCheck, - checkVideoFilesWereRemoved + checkVideoFilesWereRemoved, + getPlaylistVideos }