diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-30 10:49:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-30 10:49:56 +0200 |
commit | 0c948c1659c0a6010f2bf58c402b1c9af192aa5e (patch) | |
tree | 9e82656fc81af435f8d6c139b3decac409fa6aeb /scripts | |
parent | b4f8277cb6503bd889654f0e4f364627e9e00af9 (diff) | |
download | PeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.tar.gz PeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.tar.zst PeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.zip |
Add ability to manually run transcoding job
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/create-transcoding-job.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts new file mode 100755 index 000000000..463cdfad3 --- /dev/null +++ b/scripts/create-transcoding-job.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import * as program from 'commander' | ||
2 | import { createReadStream } from 'fs' | ||
3 | import { join } from 'path' | ||
4 | import { createInterface } from 'readline' | ||
5 | import { VideoModel } from '../server/models/video/video' | ||
6 | import { initDatabaseModels } from '../server/initializers' | ||
7 | import { JobQueue } from '../server/lib/job-queue' | ||
8 | |||
9 | program | ||
10 | .option('-v, --video [videoUUID]', 'Video UUID') | ||
11 | .parse(process.argv) | ||
12 | |||
13 | if (program['video'] === undefined) { | ||
14 | console.error('All parameters are mandatory.') | ||
15 | process.exit(-1) | ||
16 | } | ||
17 | |||
18 | run() | ||
19 | .then(() => process.exit(0)) | ||
20 | .catch(err => { | ||
21 | console.error(err) | ||
22 | process.exit(-1) | ||
23 | }) | ||
24 | |||
25 | async function run () { | ||
26 | await initDatabaseModels(true) | ||
27 | |||
28 | const video = await VideoModel.loadByUUID(program['video']) | ||
29 | if (!video) throw new Error('Video not found.') | ||
30 | |||
31 | const dataInput = { | ||
32 | videoUUID: video.uuid, | ||
33 | isNewVideo: false | ||
34 | } | ||
35 | |||
36 | await JobQueue.Instance.init() | ||
37 | await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) | ||
38 | console.log('Transcoding job for video %s created.', video.uuid) | ||
39 | } | ||