diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-21 16:28:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-22 10:25:24 +0200 |
commit | 62549e6c9818f422698f030e0b242609115493ed (patch) | |
tree | 12a969f694239fe5f926f779698df9523605ee80 /server/controllers | |
parent | a71d4140a5b7831dbe2eb7a0dfaa6a755cb2e906 (diff) | |
download | PeerTube-62549e6c9818f422698f030e0b242609115493ed.tar.gz PeerTube-62549e6c9818f422698f030e0b242609115493ed.tar.zst PeerTube-62549e6c9818f422698f030e0b242609115493ed.zip |
Rewrite youtube-dl import
Use python3 binary
Allows to use a custom youtube-dl release URL
Allows to use yt-dlp (youtube-dl fork)
Remove proxy config from configuration to use HTTP_PROXY and HTTPS_PROXY
env variables
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/videos/import.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 4265f3217..eddb9b32d 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -26,7 +26,7 @@ import { isArray } from '../../../helpers/custom-validators/misc' | |||
26 | import { cleanUpReqFiles, createReqFiles } from '../../../helpers/express-utils' | 26 | import { cleanUpReqFiles, createReqFiles } from '../../../helpers/express-utils' |
27 | import { logger } from '../../../helpers/logger' | 27 | import { logger } from '../../../helpers/logger' |
28 | import { getSecureTorrentName } from '../../../helpers/utils' | 28 | import { getSecureTorrentName } from '../../../helpers/utils' |
29 | import { YoutubeDL, YoutubeDLInfo } from '../../../helpers/youtube-dl' | 29 | import { YoutubeDLWrapper, YoutubeDLInfo } from '../../../helpers/youtube-dl' |
30 | import { CONFIG } from '../../../initializers/config' | 30 | import { CONFIG } from '../../../initializers/config' |
31 | import { MIMETYPES } from '../../../initializers/constants' | 31 | import { MIMETYPES } from '../../../initializers/constants' |
32 | import { sequelizeTypescript } from '../../../initializers/database' | 32 | import { sequelizeTypescript } from '../../../initializers/database' |
@@ -134,12 +134,12 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
134 | const targetUrl = body.targetUrl | 134 | const targetUrl = body.targetUrl |
135 | const user = res.locals.oauth.token.User | 135 | const user = res.locals.oauth.token.User |
136 | 136 | ||
137 | const youtubeDL = new YoutubeDL(targetUrl, ServerConfigManager.Instance.getEnabledResolutions('vod')) | 137 | const youtubeDL = new YoutubeDLWrapper(targetUrl, ServerConfigManager.Instance.getEnabledResolutions('vod')) |
138 | 138 | ||
139 | // Get video infos | 139 | // Get video infos |
140 | let youtubeDLInfo: YoutubeDLInfo | 140 | let youtubeDLInfo: YoutubeDLInfo |
141 | try { | 141 | try { |
142 | youtubeDLInfo = await youtubeDL.getYoutubeDLInfo() | 142 | youtubeDLInfo = await youtubeDL.getInfoForDownload() |
143 | } catch (err) { | 143 | } catch (err) { |
144 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) | 144 | logger.info('Cannot fetch information from import for URL %s.', targetUrl, { err }) |
145 | 145 | ||
@@ -373,9 +373,9 @@ function extractNameFromArray (name: string | string[]) { | |||
373 | return isArray(name) ? name[0] : name | 373 | return isArray(name) ? name[0] : name |
374 | } | 374 | } |
375 | 375 | ||
376 | async function processYoutubeSubtitles (youtubeDL: YoutubeDL, targetUrl: string, videoId: number) { | 376 | async function processYoutubeSubtitles (youtubeDL: YoutubeDLWrapper, targetUrl: string, videoId: number) { |
377 | try { | 377 | try { |
378 | const subtitles = await youtubeDL.getYoutubeDLSubs() | 378 | const subtitles = await youtubeDL.getSubtitles() |
379 | 379 | ||
380 | logger.info('Will create %s subtitles from youtube import %s.', subtitles.length, targetUrl) | 380 | logger.info('Will create %s subtitles from youtube import %s.', subtitles.length, targetUrl) |
381 | 381 | ||