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.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index cbd2e8514..c234a1391 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -18,10 +18,12 @@ import { join } from 'path'
18import { isArray } from '../../../helpers/custom-validators/misc' 18import { isArray } from '../../../helpers/custom-validators/misc'
19import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' 19import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model'
20import { VideoChannelModel } from '../../../models/video/video-channel' 20import { VideoChannelModel } from '../../../models/video/video-channel'
21import { UserModel } from '../../../models/account/user'
21import * as Bluebird from 'bluebird' 22import * as Bluebird from 'bluebird'
22import * as parseTorrent from 'parse-torrent' 23import * as parseTorrent from 'parse-torrent'
23import { getSecureTorrentName } from '../../../helpers/utils' 24import { getSecureTorrentName } from '../../../helpers/utils'
24import { readFile, move } from 'fs-extra' 25import { readFile, move } from 'fs-extra'
26import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
25 27
26const auditLogger = auditLoggerFactory('video-imports') 28const auditLogger = auditLoggerFactory('video-imports')
27const videoImportsRouter = express.Router() 29const videoImportsRouter = express.Router()
@@ -85,7 +87,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to
85 videoName = isArray(parsed.name) ? parsed.name[ 0 ] : parsed.name as string 87 videoName = isArray(parsed.name) ? parsed.name[ 0 ] : parsed.name as string
86 } 88 }
87 89
88 const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }) 90 const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }, user)
89 91
90 await processThumbnail(req, video) 92 await processThumbnail(req, video)
91 await processPreview(req, video) 93 await processPreview(req, video)
@@ -128,7 +130,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
128 }).end() 130 }).end()
129 } 131 }
130 132
131 const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) 133 const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo, user)
132 134
133 const downloadThumbnail = !await processThumbnail(req, video) 135 const downloadThumbnail = !await processThumbnail(req, video)
134 const downloadPreview = !await processPreview(req, video) 136 const downloadPreview = !await processPreview(req, video)
@@ -156,7 +158,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response)
156 return res.json(videoImport.toFormattedJSON()).end() 158 return res.json(videoImport.toFormattedJSON()).end()
157} 159}
158 160
159function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo) { 161function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo, user: UserModel) {
160 const videoData = { 162 const videoData = {
161 name: body.name || importData.name || 'Unknown name', 163 name: body.name || importData.name || 'Unknown name',
162 remote: false, 164 remote: false,
@@ -218,6 +220,8 @@ function insertIntoDB (
218 const videoCreated = await video.save(sequelizeOptions) 220 const videoCreated = await video.save(sequelizeOptions)
219 videoCreated.VideoChannel = videoChannel 221 videoCreated.VideoChannel = videoChannel
220 222
223 await autoBlacklistVideoIfNeeded(video, videoChannel.Account.User, t)
224
221 // Set tags to the video 225 // Set tags to the video
222 if (tags) { 226 if (tags) {
223 const tagInstances = await TagModel.findOrCreateTags(tags, t) 227 const tagInstances = await TagModel.findOrCreateTags(tags, t)