diff options
Diffstat (limited to 'src/videos.js')
-rw-r--r-- | src/videos.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/videos.js b/src/videos.js index 32f26abe7..90821fdf6 100644 --- a/src/videos.js +++ b/src/videos.js | |||
@@ -43,6 +43,18 @@ | |||
43 | }) | 43 | }) |
44 | } | 44 | } |
45 | 45 | ||
46 | videos.listOwned = function (callback) { | ||
47 | // If namePath is not null this is *our* video | ||
48 | VideosDB.find({ namePath: { $ne: null } }, function (err, videos_list) { | ||
49 | if (err) { | ||
50 | logger.error('Cannot get list of the videos.', { error: err }) | ||
51 | return callback(err) | ||
52 | } | ||
53 | |||
54 | return callback(null, videos_list) | ||
55 | }) | ||
56 | } | ||
57 | |||
46 | videos.add = function (data, callback) { | 58 | videos.add = function (data, callback) { |
47 | var video_file = data.video | 59 | var video_file = data.video |
48 | var video_data = data.data | 60 | var video_data = data.data |
@@ -131,6 +143,8 @@ | |||
131 | 143 | ||
132 | // Use the magnet Uri because the _id field is not the same on different servers | 144 | // Use the magnet Uri because the _id field is not the same on different servers |
133 | videos.removeRemotes = function (fromUrl, magnetUris, callback) { | 145 | videos.removeRemotes = function (fromUrl, magnetUris, callback) { |
146 | if (callback === undefined) callback = function () {} | ||
147 | |||
134 | VideosDB.find({ magnetUri: { $in: magnetUris } }, function (err, videos) { | 148 | VideosDB.find({ magnetUri: { $in: magnetUris } }, function (err, videos) { |
135 | if (err || !videos) { | 149 | if (err || !videos) { |
136 | logger.error('Cannot find the torrent URI of these remote videos.') | 150 | logger.error('Cannot find the torrent URI of these remote videos.') |
@@ -155,14 +169,34 @@ | |||
155 | return callback(err) | 169 | return callback(err) |
156 | } | 170 | } |
157 | 171 | ||
172 | logger.info('Removed remote videos from %s.', fromUrl) | ||
158 | callback(null) | 173 | callback(null) |
159 | }) | 174 | }) |
160 | }) | 175 | }) |
161 | }) | 176 | }) |
162 | } | 177 | } |
163 | 178 | ||
179 | videos.removeAllRemotes = function (callback) { | ||
180 | VideosDB.remove({ namePath: null }, function (err) { | ||
181 | if (err) return callback(err) | ||
182 | |||
183 | callback(null) | ||
184 | }) | ||
185 | } | ||
186 | |||
187 | videos.removeAllRemotesOf = function (fromUrl, callback) { | ||
188 | VideosDB.remove({ podUrl: fromUrl }, function (err) { | ||
189 | if (err) return callback(err) | ||
190 | |||
191 | callback(null) | ||
192 | }) | ||
193 | } | ||
194 | |||
164 | // { name, magnetUri, podUrl } | 195 | // { name, magnetUri, podUrl } |
196 | // TODO: avoid doublons | ||
165 | videos.addRemotes = function (videos, callback) { | 197 | videos.addRemotes = function (videos, callback) { |
198 | if (callback === undefined) callback = function () {} | ||
199 | |||
166 | var to_add = [] | 200 | var to_add = [] |
167 | 201 | ||
168 | async.each(videos, function (video, callback_each) { | 202 | async.each(videos, function (video, callback_each) { |