1 import { database as db } from '../../../initializers/database'
2 import { logger } from '../../../helpers'
3 import { addVideoToFriends } from '../../../lib'
4 import { VideoInstance } from '../../../models'
6 function process (data: { id: string }) {
7 return db.Video.loadAndPopulateAuthorAndPodAndTags(data.id).then(video => {
8 return video.transcodeVideofile().then(() => video)
12 function onError (err: Error, jobId: number) {
13 logger.error('Error when transcoding video file in job %d.', jobId, err)
14 return Promise.resolve()
17 function onSuccess (jobId: number, video: VideoInstance) {
18 logger.info('Job %d is a success.', jobId)
20 video.toAddRemoteJSON().then(remoteVideo => {
21 // Now we'll add the video's meta data to our friends
22 return addVideoToFriends(remoteVideo, null)
26 // ---------------------------------------------------------------------------