},
WEBSERVER: {
SCHEME: config.get('webserver.https') === true ? 'https' : 'http',
+ WS: config.get('webserver.https') === true ? 'wss' : 'ws',
HOST: config.get('webserver.host'),
PORT: config.get('webserver.port')
}
'use strict'
-const config = require('config')
const createTorrent = require('create-torrent')
const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs')
const modelUtils = require('./utils')
const utils = require('../helpers/utils')
-const http = config.get('webserver.https') === true ? 'https' : 'http'
-const host = config.get('webserver.host')
-const port = config.get('webserver.port')
-const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED
-
// ---------------------------------------------------------------------------
// TODO: add indexes on searchable columns
tasks.push(
// TODO: refractoring
function (callback) {
- createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) {
+ const options = {
+ announceList: [
+ [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ]
+ ],
+ urlList: [
+ constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename
+ ]
+ }
+
+ createTorrent(videoPath, options, function (err, torrent) {
if (err) return callback(err)
fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) {