diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index c457b71fc..fd61aecad 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -14,6 +14,7 @@ import { JobQueue } from '../index' | |||
14 | import { federateVideoIfNeeded } from '../../activitypub' | 14 | import { federateVideoIfNeeded } from '../../activitypub' |
15 | import { VideoModel } from '../../../models/video/video' | 15 | import { VideoModel } from '../../../models/video/video' |
16 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 16 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
17 | import { getSecureTorrentName } from '../../../helpers/utils' | ||
17 | 18 | ||
18 | type VideoImportYoutubeDLPayload = { | 19 | type VideoImportYoutubeDLPayload = { |
19 | type: 'youtube-dl' | 20 | type: 'youtube-dl' |
@@ -25,7 +26,7 @@ type VideoImportYoutubeDLPayload = { | |||
25 | } | 26 | } |
26 | 27 | ||
27 | type VideoImportTorrentPayload = { | 28 | type VideoImportTorrentPayload = { |
28 | type: 'magnet-uri' | 29 | type: 'magnet-uri' | 'torrent-file' |
29 | videoImportId: number | 30 | videoImportId: number |
30 | } | 31 | } |
31 | 32 | ||
@@ -35,7 +36,7 @@ async function processVideoImport (job: Bull.Job) { | |||
35 | const payload = job.data as VideoImportPayload | 36 | const payload = job.data as VideoImportPayload |
36 | 37 | ||
37 | if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) | 38 | if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) |
38 | if (payload.type === 'magnet-uri') return processTorrentImport(job, payload) | 39 | if (payload.type === 'magnet-uri' || payload.type === 'torrent-file') return processTorrentImport(job, payload) |
39 | } | 40 | } |
40 | 41 | ||
41 | // --------------------------------------------------------------------------- | 42 | // --------------------------------------------------------------------------- |
@@ -50,6 +51,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP | |||
50 | logger.info('Processing torrent video import in job %d.', job.id) | 51 | logger.info('Processing torrent video import in job %d.', job.id) |
51 | 52 | ||
52 | const videoImport = await getVideoImportOrDie(payload.videoImportId) | 53 | const videoImport = await getVideoImportOrDie(payload.videoImportId) |
54 | |||
53 | const options = { | 55 | const options = { |
54 | videoImportId: payload.videoImportId, | 56 | videoImportId: payload.videoImportId, |
55 | 57 | ||
@@ -59,7 +61,11 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP | |||
59 | generateThumbnail: true, | 61 | generateThumbnail: true, |
60 | generatePreview: true | 62 | generatePreview: true |
61 | } | 63 | } |
62 | return processFile(() => downloadWebTorrentVideo(videoImport.magnetUri), videoImport, options) | 64 | const target = { |
65 | torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined, | ||
66 | magnetUri: videoImport.magnetUri | ||
67 | } | ||
68 | return processFile(() => downloadWebTorrentVideo(target), videoImport, options) | ||
63 | } | 69 | } |
64 | 70 | ||
65 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { | 71 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { |