aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/webtorrent.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/webtorrent.ts')
-rw-r--r--server/helpers/webtorrent.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index 4e08c27c6..d8220ba9c 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -7,13 +7,14 @@ import * as WebTorrent from 'webtorrent'
7import { isArray } from '@server/helpers/custom-validators/misc' 7import { isArray } from '@server/helpers/custom-validators/misc'
8import { WEBSERVER } from '@server/initializers/constants' 8import { WEBSERVER } from '@server/initializers/constants'
9import { generateTorrentFileName, getVideoFilePath } from '@server/lib/video-paths' 9import { generateTorrentFileName, getVideoFilePath } from '@server/lib/video-paths'
10import { MVideo, MVideoWithHost } from '@server/types/models/video/video' 10import { MVideo } from '@server/types/models/video/video'
11import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file' 11import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file'
12import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist' 12import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist'
13import { CONFIG } from '../initializers/config' 13import { CONFIG } from '../initializers/config'
14import { promisify2 } from './core-utils' 14import { promisify2 } from './core-utils'
15import { logger } from './logger' 15import { logger } from './logger'
16import { generateVideoImportTmpPath } from './utils' 16import { generateVideoImportTmpPath } from './utils'
17import { extractVideo } from './video'
17 18
18const createTorrentPromise = promisify2<string, any, any>(createTorrent) 19const createTorrentPromise = promisify2<string, any, any>(createTorrent)
19 20
@@ -77,12 +78,12 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
77 }) 78 })
78} 79}
79 80
80// FIXME: refactor/merge videoOrPlaylist and video arguments
81async function createTorrentAndSetInfoHash ( 81async function createTorrentAndSetInfoHash (
82 videoOrPlaylist: MVideo | MStreamingPlaylistVideo, 82 videoOrPlaylist: MVideo | MStreamingPlaylistVideo,
83 video: MVideoWithHost,
84 videoFile: MVideoFile 83 videoFile: MVideoFile
85) { 84) {
85 const video = extractVideo(videoOrPlaylist)
86
86 const options = { 87 const options = {
87 // Keep the extname, it's used by the client to stream the file inside a web browser 88 // Keep the extname, it's used by the client to stream the file inside a web browser
88 name: `${video.name} ${videoFile.resolution}p${videoFile.extname}`, 89 name: `${video.name} ${videoFile.resolution}p${videoFile.extname}`,
@@ -108,7 +109,7 @@ async function createTorrentAndSetInfoHash (
108} 109}
109 110
110function generateMagnetUri ( 111function generateMagnetUri (
111 video: MVideoWithHost, 112 video: MVideo,
112 videoFile: MVideoFileRedundanciesOpt, 113 videoFile: MVideoFileRedundanciesOpt,
113 trackerUrls: string[] 114 trackerUrls: string[]
114) { 115) {