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')
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.loadByUUID(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.')
filePath: resolve(options.import)
}
- await JobQueue.Instance.init()
+ JobQueue.Instance.init(true)
await JobQueue.Instance.createJobWithPromise({ type: 'video-file-import', payload: dataInput })
console.log('Import job for video %s created.', video.uuid)
}