aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
commit528a9efa8272532bbd0dafc35c3e05e57c50f61e (patch)
tree62d4417df4ab9b2e53c44dc7271be81b88e4e0e5 /server/lib/videos.js
parentb2e4c0ba1a33b8a50491a1f8d111468a7da5640f (diff)
downloadPeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.gz
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.zst
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.zip
Try to make a better communication (between pods) module
Diffstat (limited to 'server/lib/videos.js')
-rw-r--r--server/lib/videos.js27
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
17const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails')) 17const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails'))
18 18
19const videos = { 19const 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
31function 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
30function createRemoteVideos (videos, callback) { 54function 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