X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideos.js;h=a74c77dc4c98b8bdf37cb80c7d67a4b03275030f;hb=528a9efa8272532bbd0dafc35c3e05e57c50f61e;hp=7da4b11d2bb06b21ad1016575623eba944e7558c;hpb=bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/videos.js b/server/lib/videos.js index 7da4b11d2..a74c77dc4 100644 --- a/server/lib/videos.js +++ b/server/lib/videos.js @@ -17,16 +17,40 @@ const uploadDir = pathUtils.join(__dirname, '..', '..', config.get('storage.uplo const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails')) const videos = { + convertVideoToRemote: convertVideoToRemote, createRemoteVideos: createRemoteVideos, getVideoDuration: getVideoDuration, getVideoState: getVideoState, - getVideoThumbnail: getVideoThumbnail, + createVideoThumbnail: createVideoThumbnail, removeVideosDataFromDisk: removeVideosDataFromDisk, removeRemoteVideos: removeRemoteVideos, seed: seed, seedAllExisting: seedAllExisting } +function convertVideoToRemote (video, callback) { + fs.readFile(thumbnailsDir + video.thumbnail, function (err, thumbnailData) { + if (err) { + logger.error('Cannot read the thumbnail of the video') + return callback(err) + } + + const remoteVideo = { + name: video.name, + description: video.description, + magnetUri: video.magnetUri, + author: video.author, + duration: video.duration, + thumbnailBase64: new Buffer(thumbnailData).toString('base64'), + tags: video.tags, + createdDate: video.createdDate, + podUrl: video.podUrl + } + + return callback(null, remoteVideo) + }) +} + function createRemoteVideos (videos, callback) { // Create the remote videos from the new pod createRemoteVideoObjects(videos, function (err, remoteVideos) { @@ -54,7 +78,7 @@ function getVideoState (video) { return { exist: exist, owned: owned } } -function getVideoThumbnail (videoPath, callback) { +function createVideoThumbnail (videoPath, callback) { const filename = pathUtils.basename(videoPath) + '.jpg' ffmpeg(videoPath) .on('error', callback) @@ -153,7 +177,9 @@ function createRemoteVideoObjects (videos, callback) { magnetUri: video.magnetUri, podUrl: video.podUrl, duration: video.duration, - thumbnail: thumbnailName + thumbnail: thumbnailName, + tags: video.tags, + author: video.author } remoteVideos.push(params)