aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/import.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 3b9b887e2..37fd42b90 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -3,6 +3,7 @@ import { move, readFile } from 'fs-extra'
3import * as magnetUtil from 'magnet-uri' 3import * as magnetUtil from 'magnet-uri'
4import * as parseTorrent from 'parse-torrent' 4import * as parseTorrent from 'parse-torrent'
5import { join } from 'path' 5import { join } from 'path'
6import { getEnabledResolutions } from '@server/lib/config'
6import { setVideoTags } from '@server/lib/video' 7import { setVideoTags } from '@server/lib/video'
7import { 8import {
8 MChannelAccountDefault, 9 MChannelAccountDefault,
@@ -24,7 +25,7 @@ import { isArray } from '../../../helpers/custom-validators/misc'
24import { createReqFiles } from '../../../helpers/express-utils' 25import { createReqFiles } from '../../../helpers/express-utils'
25import { logger } from '../../../helpers/logger' 26import { logger } from '../../../helpers/logger'
26import { getSecureTorrentName } from '../../../helpers/utils' 27import { getSecureTorrentName } from '../../../helpers/utils'
27import { getYoutubeDLInfo, getYoutubeDLSubs, YoutubeDLInfo } from '../../../helpers/youtube-dl' 28import { YoutubeDL, YoutubeDLInfo } from '../../../helpers/youtube-dl'
28import { CONFIG } from '../../../initializers/config' 29import { CONFIG } from '../../../initializers/config'
29import { MIMETYPES } from '../../../initializers/constants' 30import { MIMETYPES } from '../../../initializers/constants'
30import { sequelizeTypescript } from '../../../initializers/database' 31import { sequelizeTypescript } from '../../../initializers/database'
@@ -139,10 +140,12 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
139 const targetUrl = body.targetUrl 140 const targetUrl = body.targetUrl
140 const user = res.locals.oauth.token.User 141 const user = res.locals.oauth.token.User
141 142
143 const youtubeDL = new YoutubeDL(targetUrl, getEnabledResolutions('vod'))
144
142 // Get video infos 145 // Get video infos
143 let youtubeDLInfo: YoutubeDLInfo 146 let youtubeDLInfo: YoutubeDLInfo
144 try { 147 try {
145 youtubeDLInfo = await getYoutubeDLInfo(targetUrl) 148 youtubeDLInfo = await youtubeDL.getYoutubeDLInfo()
146 } catch (err) { 149 } catch (err) {
147 logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) 150 logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err })
148 151
@@ -188,7 +191,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
188 191
189 // Get video subtitles 192 // Get video subtitles
190 try { 193 try {
191 const subtitles = await getYoutubeDLSubs(targetUrl) 194 const subtitles = await youtubeDL.getYoutubeDLSubs()
192 195
193 logger.info('Will create %s subtitles from youtube import %s.', subtitles.length, targetUrl) 196 logger.info('Will create %s subtitles from youtube import %s.', subtitles.length, targetUrl)
194 197