aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/import.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/import.ts')
-rw-r--r--server/controllers/api/videos/import.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index eddb9b32d..52864bdfd 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -38,6 +38,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoIm
38import { VideoModel } from '../../../models/video/video' 38import { VideoModel } from '../../../models/video/video'
39import { VideoCaptionModel } from '../../../models/video/video-caption' 39import { VideoCaptionModel } from '../../../models/video/video-caption'
40import { VideoImportModel } from '../../../models/video/video-import' 40import { VideoImportModel } from '../../../models/video/video-import'
41import { Hooks } from '@server/lib/plugins/hooks'
41 42
42const auditLogger = auditLoggerFactory('video-imports') 43const auditLogger = auditLoggerFactory('video-imports')
43const videoImportsRouter = express.Router() 44const videoImportsRouter = express.Router()
@@ -94,7 +95,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
94 videoName = result.name 95 videoName = result.name
95 } 96 }
96 97
97 const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }) 98 const video = await buildVideo(res.locals.videoChannel.id, body, { name: videoName })
98 99
99 const thumbnailModel = await processThumbnail(req, video) 100 const thumbnailModel = await processThumbnail(req, video)
100 const previewModel = await processPreview(req, video) 101 const previewModel = await processPreview(req, video)
@@ -151,7 +152,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
151 }) 152 })
152 } 153 }
153 154
154 const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) 155 const video = await buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo)
155 156
156 // Process video thumbnail from request.files 157 // Process video thumbnail from request.files
157 let thumbnailModel = await processThumbnail(req, video) 158 let thumbnailModel = await processThumbnail(req, video)
@@ -210,8 +211,8 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
210 return res.json(videoImport.toFormattedJSON()).end() 211 return res.json(videoImport.toFormattedJSON()).end()
211} 212}
212 213
213function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo): MVideoThumbnail { 214async function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo): Promise<MVideoThumbnail> {
214 const videoData = { 215 let videoData = {
215 name: body.name || importData.name || 'Unknown name', 216 name: body.name || importData.name || 'Unknown name',
216 remote: false, 217 remote: false,
217 category: body.category || importData.category, 218 category: body.category || importData.category,
@@ -231,6 +232,14 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
231 ? new Date(body.originallyPublishedAt) 232 ? new Date(body.originallyPublishedAt)
232 : importData.originallyPublishedAt 233 : importData.originallyPublishedAt
233 } 234 }
235
236 videoData = await Hooks.wrapObject(
237 videoData,
238 body.targetUrl
239 ? 'filter:api.video.import-url.video-attribute.result'
240 : 'filter:api.video.import-torrent.video-attribute.result'
241 )
242
234 const video = new VideoModel(videoData) 243 const video = new VideoModel(videoData)
235 video.url = getLocalVideoActivityPubUrl(video) 244 video.url = getLocalVideoActivityPubUrl(video)
236 245