mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Support short uuid for scripts
This commit is contained in:
@@ -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.')
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { JobQueue } from '../server/lib/job-queue'
|
||||
import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils'
|
||||
import { VideoState, VideoTranscodingPayload } from '@shared/models'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { isUUIDValid } from '@server/helpers/custom-validators/misc'
|
||||
import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
|
||||
import { addTranscodingJob } from '@server/lib/video'
|
||||
|
||||
program
|
||||
@@ -39,12 +39,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.loadAndPopulateAccountAndServerAndTags(options.video)
|
||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(uuid)
|
||||
if (!video) throw new Error('Video not found.')
|
||||
|
||||
const dataInput: VideoTranscodingPayload[] = []
|
||||
|
||||
Reference in New Issue
Block a user