Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
This commit is contained in:
parent
69f224587e
commit
93e1258c7c
30 changed files with 818 additions and 340 deletions
|
@ -1,4 +1,5 @@
|
|||
import { readFileSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import * as parseTorrent from 'parse-torrent'
|
||||
|
||||
import { CONFIG, STATIC_PATHS } from '../server/initializers/constants'
|
||||
|
@ -19,17 +20,10 @@ db.init(true)
|
|||
return db.Video.list()
|
||||
})
|
||||
.then(videos => {
|
||||
videos.forEach(function (video) {
|
||||
const torrentName = video.id + '.torrent'
|
||||
const torrentPath = CONFIG.STORAGE.TORRENTS_DIR + torrentName
|
||||
const filename = video.id + video.extname
|
||||
|
||||
const parsed = parseTorrent(readFileSync(torrentPath))
|
||||
parsed.announce = [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOST + '/tracker/socket' ]
|
||||
parsed.urlList = [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + filename ]
|
||||
|
||||
const buf = parseTorrent.toTorrentFile(parsed)
|
||||
writeFileSync(torrentPath, buf)
|
||||
videos.forEach(video => {
|
||||
video.VideoFiles.forEach(file => {
|
||||
video.createTorrentAndSetInfoHash(file)
|
||||
})
|
||||
})
|
||||
|
||||
process.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue