aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/videos.js')
-rw-r--r--server/lib/videos.js54
1 files changed, 27 insertions, 27 deletions
diff --git a/server/lib/videos.js b/server/lib/videos.js
index b3497743a..7da4b11d2 100644
--- a/server/lib/videos.js
+++ b/server/lib/videos.js
@@ -29,15 +29,15 @@ const videos = {
29 29
30function createRemoteVideos (videos, callback) { 30function createRemoteVideos (videos, callback) {
31 // Create the remote videos from the new pod 31 // Create the remote videos from the new pod
32 createRemoteVideoObjects(videos, function (err, remote_videos) { 32 createRemoteVideoObjects(videos, function (err, remoteVideos) {
33 if (err) return callback(err) 33 if (err) return callback(err)
34 34
35 Videos.addRemotes(remote_videos, callback) 35 Videos.addRemotes(remoteVideos, callback)
36 }) 36 })
37} 37}
38 38
39function getVideoDuration (video_path, callback) { 39function getVideoDuration (videoPath, callback) {
40 ffmpeg.ffprobe(video_path, function (err, metadata) { 40 ffmpeg.ffprobe(videoPath, function (err, metadata) {
41 if (err) return callback(err) 41 if (err) return callback(err)
42 42
43 return callback(null, Math.floor(metadata.format.duration)) 43 return callback(null, Math.floor(metadata.format.duration))
@@ -54,9 +54,9 @@ function getVideoState (video) {
54 return { exist: exist, owned: owned } 54 return { exist: exist, owned: owned }
55} 55}
56 56
57function getVideoThumbnail (video_path, callback) { 57function getVideoThumbnail (videoPath, callback) {
58 const filename = pathUtils.basename(video_path) + '.jpg' 58 const filename = pathUtils.basename(videoPath) + '.jpg'
59 ffmpeg(video_path) 59 ffmpeg(videoPath)
60 .on('error', callback) 60 .on('error', callback)
61 .on('end', function () { 61 .on('end', function () {
62 callback(null, filename) 62 callback(null, filename)
@@ -71,7 +71,7 @@ function getVideoThumbnail (video_path, callback) {
71 71
72// Remove video datas from disk (video file, thumbnail...) 72// Remove video datas from disk (video file, thumbnail...)
73function removeVideosDataFromDisk (videos, callback) { 73function removeVideosDataFromDisk (videos, callback) {
74 async.each(videos, function (video, callback_each) { 74 async.each(videos, function (video, callbackEach) {
75 fs.unlink(thumbnailsDir + video.thumbnail, function (err) { 75 fs.unlink(thumbnailsDir + video.thumbnail, function (err) {
76 if (err) logger.error('Cannot remove the video thumbnail') 76 if (err) logger.error('Cannot remove the video thumbnail')
77 77
@@ -79,13 +79,13 @@ function removeVideosDataFromDisk (videos, callback) {
79 fs.unlink(uploadDir + video.namePath, function (err) { 79 fs.unlink(uploadDir + video.namePath, function (err) {
80 if (err) { 80 if (err) {
81 logger.error('Cannot remove this video file.') 81 logger.error('Cannot remove this video file.')
82 return callback_each(err) 82 return callbackEach(err)
83 } 83 }
84 84
85 callback_each(null) 85 callbackEach(null)
86 }) 86 })
87 } else { 87 } else {
88 callback_each(null) 88 callbackEach(null)
89 } 89 }
90 }) 90 })
91 }, callback) 91 }, callback)
@@ -110,20 +110,20 @@ function seed (path, callback) {
110} 110}
111 111
112function seedAllExisting (callback) { 112function seedAllExisting (callback) {
113 Videos.listOwned(function (err, videos_list) { 113 Videos.listOwned(function (err, videosList) {
114 if (err) { 114 if (err) {
115 logger.error('Cannot get list of the videos to seed.') 115 logger.error('Cannot get list of the videos to seed.')
116 return callback(err) 116 return callback(err)
117 } 117 }
118 118
119 async.each(videos_list, function (video, each_callback) { 119 async.each(videosList, function (video, callbackEach) {
120 seed(uploadDir + video.namePath, function (err) { 120 seed(uploadDir + video.namePath, function (err) {
121 if (err) { 121 if (err) {
122 logger.error('Cannot seed this video.') 122 logger.error('Cannot seed this video.')
123 return callback(err) 123 return callback(err)
124 } 124 }
125 125
126 each_callback(null) 126 callbackEach(null)
127 }) 127 })
128 }, callback) 128 }, callback)
129 }) 129 })
@@ -136,16 +136,16 @@ module.exports = videos
136// --------------------------------------------------------------------------- 136// ---------------------------------------------------------------------------
137 137
138function createRemoteVideoObjects (videos, callback) { 138function createRemoteVideoObjects (videos, callback) {
139 const remote_videos = [] 139 const remoteVideos = []
140 140
141 async.each(videos, function (video, callback_each) { 141 async.each(videos, function (video, callbackEach) {
142 // Creating the thumbnail for this remote video 142 // Creating the thumbnail for this remote video
143 utils.generateRandomString(16, function (err, random_string) { 143 utils.generateRandomString(16, function (err, randomString) {
144 if (err) return callback_each(err) 144 if (err) return callbackEach(err)
145 145
146 const thumbnail_name = random_string + '.jpg' 146 const thumbnailName = randomString + '.jpg'
147 createThumbnailFromBase64(thumbnail_name, video.thumbnail_base64, function (err) { 147 createThumbnailFromBase64(thumbnailName, video.thumbnailBase64, function (err) {
148 if (err) return callback_each(err) 148 if (err) return callbackEach(err)
149 149
150 const params = { 150 const params = {
151 name: video.name, 151 name: video.name,
@@ -153,21 +153,21 @@ function createRemoteVideoObjects (videos, callback) {
153 magnetUri: video.magnetUri, 153 magnetUri: video.magnetUri,
154 podUrl: video.podUrl, 154 podUrl: video.podUrl,
155 duration: video.duration, 155 duration: video.duration,
156 thumbnail: thumbnail_name 156 thumbnail: thumbnailName
157 } 157 }
158 remote_videos.push(params) 158 remoteVideos.push(params)
159 159
160 callback_each(null) 160 callbackEach(null)
161 }) 161 })
162 }) 162 })
163 }, 163 },
164 function (err) { 164 function (err) {
165 if (err) return callback(err) 165 if (err) return callback(err)
166 166
167 callback(null, remote_videos) 167 callback(null, remoteVideos)
168 }) 168 })
169} 169}
170 170
171function createThumbnailFromBase64 (thumbnail_name, data, callback) { 171function createThumbnailFromBase64 (thumbnailName, data, callback) {
172 fs.writeFile(thumbnailsDir + thumbnail_name, data, { encoding: 'base64' }, callback) 172 fs.writeFile(thumbnailsDir + thumbnailName, data, { encoding: 'base64' }, callback)
173} 173}