diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/import.ts | 9 |
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' | |||
3 | import * as magnetUtil from 'magnet-uri' | 3 | import * as magnetUtil from 'magnet-uri' |
4 | import * as parseTorrent from 'parse-torrent' | 4 | import * as parseTorrent from 'parse-torrent' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { getEnabledResolutions } from '@server/lib/config' | ||
6 | import { setVideoTags } from '@server/lib/video' | 7 | import { setVideoTags } from '@server/lib/video' |
7 | import { | 8 | import { |
8 | MChannelAccountDefault, | 9 | MChannelAccountDefault, |
@@ -24,7 +25,7 @@ import { isArray } from '../../../helpers/custom-validators/misc' | |||
24 | import { createReqFiles } from '../../../helpers/express-utils' | 25 | import { createReqFiles } from '../../../helpers/express-utils' |
25 | import { logger } from '../../../helpers/logger' | 26 | import { logger } from '../../../helpers/logger' |
26 | import { getSecureTorrentName } from '../../../helpers/utils' | 27 | import { getSecureTorrentName } from '../../../helpers/utils' |
27 | import { getYoutubeDLInfo, getYoutubeDLSubs, YoutubeDLInfo } from '../../../helpers/youtube-dl' | 28 | import { YoutubeDL, YoutubeDLInfo } from '../../../helpers/youtube-dl' |
28 | import { CONFIG } from '../../../initializers/config' | 29 | import { CONFIG } from '../../../initializers/config' |
29 | import { MIMETYPES } from '../../../initializers/constants' | 30 | import { MIMETYPES } from '../../../initializers/constants' |
30 | import { sequelizeTypescript } from '../../../initializers/database' | 31 | import { 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 | ||