]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/create-import-video-file-job.ts
Fix undefined this.user.videoChannels on production build
[github/Chocobozzz/PeerTube.git] / scripts / create-import-video-file-job.ts
index 094544e0550328d0a267dc8e353a84f44399ebd2..726f51ccf62cf69d8bad5413139ebc459a61b252 100644 (file)
@@ -1,12 +1,12 @@
 import { registerTSPaths } from '../server/helpers/register-ts-paths'
 registerTSPaths()
 
-import * as program from 'commander'
+import { program } from 'commander'
 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.')