diff options
Diffstat (limited to 'server/lib/videos.js')
-rw-r--r-- | server/lib/videos.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/server/lib/videos.js b/server/lib/videos.js index e0db0e1d5..a74c77dc4 100644 --- a/server/lib/videos.js +++ b/server/lib/videos.js | |||
@@ -17,6 +17,7 @@ const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uplo | |||
17 | const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails')) | 17 | const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails')) |
18 | 18 | ||
19 | const videos = { | 19 | const videos = { |
20 | convertVideoToRemote: convertVideoToRemote, | ||
20 | createRemoteVideos: createRemoteVideos, | 21 | createRemoteVideos: createRemoteVideos, |
21 | getVideoDuration: getVideoDuration, | 22 | getVideoDuration: getVideoDuration, |
22 | getVideoState: getVideoState, | 23 | getVideoState: getVideoState, |
@@ -27,6 +28,29 @@ const videos = { | |||
27 | seedAllExisting: seedAllExisting | 28 | seedAllExisting: seedAllExisting |
28 | } | 29 | } |
29 | 30 | ||
31 | function convertVideoToRemote (video, callback) { | ||
32 | fs.readFile(thumbnailsDir + video.thumbnail, function (err, thumbnailData) { | ||
33 | if (err) { | ||
34 | logger.error('Cannot read the thumbnail of the video') | ||
35 | return callback(err) | ||
36 | } | ||
37 | |||
38 | const remoteVideo = { | ||
39 | name: video.name, | ||
40 | description: video.description, | ||
41 | magnetUri: video.magnetUri, | ||
42 | author: video.author, | ||
43 | duration: video.duration, | ||
44 | thumbnailBase64: new Buffer(thumbnailData).toString('base64'), | ||
45 | tags: video.tags, | ||
46 | createdDate: video.createdDate, | ||
47 | podUrl: video.podUrl | ||
48 | } | ||
49 | |||
50 | return callback(null, remoteVideo) | ||
51 | }) | ||
52 | } | ||
53 | |||
30 | function createRemoteVideos (videos, callback) { | 54 | function createRemoteVideos (videos, callback) { |
31 | // Create the remote videos from the new pod | 55 | // Create the remote videos from the new pod |
32 | createRemoteVideoObjects(videos, function (err, remoteVideos) { | 56 | createRemoteVideoObjects(videos, function (err, remoteVideos) { |
@@ -154,7 +178,8 @@ function createRemoteVideoObjects (videos, callback) { | |||
154 | podUrl: video.podUrl, | 178 | podUrl: video.podUrl, |
155 | duration: video.duration, | 179 | duration: video.duration, |
156 | thumbnail: thumbnailName, | 180 | thumbnail: thumbnailName, |
157 | tags: video.tags | 181 | tags: video.tags, |
182 | author: video.author | ||
158 | } | 183 | } |
159 | remoteVideos.push(params) | 184 | remoteVideos.push(params) |
160 | 185 | ||