diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-11 16:14:12 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-11 16:15:11 +0100 |
commit | 9aeef9aafa009762e128046bfb2f3cec3252e181 (patch) | |
tree | 300ed4599b2608cb5e848d85bc7ceccd17c90240 /scripts | |
parent | c83af8f94a3c9732c3ea02c80fa96441e5d99c0f (diff) | |
download | PeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.tar.gz PeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.tar.zst PeerTube-9aeef9aafa009762e128046bfb2f3cec3252e181.zip |
Check video UUID in args scripts
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/create-import-video-file-job.ts | 6 | ||||
-rwxr-xr-x | scripts/create-transcoding-job.ts | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/scripts/create-import-video-file-job.ts b/scripts/create-import-video-file-job.ts index f5271c7a3..5d38af066 100644 --- a/scripts/create-import-video-file-job.ts +++ b/scripts/create-import-video-file-job.ts | |||
@@ -6,6 +6,7 @@ import { resolve } from 'path' | |||
6 | import { VideoModel } from '../server/models/video/video' | 6 | import { VideoModel } from '../server/models/video/video' |
7 | import { initDatabaseModels } from '../server/initializers/database' | 7 | import { initDatabaseModels } from '../server/initializers/database' |
8 | import { JobQueue } from '../server/lib/job-queue' | 8 | import { JobQueue } from '../server/lib/job-queue' |
9 | import { isUUIDValid } from '@server/helpers/custom-validators/misc' | ||
9 | 10 | ||
10 | program | 11 | program |
11 | .option('-v, --video [videoUUID]', 'Video UUID') | 12 | .option('-v, --video [videoUUID]', 'Video UUID') |
@@ -30,6 +31,11 @@ run() | |||
30 | async function run () { | 31 | async function run () { |
31 | await initDatabaseModels(true) | 32 | await initDatabaseModels(true) |
32 | 33 | ||
34 | if (isUUIDValid(options.video) === false) { | ||
35 | console.error('%s is not a valid video UUID.', options.video) | ||
36 | return | ||
37 | } | ||
38 | |||
33 | const video = await VideoModel.loadByUUID(options.video) | 39 | const video = await VideoModel.loadByUUID(options.video) |
34 | if (!video) throw new Error('Video not found.') | 40 | if (!video) throw new Error('Video not found.') |
35 | if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') | 41 | 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 9f1d8b956..56a5f4938 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue' | |||
8 | import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' | 8 | import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' |
9 | import { VideoTranscodingPayload } from '@shared/models' | 9 | import { VideoTranscodingPayload } from '@shared/models' |
10 | import { CONFIG } from '@server/initializers/config' | 10 | import { CONFIG } from '@server/initializers/config' |
11 | import { isUUIDValid } from '@server/helpers/custom-validators/misc' | ||
11 | 12 | ||
12 | program | 13 | program |
13 | .option('-v, --video [videoUUID]', 'Video UUID') | 14 | .option('-v, --video [videoUUID]', 'Video UUID') |
@@ -37,6 +38,11 @@ run() | |||
37 | async function run () { | 38 | async function run () { |
38 | await initDatabaseModels(true) | 39 | await initDatabaseModels(true) |
39 | 40 | ||
41 | if (isUUIDValid(options.video) === false) { | ||
42 | console.error('%s is not a valid video UUID.', options.video) | ||
43 | return | ||
44 | } | ||
45 | |||
40 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video) | 46 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video) |
41 | if (!video) throw new Error('Video not found.') | 47 | if (!video) throw new Error('Video not found.') |
42 | 48 | ||