const thumbnailsDir = pathUtils.join(__dirname, '..', '..', config.get('storage.thumbnails'))
const videos = {
+ convertVideoToRemote: convertVideoToRemote,
createRemoteVideos: createRemoteVideos,
getVideoDuration: getVideoDuration,
getVideoState: getVideoState,
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) {
magnetUri: video.magnetUri,
podUrl: video.podUrl,
duration: video.duration,
- thumbnail: thumbnailName
+ thumbnail: thumbnailName,
+ tags: video.tags,
+ author: video.author
}
remoteVideos.push(params)