1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Prepare folders structure for angular app

This commit is contained in:
Chocobozzz 2016-03-07 11:33:59 +01:00
parent b2ff5e3e68
commit b9a3e09ad5
60 changed files with 13 additions and 86 deletions

50
server/lib/videos.js Normal file
View file

@ -0,0 +1,50 @@
'use strict'
var async = require('async')
var config = require('config')
var path = require('path')
var webtorrent = require('../lib/webtorrent')
var logger = require('../helpers/logger')
var Videos = require('../models/videos')
var uploadDir = path.join(__dirname, '..', config.get('storage.uploads'))
var videos = {
seed: seed,
seedAllExisting: seedAllExisting
}
function seed (path, callback) {
logger.info('Seeding %s...', path)
webtorrent.seed(path, function (torrent) {
logger.info('%s seeded (%s).', path, torrent.magnetURI)
return callback(null, torrent)
})
}
function seedAllExisting (callback) {
Videos.listOwned(function (err, videos_list) {
if (err) {
logger.error('Cannot get list of the videos to seed.')
return callback(err)
}
async.each(videos_list, function (video, each_callback) {
seed(uploadDir + video.namePath, function (err) {
if (err) {
logger.error('Cannot seed this video.')
return callback(err)
}
each_callback(null)
})
}, callback)
})
}
// ---------------------------------------------------------------------------
module.exports = videos