]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/create-import-video-file-job.ts
Faster ci using compiled ts files
[github/Chocobozzz/PeerTube.git] / scripts / create-import-video-file-job.ts
index f5271c7a3ba22e37dba24c479f540e860edfb467..094544e0550328d0a267dc8e353a84f44399ebd2 100644 (file)
@@ -6,6 +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'
 
 program
   .option('-v, --video [videoUUID]', 'Video UUID')
@@ -30,7 +31,12 @@ run()
 async function run () {
   await initDatabaseModels(true)
 
-  const video = await VideoModel.loadByUUID(options.video)
+  if (isUUIDValid(options.video) === false) {
+    console.error('%s is not a valid video UUID.', options.video)
+    return
+  }
+
+  const video = await VideoModel.load(options.video)
   if (!video) throw new Error('Video not found.')
   if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')
 
@@ -39,7 +45,7 @@ async function run () {
     filePath: resolve(options.import)
   }
 
-  await JobQueue.Instance.init()
+  JobQueue.Instance.init()
   await JobQueue.Instance.createJobWithPromise({ type: 'video-file-import', payload: dataInput })
   console.log('Import job for video %s created.', video.uuid)
 }