diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts index a3a35bc10..726f51ccf 100644 --- a/scripts/create-import-video-file-job.ts +++ b/scripts/create-import-video-file-job.ts @@ -6,7 +6,7 @@ import { resolve } from 'path' import { VideoModel } from '../server/models/video/video' import { initDatabaseModels } from '../server/initializers/database' import { JobQueue } from '../server/lib/job-queue' -import { isUUIDValid } from '@server/helpers/custom-validators/misc' +import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' program .option('-v, --video [videoUUID]', 'Video UUID') @@ -31,12 +31,14 @@ run() async function run () { await initDatabaseModels(true) - if (isUUIDValid(options.video) === false) { + const uuid = toCompleteUUID(options.video) + + if (isUUIDValid(uuid) === false) { console.error('%s is not a valid video UUID.', options.video) return } - const video = await VideoModel.load(options.video) + const video = await VideoModel.load(uuid) if (!video) throw new Error('Video not found.') if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 0bb9bfeab..30846cd15 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts @@ -8,7 +8,7 @@ import { JobQueue } from '../server/lib/job-queue' import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' import { VideoState, VideoTranscodingPayload } from '@shared/models' import { CONFIG } from '@server/initializers/config' -import { isUUIDValid } from '@server/helpers/custom-validators/misc' +import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' import { addTranscodingJob } from '@server/lib/video' program @@ -39,12 +39,14 @@ run() async function run () { await initDatabaseModels(true) - if (isUUIDValid(options.video) === false) { + const uuid = toCompleteUUID(options.video) + + if (isUUIDValid(uuid) === false) { console.error('%s is not a valid video UUID.', options.video) return } - const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video) + const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid) if (!video) throw new Error('Video not found.') const dataInput: VideoTranscodingPayload[] = [] diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 9f1b57a2e..01817216e 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -37,7 +37,7 @@ async function checkFiles (video: VideoDetails, objectStorage: boolean) { } function runTests (objectStorage: boolean) { - let video1UUID: string + let video1ShortId: string let video2UUID: string let servers: PeerTubeServer[] = [] @@ -59,8 +59,8 @@ function runTests (objectStorage: boolean) { // Upload two videos for our needs { - const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } }) - video1UUID = uuid + const { shortUUID } = await servers[0].videos.upload({ attributes: { name: 'video1' } }) + video1ShortId = shortUUID } { @@ -72,7 +72,7 @@ function runTests (objectStorage: boolean) { }) it('Should run a import job on video 1 with a lower resolution', async function () { - const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm` + const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short-480.webm` await servers[0].cli.execWithEnv(command) await waitJobs(servers) @@ -81,8 +81,8 @@ function runTests (objectStorage: boolean) { const { data: videos } = await server.videos.list() expect(videos).to.have.lengthOf(2) - const video = videos.find(({ uuid }) => uuid === video1UUID) - const videoDetails = await server.videos.get({ id: video.uuid }) + const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId) + const videoDetails = await server.videos.get({ id: video.shortUUID }) expect(videoDetails.files).to.have.lengthOf(2) const [ originalVideo, transcodedVideo ] = videoDetails.files @@ -118,7 +118,7 @@ function runTests (objectStorage: boolean) { }) it('Should run a import job on video 2 with the same resolution and the same extension', async function () { - const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm` + const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short2.webm` await servers[0].cli.execWithEnv(command) await waitJobs(servers) @@ -127,7 +127,7 @@ function runTests (objectStorage: boolean) { const { data: videos } = await server.videos.list() expect(videos).to.have.lengthOf(2) - const video = videos.find(({ uuid }) => uuid === video1UUID) + const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId) const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(2) diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 3313a492f..3fd624091 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -52,8 +52,13 @@ function runTests (objectStorage: boolean) { if (objectStorage) await ObjectStorageCommand.prepareDefaultBuckets() for (let i = 1; i <= 5; i++) { - const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } }) - videosUUID.push(uuid) + const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'video' + i } }) + + if (i > 2) { + videosUUID.push(uuid) + } else { + videosUUID.push(shortUUID) + } } await waitJobs(servers) @@ -88,7 +93,7 @@ function runTests (objectStorage: boolean) { for (const video of data) { const videoDetails = await server.videos.get({ id: video.uuid }) - if (video.uuid === videosUUID[1]) { + if (video.shortUUID === videosUUID[1] || video.uuid === videosUUID[1]) { expect(videoDetails.files).to.have.lengthOf(4) expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)