aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/update-host.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/update-host.js')
-rwxr-xr-xscripts/update-host.js42
1 files changed, 0 insertions, 42 deletions
diff --git a/scripts/update-host.js b/scripts/update-host.js
deleted file mode 100755
index 8ae0f0d0e..000000000
--- a/scripts/update-host.js
+++ /dev/null
@@ -1,42 +0,0 @@
1#!/usr/bin/env node
2
3'use strict'
4
5const fs = require('fs')
6const parseTorrent = require('parse-torrent')
7
8const constants = require('../server/initializers/constants')
9const db = require('../server/initializers/database')
10
11const friends = require('../server/lib/friends')
12
13db.init(true, function () {
14 friends.hasFriends(function (err, hasFriends) {
15 if (err) throw err
16
17 if (hasFriends === true) {
18 console.log('Cannot update host because you have friends!')
19 process.exit(-1)
20 }
21
22 console.log('Updating torrent files.')
23 db.Video.list(function (err, videos) {
24 if (err) throw err
25
26 videos.forEach(function (video) {
27 const torrentName = video.id + '.torrent'
28 const torrentPath = constants.CONFIG.STORAGE.TORRENTS_DIR + torrentName
29 const filename = video.id + video.extname
30
31 const parsed = parseTorrent(fs.readFileSync(torrentPath))
32 parsed.announce = [ constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOST + '/tracker/socket' ]
33 parsed.urlList = [ constants.CONFIG.WEBSERVER.URL + constants.STATIC_PATHS.WEBSEED + filename ]
34
35 const buf = parseTorrent.toTorrentFile(parsed)
36 fs.writeFileSync(torrentPath, buf)
37 })
38
39 process.exit(0)
40 })
41 })
42})