aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/webtorrent.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-18 11:28:00 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-18 13:38:09 +0100
commit8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769 (patch)
tree863daf231cf4a66d9e5abf1cfe4fbe2b742cd856 /server/helpers/webtorrent.ts
parentf66db4d5c851fe87bb71cccee96926000f59a15b (diff)
downloadPeerTube-8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769.tar.gz
PeerTube-8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769.tar.zst
PeerTube-8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769.zip
Cleanup
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) {