index.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. import * as express from 'express'
  2. import { extname, join } from 'path'
  3. import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
  4. import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
  5. import { logger } from '../../../helpers/logger'
  6. import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
  7. import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
  8. import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
  9. import {
  10. DEFAULT_AUDIO_RESOLUTION,
  11. MIMETYPES,
  12. VIDEO_CATEGORIES,
  13. VIDEO_LANGUAGES,
  14. VIDEO_LICENCES,
  15. VIDEO_PRIVACIES
  16. } from '../../../initializers/constants'
  17. import {
  18. changeVideoChannelShare,
  19. federateVideoIfNeeded,
  20. fetchRemoteVideoDescription,
  21. getVideoActivityPubUrl
  22. } from '../../../lib/activitypub'
  23. import { JobQueue } from '../../../lib/job-queue'
  24. import { Redis } from '../../../lib/redis'
  25. import {
  26. asyncMiddleware,
  27. asyncRetryTransactionMiddleware,
  28. authenticate,
  29. checkVideoFollowConstraints,
  30. commonVideosFiltersValidator,
  31. optionalAuthenticate,
  32. paginationValidator,
  33. setDefaultPagination,
  34. setDefaultSort,
  35. videosAddValidator,
  36. videosCustomGetValidator,
  37. videosGetValidator,
  38. videosRemoveValidator,
  39. videosSortValidator,
  40. videosUpdateValidator
  41. } from '../../../middlewares'
  42. import { TagModel } from '../../../models/video/tag'
  43. import { VideoModel } from '../../../models/video/video'
  44. import { VideoFileModel } from '../../../models/video/video-file'
  45. import { abuseVideoRouter } from './abuse'
  46. import { blacklistRouter } from './blacklist'
  47. import { videoCommentRouter } from './comment'
  48. import { rateVideoRouter } from './rate'
  49. import { ownershipVideoRouter } from './ownership'
  50. import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
  51. import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils'
  52. import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
  53. import { videoCaptionsRouter } from './captions'
  54. import { videoImportsRouter } from './import'
  55. import { resetSequelizeInstance } from '../../../helpers/database-utils'
  56. import { move } from 'fs-extra'
  57. import { watchingRouter } from './watching'
  58. import { Notifier } from '../../../lib/notifier'
  59. import { sendView } from '../../../lib/activitypub/send/send-view'
  60. import { CONFIG } from '../../../initializers/config'
  61. import { sequelizeTypescript } from '../../../initializers/database'
  62. import { createVideoMiniatureFromExisting, generateVideoMiniature } from '../../../lib/thumbnail'
  63. import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
  64. import { VideoTranscodingPayload } from '../../../lib/job-queue/handlers/video-transcoding'
  65. import { Hooks } from '../../../lib/plugins/hooks'
  66. import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
  67. import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
  68. import { getVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
  69. const auditLogger = auditLoggerFactory('videos')
  70. const videosRouter = express.Router()
  71. const reqVideoFileAdd = createReqFiles(
  72. [ 'videofile', 'thumbnailfile', 'previewfile' ],
  73. Object.assign({}, MIMETYPES.VIDEO.MIMETYPE_EXT, MIMETYPES.IMAGE.MIMETYPE_EXT),
  74. {
  75. videofile: CONFIG.STORAGE.TMP_DIR,
  76. thumbnailfile: CONFIG.STORAGE.TMP_DIR,
  77. previewfile: CONFIG.STORAGE.TMP_DIR
  78. }
  79. )
  80. const reqVideoFileUpdate = createReqFiles(
  81. [ 'thumbnailfile', 'previewfile' ],
  82. MIMETYPES.IMAGE.MIMETYPE_EXT,
  83. {
  84. thumbnailfile: CONFIG.STORAGE.TMP_DIR,
  85. previewfile: CONFIG.STORAGE.TMP_DIR
  86. }
  87. )
  88. videosRouter.use('/', abuseVideoRouter)
  89. videosRouter.use('/', blacklistRouter)
  90. videosRouter.use('/', rateVideoRouter)
  91. videosRouter.use('/', videoCommentRouter)
  92. videosRouter.use('/', videoCaptionsRouter)
  93. videosRouter.use('/', videoImportsRouter)
  94. videosRouter.use('/', ownershipVideoRouter)
  95. videosRouter.use('/', watchingRouter)
  96. videosRouter.get('/categories', listVideoCategories)
  97. videosRouter.get('/licences', listVideoLicences)
  98. videosRouter.get('/languages', listVideoLanguages)
  99. videosRouter.get('/privacies', listVideoPrivacies)
  100. videosRouter.get('/',
  101. paginationValidator,
  102. videosSortValidator,
  103. setDefaultSort,
  104. setDefaultPagination,
  105. optionalAuthenticate,
  106. commonVideosFiltersValidator,
  107. asyncMiddleware(listVideos)
  108. )
  109. videosRouter.put('/:id',
  110. authenticate,
  111. reqVideoFileUpdate,
  112. asyncMiddleware(videosUpdateValidator),
  113. asyncRetryTransactionMiddleware(updateVideo)
  114. )
  115. videosRouter.post('/upload',
  116. authenticate,
  117. reqVideoFileAdd,
  118. asyncMiddleware(videosAddValidator),
  119. asyncRetryTransactionMiddleware(addVideo)
  120. )
  121. videosRouter.get('/:id/description',
  122. asyncMiddleware(videosGetValidator),
  123. asyncMiddleware(getVideoDescription)
  124. )
  125. videosRouter.get('/:id',
  126. optionalAuthenticate,
  127. asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
  128. asyncMiddleware(checkVideoFollowConstraints),
  129. asyncMiddleware(getVideo)
  130. )
  131. videosRouter.post('/:id/views',
  132. asyncMiddleware(videosGetValidator),
  133. asyncMiddleware(viewVideo)
  134. )
  135. videosRouter.delete('/:id',
  136. authenticate,
  137. asyncMiddleware(videosRemoveValidator),
  138. asyncRetryTransactionMiddleware(removeVideo)
  139. )
  140. // ---------------------------------------------------------------------------
  141. export {
  142. videosRouter
  143. }
  144. // ---------------------------------------------------------------------------
  145. function listVideoCategories (req: express.Request, res: express.Response) {
  146. res.json(VIDEO_CATEGORIES)
  147. }
  148. function listVideoLicences (req: express.Request, res: express.Response) {
  149. res.json(VIDEO_LICENCES)
  150. }
  151. function listVideoLanguages (req: express.Request, res: express.Response) {
  152. res.json(VIDEO_LANGUAGES)
  153. }
  154. function listVideoPrivacies (req: express.Request, res: express.Response) {
  155. res.json(VIDEO_PRIVACIES)
  156. }
  157. async function addVideo (req: express.Request, res: express.Response) {
  158. // Processing the video could be long
  159. // Set timeout to 10 minutes
  160. req.setTimeout(1000 * 60 * 10, () => {
  161. logger.error('Upload video has timed out.')
  162. return res.sendStatus(408)
  163. })
  164. const videoPhysicalFile = req.files['videofile'][0]
  165. const videoInfo: VideoCreate = req.body
  166. // Prepare data so we don't block the transaction
  167. const videoData = {
  168. name: videoInfo.name,
  169. remote: false,
  170. category: videoInfo.category,
  171. licence: videoInfo.licence,
  172. language: videoInfo.language,
  173. commentsEnabled: videoInfo.commentsEnabled !== false, // If the value is not "false", the default is "true"
  174. downloadEnabled: videoInfo.downloadEnabled !== false,
  175. waitTranscoding: videoInfo.waitTranscoding || false,
  176. state: CONFIG.TRANSCODING.ENABLED ? VideoState.TO_TRANSCODE : VideoState.PUBLISHED,
  177. nsfw: videoInfo.nsfw || false,
  178. description: videoInfo.description,
  179. support: videoInfo.support,
  180. privacy: videoInfo.privacy || VideoPrivacy.PRIVATE,
  181. duration: videoPhysicalFile['duration'], // duration was added by a previous middleware
  182. channelId: res.locals.videoChannel.id,
  183. originallyPublishedAt: videoInfo.originallyPublishedAt
  184. }
  185. const video = new VideoModel(videoData) as MVideoDetails
  186. video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
  187. const videoFile = new VideoFileModel({
  188. extname: extname(videoPhysicalFile.filename),
  189. size: videoPhysicalFile.size,
  190. videoStreamingPlaylistId: null
  191. })
  192. if (videoFile.isAudio()) {
  193. videoFile.resolution = DEFAULT_AUDIO_RESOLUTION
  194. } else {
  195. videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path)
  196. videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path)).videoFileResolution
  197. }
  198. // Move physical file
  199. const destination = getVideoFilePath(video, videoFile)
  200. await move(videoPhysicalFile.path, destination)
  201. // This is important in case if there is another attempt in the retry process
  202. videoPhysicalFile.filename = getVideoFilePath(video, videoFile)
  203. videoPhysicalFile.path = destination
  204. // Process thumbnail or create it from the video
  205. const thumbnailField = req.files['thumbnailfile']
  206. const thumbnailModel = thumbnailField
  207. ? await createVideoMiniatureFromExisting(thumbnailField[0].path, video, ThumbnailType.MINIATURE, false)
  208. : await generateVideoMiniature(video, videoFile, ThumbnailType.MINIATURE)
  209. // Process preview or create it from the video
  210. const previewField = req.files['previewfile']
  211. const previewModel = previewField
  212. ? await createVideoMiniatureFromExisting(previewField[0].path, video, ThumbnailType.PREVIEW, false)
  213. : await generateVideoMiniature(video, videoFile, ThumbnailType.PREVIEW)
  214. // Create the torrent file
  215. await createTorrentAndSetInfoHash(video, videoFile)
  216. const { videoCreated } = await sequelizeTypescript.transaction(async t => {
  217. const sequelizeOptions = { transaction: t }
  218. const videoCreated = await video.save(sequelizeOptions) as MVideoFullLight
  219. await videoCreated.addAndSaveThumbnail(thumbnailModel, t)
  220. await videoCreated.addAndSaveThumbnail(previewModel, t)
  221. // Do not forget to add video channel information to the created video
  222. videoCreated.VideoChannel = res.locals.videoChannel
  223. videoFile.videoId = video.id
  224. await videoFile.save(sequelizeOptions)
  225. video.VideoFiles = [ videoFile ]
  226. // Create tags
  227. if (videoInfo.tags !== undefined) {
  228. const tagInstances = await TagModel.findOrCreateTags(videoInfo.tags, t)
  229. await video.$set('Tags', tagInstances, sequelizeOptions)
  230. video.Tags = tagInstances
  231. }
  232. // Schedule an update in the future?
  233. if (videoInfo.scheduleUpdate) {
  234. await ScheduleVideoUpdateModel.create({
  235. videoId: video.id,
  236. updateAt: videoInfo.scheduleUpdate.updateAt,
  237. privacy: videoInfo.scheduleUpdate.privacy || null
  238. }, { transaction: t })
  239. }
  240. await autoBlacklistVideoIfNeeded({
  241. video,
  242. user: res.locals.oauth.token.User,
  243. isRemote: false,
  244. isNew: true,
  245. transaction: t
  246. })
  247. await federateVideoIfNeeded(video, true, t)
  248. auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
  249. logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
  250. return { videoCreated }
  251. })
  252. Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated)
  253. if (video.state === VideoState.TO_TRANSCODE) {
  254. // Put uuid because we don't have id auto incremented for now
  255. let dataInput: VideoTranscodingPayload
  256. if (videoFile.isAudio()) {
  257. dataInput = {
  258. type: 'merge-audio' as 'merge-audio',
  259. resolution: DEFAULT_AUDIO_RESOLUTION,
  260. videoUUID: videoCreated.uuid,
  261. isNewVideo: true
  262. }
  263. } else {
  264. dataInput = {
  265. type: 'optimize' as 'optimize',
  266. videoUUID: videoCreated.uuid,
  267. isNewVideo: true
  268. }
  269. }
  270. await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
  271. }
  272. Hooks.runAction('action:api.video.uploaded', { video: videoCreated })
  273. return res.json({
  274. video: {
  275. id: videoCreated.id,
  276. uuid: videoCreated.uuid
  277. }
  278. }).end()
  279. }
  280. async function updateVideo (req: express.Request, res: express.Response) {
  281. const videoInstance = res.locals.videoAll
  282. const videoFieldsSave = videoInstance.toJSON()
  283. const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON())
  284. const videoInfoToUpdate: VideoUpdate = req.body
  285. const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE
  286. const wasNotPrivateVideo = videoInstance.privacy !== VideoPrivacy.PRIVATE
  287. const wasUnlistedVideo = videoInstance.privacy === VideoPrivacy.UNLISTED
  288. // Process thumbnail or create it from the video
  289. const thumbnailModel = req.files && req.files['thumbnailfile']
  290. ? await createVideoMiniatureFromExisting(req.files['thumbnailfile'][0].path, videoInstance, ThumbnailType.MINIATURE, false)
  291. : undefined
  292. const previewModel = req.files && req.files['previewfile']
  293. ? await createVideoMiniatureFromExisting(req.files['previewfile'][0].path, videoInstance, ThumbnailType.PREVIEW, false)
  294. : undefined
  295. try {
  296. const videoInstanceUpdated = await sequelizeTypescript.transaction(async t => {
  297. const sequelizeOptions = { transaction: t }
  298. const oldVideoChannel = videoInstance.VideoChannel
  299. if (videoInfoToUpdate.name !== undefined) videoInstance.name = videoInfoToUpdate.name
  300. if (videoInfoToUpdate.category !== undefined) videoInstance.category = videoInfoToUpdate.category
  301. if (videoInfoToUpdate.licence !== undefined) videoInstance.licence = videoInfoToUpdate.licence
  302. if (videoInfoToUpdate.language !== undefined) videoInstance.language = videoInfoToUpdate.language
  303. if (videoInfoToUpdate.nsfw !== undefined) videoInstance.nsfw = videoInfoToUpdate.nsfw
  304. if (videoInfoToUpdate.waitTranscoding !== undefined) videoInstance.waitTranscoding = videoInfoToUpdate.waitTranscoding
  305. if (videoInfoToUpdate.support !== undefined) videoInstance.support = videoInfoToUpdate.support
  306. if (videoInfoToUpdate.description !== undefined) videoInstance.description = videoInfoToUpdate.description
  307. if (videoInfoToUpdate.commentsEnabled !== undefined) videoInstance.commentsEnabled = videoInfoToUpdate.commentsEnabled
  308. if (videoInfoToUpdate.downloadEnabled !== undefined) videoInstance.downloadEnabled = videoInfoToUpdate.downloadEnabled
  309. if (videoInfoToUpdate.originallyPublishedAt !== undefined && videoInfoToUpdate.originallyPublishedAt !== null) {
  310. videoInstance.originallyPublishedAt = new Date(videoInfoToUpdate.originallyPublishedAt)
  311. }
  312. if (videoInfoToUpdate.privacy !== undefined) {
  313. const newPrivacy = parseInt(videoInfoToUpdate.privacy.toString(), 10)
  314. videoInstance.privacy = newPrivacy
  315. // The video was private, and is not anymore -> publish it
  316. if (wasPrivateVideo === true && newPrivacy !== VideoPrivacy.PRIVATE) {
  317. videoInstance.publishedAt = new Date()
  318. }
  319. // The video was not private, but now it is -> we need to unfederate it
  320. if (wasNotPrivateVideo === true && newPrivacy === VideoPrivacy.PRIVATE) {
  321. await VideoModel.sendDelete(videoInstance, { transaction: t })
  322. }
  323. }
  324. const videoInstanceUpdated = await videoInstance.save(sequelizeOptions) as MVideoFullLight
  325. if (thumbnailModel) await videoInstanceUpdated.addAndSaveThumbnail(thumbnailModel, t)
  326. if (previewModel) await videoInstanceUpdated.addAndSaveThumbnail(previewModel, t)
  327. // Video tags update?
  328. if (videoInfoToUpdate.tags !== undefined) {
  329. const tagInstances = await TagModel.findOrCreateTags(videoInfoToUpdate.tags, t)
  330. await videoInstanceUpdated.$set('Tags', tagInstances, sequelizeOptions)
  331. videoInstanceUpdated.Tags = tagInstances
  332. }
  333. // Video channel update?
  334. if (res.locals.videoChannel && videoInstanceUpdated.channelId !== res.locals.videoChannel.id) {
  335. await videoInstanceUpdated.$set('VideoChannel', res.locals.videoChannel, { transaction: t })
  336. videoInstanceUpdated.VideoChannel = res.locals.videoChannel
  337. if (wasPrivateVideo === false) await changeVideoChannelShare(videoInstanceUpdated, oldVideoChannel, t)
  338. }
  339. // Schedule an update in the future?
  340. if (videoInfoToUpdate.scheduleUpdate) {
  341. await ScheduleVideoUpdateModel.upsert({
  342. videoId: videoInstanceUpdated.id,
  343. updateAt: videoInfoToUpdate.scheduleUpdate.updateAt,
  344. privacy: videoInfoToUpdate.scheduleUpdate.privacy || null
  345. }, { transaction: t })
  346. } else if (videoInfoToUpdate.scheduleUpdate === null) {
  347. await ScheduleVideoUpdateModel.deleteByVideoId(videoInstanceUpdated.id, t)
  348. }
  349. await autoBlacklistVideoIfNeeded({
  350. video: videoInstanceUpdated,
  351. user: res.locals.oauth.token.User,
  352. isRemote: false,
  353. isNew: false,
  354. transaction: t
  355. })
  356. const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
  357. await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
  358. auditLogger.update(
  359. getAuditIdFromRes(res),
  360. new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
  361. oldVideoAuditView
  362. )
  363. logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
  364. return videoInstanceUpdated
  365. })
  366. if (wasUnlistedVideo || wasPrivateVideo) {
  367. Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated)
  368. }
  369. Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated })
  370. } catch (err) {
  371. // Force fields we want to update
  372. // If the transaction is retried, sequelize will think the object has not changed
  373. // So it will skip the SQL request, even if the last one was ROLLBACKed!
  374. resetSequelizeInstance(videoInstance, videoFieldsSave)
  375. throw err
  376. }
  377. return res.type('json').status(204).end()
  378. }
  379. async function getVideo (req: express.Request, res: express.Response) {
  380. // We need more attributes
  381. const userId: number = res.locals.oauth ? res.locals.oauth.token.User.id : null
  382. const video = await Hooks.wrapPromiseFun(
  383. VideoModel.loadForGetAPI,
  384. { id: res.locals.onlyVideoWithRights.id, userId },
  385. 'filter:api.video.get.result'
  386. )
  387. if (video.isOutdated()) {
  388. JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: video.url } })
  389. .catch(err => logger.error('Cannot create AP refresher job for video %s.', video.url, { err }))
  390. }
  391. return res.json(video.toFormattedDetailsJSON())
  392. }
  393. async function viewVideo (req: express.Request, res: express.Response) {
  394. const videoInstance = res.locals.videoAll
  395. const ip = req.ip
  396. const exists = await Redis.Instance.doesVideoIPViewExist(ip, videoInstance.uuid)
  397. if (exists) {
  398. logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid)
  399. return res.status(204).end()
  400. }
  401. await Promise.all([
  402. Redis.Instance.addVideoView(videoInstance.id),
  403. Redis.Instance.setIPVideoView(ip, videoInstance.uuid)
  404. ])
  405. const serverActor = await getServerActor()
  406. await sendView(serverActor, videoInstance, undefined)
  407. Hooks.runAction('action:api.video.viewed', { video: videoInstance, ip })
  408. return res.status(204).end()
  409. }
  410. async function getVideoDescription (req: express.Request, res: express.Response) {
  411. const videoInstance = res.locals.videoAll
  412. let description = ''
  413. if (videoInstance.isOwned()) {
  414. description = videoInstance.description
  415. } else {
  416. description = await fetchRemoteVideoDescription(videoInstance)
  417. }
  418. return res.json({ description })
  419. }
  420. async function listVideos (req: express.Request, res: express.Response) {
  421. const apiOptions = await Hooks.wrapObject({
  422. start: req.query.start,
  423. count: req.query.count,
  424. sort: req.query.sort,
  425. includeLocalVideos: true,
  426. categoryOneOf: req.query.categoryOneOf,
  427. licenceOneOf: req.query.licenceOneOf,
  428. languageOneOf: req.query.languageOneOf,
  429. tagsOneOf: req.query.tagsOneOf,
  430. tagsAllOf: req.query.tagsAllOf,
  431. nsfw: buildNSFWFilter(res, req.query.nsfw),
  432. filter: req.query.filter as VideoFilter,
  433. withFiles: false,
  434. user: res.locals.oauth ? res.locals.oauth.token.User : undefined
  435. }, 'filter:api.videos.list.params')
  436. const resultList = await Hooks.wrapPromiseFun(
  437. VideoModel.listForApi,
  438. apiOptions,
  439. 'filter:api.videos.list.result'
  440. )
  441. return res.json(getFormattedObjects(resultList.data, resultList.total))
  442. }
  443. async function removeVideo (req: express.Request, res: express.Response) {
  444. const videoInstance = res.locals.videoAll
  445. await sequelizeTypescript.transaction(async t => {
  446. await videoInstance.destroy({ transaction: t })
  447. })
  448. auditLogger.delete(getAuditIdFromRes(res), new VideoAuditView(videoInstance.toFormattedDetailsJSON()))
  449. logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid)
  450. Hooks.runAction('action:api.video.deleted', { video: videoInstance })
  451. return res.type('json').status(204).end()
  452. }