diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-27 16:21:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-27 16:21:19 +0200 |
commit | e3c9ea722629a7d2b5656299ea51aec8c903b8ae (patch) | |
tree | 017bd8463c300d90b66e7ae26cbbb286beb9a949 /server/controllers | |
parent | 41fb13c330de629df2d23379209e79c7af0f2e9a (diff) | |
download | PeerTube-e3c9ea722629a7d2b5656299ea51aec8c903b8ae.tar.gz PeerTube-e3c9ea722629a7d2b5656299ea51aec8c903b8ae.tar.zst PeerTube-e3c9ea722629a7d2b5656299ea51aec8c903b8ae.zip |
Add peertube import test
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/videos/import.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 39fc57788..5f90e4308 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 { decode } from 'magnet-uri' | 3 | import { decode } from 'magnet-uri' |
4 | import parseTorrent, { Instance } from 'parse-torrent' | 4 | import parseTorrent, { Instance } from 'parse-torrent' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { isVideoFileExtnameValid } from '@server/helpers/custom-validators/videos' | ||
6 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 7 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
7 | import { setVideoTags } from '@server/lib/video' | 8 | import { setVideoTags } from '@server/lib/video' |
8 | import { FilteredModelAttributes } from '@server/types' | 9 | import { FilteredModelAttributes } from '@server/types' |
@@ -185,11 +186,14 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
185 | // Get video subtitles | 186 | // Get video subtitles |
186 | await processYoutubeSubtitles(youtubeDL, targetUrl, video.id) | 187 | await processYoutubeSubtitles(youtubeDL, targetUrl, video.id) |
187 | 188 | ||
189 | let fileExt = `.${youtubeDLInfo.ext}` | ||
190 | if (!isVideoFileExtnameValid(fileExt)) fileExt = '.mp4' | ||
191 | |||
188 | // Create job to import the video | 192 | // Create job to import the video |
189 | const payload = { | 193 | const payload = { |
190 | type: 'youtube-dl' as 'youtube-dl', | 194 | type: 'youtube-dl' as 'youtube-dl', |
191 | videoImportId: videoImport.id, | 195 | videoImportId: videoImport.id, |
192 | fileExt: `.${youtubeDLInfo.ext || 'mp4'}` | 196 | fileExt |
193 | } | 197 | } |
194 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) | 198 | await JobQueue.Instance.createJobWithPromise({ type: 'video-import', payload }) |
195 | 199 | ||