1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Support short uuid for scripts

This commit is contained in:
Chocobozzz 2021-08-17 11:06:10 +02:00
parent 66a7fc9473
commit c186a67f90
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 26 additions and 17 deletions

View file

@ -6,7 +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'
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.')