Check video UUID in args scripts
This commit is contained in:
parent
c83af8f94a
commit
9aeef9aafa
|
@ -6,6 +6,7 @@ import { resolve } from 'path'
|
||||||
import { VideoModel } from '../server/models/video/video'
|
import { VideoModel } from '../server/models/video/video'
|
||||||
import { initDatabaseModels } from '../server/initializers/database'
|
import { initDatabaseModels } from '../server/initializers/database'
|
||||||
import { JobQueue } from '../server/lib/job-queue'
|
import { JobQueue } from '../server/lib/job-queue'
|
||||||
|
import { isUUIDValid } from '@server/helpers/custom-validators/misc'
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-v, --video [videoUUID]', 'Video UUID')
|
.option('-v, --video [videoUUID]', 'Video UUID')
|
||||||
|
@ -30,6 +31,11 @@ run()
|
||||||
async function run () {
|
async function run () {
|
||||||
await initDatabaseModels(true)
|
await initDatabaseModels(true)
|
||||||
|
|
||||||
|
if (isUUIDValid(options.video) === false) {
|
||||||
|
console.error('%s is not a valid video UUID.', options.video)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const video = await VideoModel.loadByUUID(options.video)
|
const video = await VideoModel.loadByUUID(options.video)
|
||||||
if (!video) throw new Error('Video not found.')
|
if (!video) throw new Error('Video not found.')
|
||||||
if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')
|
if (video.isOwned() === false) throw new Error('Cannot import files of a non owned video.')
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue'
|
||||||
import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
|
import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
|
||||||
import { VideoTranscodingPayload } from '@shared/models'
|
import { VideoTranscodingPayload } from '@shared/models'
|
||||||
import { CONFIG } from '@server/initializers/config'
|
import { CONFIG } from '@server/initializers/config'
|
||||||
|
import { isUUIDValid } from '@server/helpers/custom-validators/misc'
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-v, --video [videoUUID]', 'Video UUID')
|
.option('-v, --video [videoUUID]', 'Video UUID')
|
||||||
|
@ -37,6 +38,11 @@ run()
|
||||||
async function run () {
|
async function run () {
|
||||||
await initDatabaseModels(true)
|
await initDatabaseModels(true)
|
||||||
|
|
||||||
|
if (isUUIDValid(options.video) === false) {
|
||||||
|
console.error('%s is not a valid video UUID.', options.video)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video)
|
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video)
|
||||||
if (!video) throw new Error('Video not found.')
|
if (!video) throw new Error('Video not found.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue