diff options
Diffstat (limited to 'scripts/update-host.ts')
-rwxr-xr-x | scripts/update-host.ts | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 23e8d5ef3..5e69e4172 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { readFileSync, writeFileSync } from 'fs' | 1 | import { readFileSync, writeFileSync } from 'fs' |
2 | import { join } from 'path' | ||
2 | import * as parseTorrent from 'parse-torrent' | 3 | import * as parseTorrent from 'parse-torrent' |
3 | 4 | ||
4 | import { CONFIG, STATIC_PATHS } from '../server/initializers/constants' | 5 | import { CONFIG, STATIC_PATHS } from '../server/initializers/constants' |
@@ -19,17 +20,10 @@ db.init(true) | |||
19 | return db.Video.list() | 20 | return db.Video.list() |
20 | }) | 21 | }) |
21 | .then(videos => { | 22 | .then(videos => { |
22 | videos.forEach(function (video) { | 23 | videos.forEach(video => { |
23 | const torrentName = video.id + '.torrent' | 24 | video.VideoFiles.forEach(file => { |
24 | const torrentPath = CONFIG.STORAGE.TORRENTS_DIR + torrentName | 25 | video.createTorrentAndSetInfoHash(file) |
25 | const filename = video.id + video.extname | 26 | }) |
26 | |||
27 | const parsed = parseTorrent(readFileSync(torrentPath)) | ||
28 | parsed.announce = [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOST + '/tracker/socket' ] | ||
29 | parsed.urlList = [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + filename ] | ||
30 | |||
31 | const buf = parseTorrent.toTorrentFile(parsed) | ||
32 | writeFileSync(torrentPath, buf) | ||
33 | }) | 27 | }) |
34 | 28 | ||
35 | process.exit(0) | 29 | process.exit(0) |