diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.js | 1 | ||||
-rw-r--r-- | server/models/video.js | 17 |
2 files changed, 11 insertions, 7 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 09c4f755e..fb1cbc5f3 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -44,6 +44,7 @@ const CONFIG = { | |||
44 | }, | 44 | }, |
45 | WEBSERVER: { | 45 | WEBSERVER: { |
46 | SCHEME: config.get('webserver.https') === true ? 'https' : 'http', | 46 | SCHEME: config.get('webserver.https') === true ? 'https' : 'http', |
47 | WS: config.get('webserver.https') === true ? 'wss' : 'ws', | ||
47 | HOST: config.get('webserver.host'), | 48 | HOST: config.get('webserver.host'), |
48 | PORT: config.get('webserver.port') | 49 | PORT: config.get('webserver.port') |
49 | } | 50 | } |
diff --git a/server/models/video.js b/server/models/video.js index 9272bea6d..4b941a40c 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -1,6 +1,5 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | ||
4 | const createTorrent = require('create-torrent') | 3 | const createTorrent = require('create-torrent') |
5 | const ffmpeg = require('fluent-ffmpeg') | 4 | const ffmpeg = require('fluent-ffmpeg') |
6 | const fs = require('fs') | 5 | const fs = require('fs') |
@@ -16,11 +15,6 @@ const logger = require('../helpers/logger') | |||
16 | const modelUtils = require('./utils') | 15 | const modelUtils = require('./utils') |
17 | const utils = require('../helpers/utils') | 16 | const utils = require('../helpers/utils') |
18 | 17 | ||
19 | const http = config.get('webserver.https') === true ? 'https' : 'http' | ||
20 | const host = config.get('webserver.host') | ||
21 | const port = config.get('webserver.port') | ||
22 | const webseedBaseUrl = http + '://' + host + ':' + port + constants.STATIC_PATHS.WEBSEED | ||
23 | |||
24 | // --------------------------------------------------------------------------- | 18 | // --------------------------------------------------------------------------- |
25 | 19 | ||
26 | // TODO: add indexes on searchable columns | 20 | // TODO: add indexes on searchable columns |
@@ -106,7 +100,16 @@ VideoSchema.pre('save', function (next) { | |||
106 | tasks.push( | 100 | tasks.push( |
107 | // TODO: refractoring | 101 | // TODO: refractoring |
108 | function (callback) { | 102 | function (callback) { |
109 | createTorrent(videoPath, { announceList: [ [ 'ws://' + host + ':' + port + '/tracker/socket' ] ], urlList: [ webseedBaseUrl + video.filename ] }, function (err, torrent) { | 103 | const options = { |
104 | announceList: [ | ||
105 | [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + ':' + constants.CONFIG.WEBSERVER.PORT + '/tracker/socket' ] | ||
106 | ], | ||
107 | urlList: [ | ||
108 | constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + video.filename | ||
109 | ] | ||
110 | } | ||
111 | |||
112 | createTorrent(videoPath, options, function (err, torrent) { | ||
110 | if (err) return callback(err) | 113 | if (err) return callback(err) |
111 | 114 | ||
112 | fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { | 115 | fs.writeFile(constants.CONFIG.STORAGE.TORRENTS_DIR + video.filename + '.torrent', torrent, function (err) { |