diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-17 11:06:10 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-17 11:06:10 +0200 |
commit | c186a67f90203af6bfa434f026efdc99193bcd65 (patch) | |
tree | 54e715f1afba3aaa14d6448fdbc14d699b7ae775 /scripts/create-import-video-file-job.ts | |
parent | 66a7fc947321b923fa1e7182202e03d0e21ffb3e (diff) | |
download | PeerTube-c186a67f90203af6bfa434f026efdc99193bcd65.tar.gz PeerTube-c186a67f90203af6bfa434f026efdc99193bcd65.tar.zst PeerTube-c186a67f90203af6bfa434f026efdc99193bcd65.zip |
Support short uuid for scripts
Diffstat (limited to 'scripts/create-import-video-file-job.ts')
-rw-r--r-- | scripts/create-import-video-file-job.ts | 8 |
1 files changed, 5 insertions, 3 deletions
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' | |||
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 | import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' |
10 | 10 | ||
11 | program | 11 | program |
12 | .option('-v, --video [videoUUID]', 'Video UUID') | 12 | .option('-v, --video [videoUUID]', 'Video UUID') |
@@ -31,12 +31,14 @@ run() | |||
31 | async function run () { | 31 | async function run () { |
32 | await initDatabaseModels(true) | 32 | await initDatabaseModels(true) |
33 | 33 | ||
34 | if (isUUIDValid(options.video) === false) { | 34 | const uuid = toCompleteUUID(options.video) |
35 | |||
36 | if (isUUIDValid(uuid) === false) { | ||
35 | console.error('%s is not a valid video UUID.', options.video) | 37 | console.error('%s is not a valid video UUID.', options.video) |
36 | return | 38 | return |
37 | } | 39 | } |
38 | 40 | ||
39 | const video = await VideoModel.load(options.video) | 41 | const video = await VideoModel.load(uuid) |
40 | if (!video) throw new Error('Video not found.') | 42 | if (!video) throw new Error('Video not found.') |
41 | if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') | 43 | if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.') |
42 | 44 | ||