+
+// ---------------------------------------------------------------------------
+
+function createRemoteVideoObjects (videos, callback) {
+ const remoteVideos = []
+
+ async.each(videos, function (video, callbackEach) {
+ // Creating the thumbnail for this remote video
+ utils.generateRandomString(16, function (err, randomString) {
+ if (err) return callbackEach(err)
+
+ const thumbnailName = randomString + '.jpg'
+ createThumbnailFromBase64(thumbnailName, video.thumbnailBase64, function (err) {
+ if (err) return callbackEach(err)
+
+ const params = {
+ name: video.name,
+ description: video.description,
+ magnetUri: video.magnetUri,
+ podUrl: video.podUrl,
+ duration: video.duration,
+ thumbnail: thumbnailName,
+ tags: video.tags,
+ author: video.author
+ }
+ remoteVideos.push(params)
+
+ callbackEach(null)
+ })
+ })
+ },
+ function (err) {
+ if (err) return callback(err)
+
+ callback(null, remoteVideos)
+ })
+}
+
+function createThumbnailFromBase64 (thumbnailName, data, callback) {
+ fs.writeFile(thumbnailsDir + thumbnailName, data, { encoding: 'base64' }, callback)
+}