From 8efc27bf14f1fe3ed23cd8a6d2de1f0918a7f769 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Feb 2021 11:28:00 +0100 Subject: Cleanup --- server/helpers/webtorrent.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server/helpers/webtorrent.ts') 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' import { isArray } from '@server/helpers/custom-validators/misc' import { WEBSERVER } from '@server/initializers/constants' import { generateTorrentFileName, getVideoFilePath } from '@server/lib/video-paths' -import { MVideo, MVideoWithHost } from '@server/types/models/video/video' +import { MVideo } from '@server/types/models/video/video' import { MVideoFile, MVideoFileRedundanciesOpt } from '@server/types/models/video/video-file' import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist' import { CONFIG } from '../initializers/config' import { promisify2 } from './core-utils' import { logger } from './logger' import { generateVideoImportTmpPath } from './utils' +import { extractVideo } from './video' const createTorrentPromise = promisify2(createTorrent) @@ -77,12 +78,12 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName }) } -// FIXME: refactor/merge videoOrPlaylist and video arguments async function createTorrentAndSetInfoHash ( videoOrPlaylist: MVideo | MStreamingPlaylistVideo, - video: MVideoWithHost, videoFile: MVideoFile ) { + const video = extractVideo(videoOrPlaylist) + const options = { // Keep the extname, it's used by the client to stream the file inside a web browser name: `${video.name} ${videoFile.resolution}p${videoFile.extname}`, @@ -108,7 +109,7 @@ async function createTorrentAndSetInfoHash ( } function generateMagnetUri ( - video: MVideoWithHost, + video: MVideo, videoFile: MVideoFileRedundanciesOpt, trackerUrls: string[] ) { -- cgit v1.2.3