aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/lib/jobs/handlers/video-transcoder.ts
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/lib/jobs/handlers/video-transcoder.ts')
-rw-r--r--server/lib/jobs/handlers/video-transcoder.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/server/lib/jobs/handlers/video-transcoder.ts b/server/lib/jobs/handlers/video-transcoder.ts
new file mode 100644
index 000000000..35db5fb96
--- /dev/null
+++ b/server/lib/jobs/handlers/video-transcoder.ts
@@ -0,0 +1,37 @@
1const db = require('../../../initializers/database')
2import { logger } from '../../../helpers'
3import { addVideoToFriends } from '../../../lib'
4
5function process (data, callback) {
6 db.Video.loadAndPopulateAuthorAndPodAndTags(data.id, function (err, video) {
7 if (err) return callback(err)
8
9 video.transcodeVideofile(function (err) {
10 return callback(err, video)
11 })
12 })
13}
14
15function onError (err, jobId, video, callback) {
16 logger.error('Error when transcoding video file in job %d.', jobId, { error: err })
17 return callback()
18}
19
20function onSuccess (data, jobId, video, callback) {
21 logger.info('Job %d is a success.', jobId)
22
23 video.toAddRemoteJSON(function (err, remoteVideo) {
24 if (err) return callback(err)
25
26 // Now we'll add the video's meta data to our friends
27 addVideoToFriends(remoteVideo, null, callback)
28 })
29}
30
31// ---------------------------------------------------------------------------
32
33export {
34 process,
35 onError,
36 onSuccess
37}