aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/update-host.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-12 21:06:32 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-12 21:06:32 +0200
commit75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615 (patch)
tree016f64d0fc6cfee533516be40d76eaca1b1f837e /scripts/update-host.js
parent7593a21d13baad422efedfb658d7ceda4e0a8c6b (diff)
downloadPeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.tar.gz
PeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.tar.zst
PeerTube-75d612ce3ca9d6f69fe8e4e83dc3070d9ab56615.zip
Convert scripts to typescript
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})