]>
Commit | Line | Data |
---|---|---|
1 | import { database as db } from '../../../initializers/database' | |
2 | import { logger } from '../../../helpers' | |
3 | import { addVideoToFriends } from '../../../lib' | |
4 | ||
5 | function 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 | ||
15 | function onError (err, jobId, video, callback) { | |
16 | logger.error('Error when transcoding video file in job %d.', jobId, { error: err }) | |
17 | return callback() | |
18 | } | |
19 | ||
20 | function 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 | ||
33 | export { | |
34 | process, | |
35 | onError, | |
36 | onSuccess | |
37 | } |