const createTorrentPromise = promisify2<string, any, any>(createTorrent)
-async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {
- const id = target.magnetUri || target.torrentName
+async function downloadWebTorrentVideo (target: { uri: string, torrentName?: string }, timeout: number) {
+ const id = target.uri || target.torrentName
let timer
const path = generateVideoImportTmpPath(id)
const webtorrent = new WebTorrent()
let file: TorrentFile
- const torrentId = target.magnetUri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName)
+ const torrentId = target.uri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName)
const options = { path: directoryPath }
const torrent = webtorrent.add(torrentId, options, torrent => {
}
const target = {
torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined,
- magnetUri: videoImport.magnetUri
+ uri: videoImport.magnetUri
}
return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options)
}
import { move } from 'fs-extra'
import { join } from 'path'
import { getServerActor } from '@server/models/application/application'
-import { TrackerModel } from '@server/models/server/tracker'
import { VideoModel } from '@server/models/video/video'
import {
MStreamingPlaylistFiles,
} from '@server/types/models'
import { VideosRedundancyStrategy } from '../../../shared/models/redundancy'
import { logger, loggerTagsFactory } from '../../helpers/logger'
-import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent'
+import { downloadWebTorrentVideo } from '../../helpers/webtorrent'
import { CONFIG } from '../../initializers/config'
import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers/constants'
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, strategy, lTags(video.uuid))
- const trackerUrls = await TrackerModel.listUrlsByVideoId(video.id)
- const magnetUri = generateMagnetUri(video, file, trackerUrls)
-
- const tmpPath = await downloadWebTorrentVideo({ magnetUri }, VIDEO_IMPORT_TIMEOUT)
+ const tmpPath = await downloadWebTorrentVideo({ uri: file.torrentUrl }, VIDEO_IMPORT_TIMEOUT)
const destPath = join(CONFIG.STORAGE.REDUNDANCY_DIR, file.filename)
await move(tmpPath, destPath, { overwrite: true })