diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 11:36:23 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-08-25 11:36:23 +0200 |
commit | 93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 (patch) | |
tree | b0a1f77af7ab54dc5f58f569fcd1e9d84b04c533 /scripts/update-host.ts | |
parent | 69f224587e99d56008e1fa129d0641840a486620 (diff) | |
download | PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.gz PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.zst PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.zip |
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
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) |