]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/create-transcoding-job.ts
Relax plugin package.json validation
[github/Chocobozzz/PeerTube.git] / scripts / create-transcoding-job.ts
index 3ea30f98e642701d5bf85e60387308c1c0fa88c1..2eb872169f00cfad6a07737ba220be51d5b28523 100755 (executable)
@@ -2,6 +2,7 @@ import * as program from 'commander'
 import { VideoModel } from '../server/models/video/video'
 import { initDatabaseModels } from '../server/initializers'
 import { JobQueue } from '../server/lib/job-queue'
+import { VideoTranscodingPayload } from '../server/lib/job-queue/handlers/video-transcoding'
 
 program
   .option('-v, --video [videoUUID]', 'Video UUID')
@@ -31,17 +32,11 @@ async function run () {
   const video = await VideoModel.loadByUUID(program['video'])
   if (!video) throw new Error('Video not found.')
 
-  const dataInput = {
-    videoUUID: video.uuid,
-    isNewVideo: false,
-    resolution: undefined
-  }
-
-  if (program.resolution !== undefined) {
-    dataInput.resolution = program.resolution
-  }
+  const dataInput: VideoTranscodingPayload = program.resolution !== undefined
+   ? { type: 'new-resolution' as 'new-resolution', videoUUID: video.uuid, isNewVideo: false, resolution: program.resolution }
+   : { type: 'optimize' as 'optimize', videoUUID: video.uuid, isNewVideo: false }
 
   await JobQueue.Instance.init()
-  await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
+  await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
   console.log('Transcoding job for video %s created.', video.uuid)
 }