X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fvideos%2Fvideos.ts;h=d1ac48292887fdb9b0edde0bac66572fe89a8ba9;hb=44d4ee4fcb7cf8beebac73f85693c09919b91e66;hp=b64de247074bd0d376fb2f7718584da6fef0be6e;hpb=fd822c1c699fb89bb1c3218e047e1d842bc1ba1a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b64de2470..d1ac48292 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts @@ -16,10 +16,10 @@ import { ServerInfo, testImage } from '../' -import * as validator from 'validator' +import validator from 'validator' import { VideoDetails, VideoPrivacy } from '../../models/videos' import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, loadLanguages, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' -import { dateIsValid, webtorrentAdd } from '../miscs/miscs' +import { dateIsValid, webtorrentAdd, buildServerDirectory } from '../miscs/miscs' loadLanguages() @@ -161,13 +161,14 @@ function getLocalVideos (url: string) { .expect('Content-Type', /json/) } -function getMyVideos (url: string, accessToken: string, start: number, count: number, sort?: string) { +function getMyVideos (url: string, accessToken: string, start: number, count: number, sort?: string, search?: string) { const path = '/api/v1/users/me/videos' const req = request(url) .get(path) .query({ start: start }) .query({ count: count }) + .query({ search: search }) if (sort) req.query({ sort }) @@ -247,7 +248,7 @@ function getPlaylistVideos ( }) } -function getVideosListPagination (url: string, start: number, count: number, sort?: string) { +function getVideosListPagination (url: string, start: number, count: number, sort?: string, skipCount?: boolean) { const path = '/api/v1/videos' const req = request(url) @@ -256,6 +257,7 @@ function getVideosListPagination (url: string, start: number, count: number, sor .query({ count: count }) if (sort) req.query({ sort }) + if (skipCount) req.query({ skipCount }) return req.set('Accept', 'application/json') .expect(200) @@ -308,10 +310,8 @@ async function checkVideoFilesWereRemoved ( join('redundancy', 'hls') ] ) { - const testDirectory = 'test' + serverNumber - for (const directory of directories) { - const directoryPath = join(root(), testDirectory, directory) + const directoryPath = buildServerDirectory(serverNumber, directory) const directoryExists = await pathExists(directoryPath) if (directoryExists === false) continue @@ -362,6 +362,10 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg .field('privacy', attributes.privacy.toString()) .field('channelId', attributes.channelId) + if (attributes.support !== undefined) { + req.field('support', attributes.support) + } + if (attributes.description !== undefined) { req.field('description', attributes.description) } @@ -375,7 +379,8 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg req.field('licence', attributes.licence.toString()) } - for (let i = 0; i < attributes.tags.length; i++) { + const tags = attributes.tags || [] + for (let i = 0; i < tags.length; i++) { req.field('tags[' + i + ']', attributes.tags[i]) } @@ -524,7 +529,6 @@ async function completeVideoCheck ( expect(video.nsfw).to.equal(attributes.nsfw) expect(video.description).to.equal(attributes.description) expect(video.account.id).to.be.a('number') - expect(video.account.uuid).to.be.a('string') expect(video.account.host).to.equal(attributes.account.host) expect(video.account.name).to.equal(attributes.account.name) expect(video.channel.displayName).to.equal(attributes.channel.displayName) @@ -571,7 +575,6 @@ async function completeVideoCheck ( // Transcoding enabled: extension will always be .mp4 if (attributes.files.length > 1) extension = '.mp4' - const magnetUri = file.magnetUri expect(file.magnetUri).to.have.lengthOf.above(2) expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`) expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`) @@ -584,19 +587,17 @@ async function completeVideoCheck ( 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') .to.be.above(minSize).and.below(maxSize) - { - await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) - } - - if (attributes.previewfile) { - await testImage(url, attributes.previewfile, videoDetails.previewPath) - } - - const torrent = await webtorrentAdd(magnetUri, true) + const torrent = await webtorrentAdd(file.magnetUri, true) expect(torrent.files).to.be.an('array') expect(torrent.files.length).to.equal(1) expect(torrent.files[0].path).to.exist.and.to.not.equal('') } + + await testImage(url, attributes.thumbnailfile || attributes.fixture, videoDetails.thumbnailPath) + + if (attributes.previewfile) { + await testImage(url, attributes.previewfile, videoDetails.previewPath) + } } async function videoUUIDToId (url: string, id: number | string) {