diff options
Diffstat (limited to 'server/controllers/api/videos/import.ts')
-rw-r--r-- | server/controllers/api/videos/import.ts | 10 |
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' | |||
18 | import { isArray } from '../../../helpers/custom-validators/misc' | 18 | import { isArray } from '../../../helpers/custom-validators/misc' |
19 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | 19 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' |
20 | import { VideoChannelModel } from '../../../models/video/video-channel' | 20 | import { VideoChannelModel } from '../../../models/video/video-channel' |
21 | import { UserModel } from '../../../models/account/user' | ||
21 | import * as Bluebird from 'bluebird' | 22 | import * as Bluebird from 'bluebird' |
22 | import * as parseTorrent from 'parse-torrent' | 23 | import * as parseTorrent from 'parse-torrent' |
23 | import { getSecureTorrentName } from '../../../helpers/utils' | 24 | import { getSecureTorrentName } from '../../../helpers/utils' |
24 | import { readFile, move } from 'fs-extra' | 25 | import { readFile, move } from 'fs-extra' |
26 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | ||
25 | 27 | ||
26 | const auditLogger = auditLoggerFactory('video-imports') | 28 | const auditLogger = auditLoggerFactory('video-imports') |
27 | const videoImportsRouter = express.Router() | 29 | const 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 | ||
159 | function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo) { | 161 | function 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) |