aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/index.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index eb46ea01f..9b19c394d 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { extname } from 'path' 2import { extname } from 'path'
3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' 3import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared'
4import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 4import { getVideoFileFPS, getVideoFileResolution, getMetadataFromFile } from '../../../helpers/ffmpeg-utils'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 6import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
7import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 7import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
@@ -37,7 +37,8 @@ import {
37 videosGetValidator, 37 videosGetValidator,
38 videosRemoveValidator, 38 videosRemoveValidator,
39 videosSortValidator, 39 videosSortValidator,
40 videosUpdateValidator 40 videosUpdateValidator,
41 videoFileMetadataGetValidator
41} from '../../../middlewares' 42} from '../../../middlewares'
42import { TagModel } from '../../../models/video/tag' 43import { TagModel } from '../../../models/video/tag'
43import { VideoModel } from '../../../models/video/video' 44import { VideoModel } from '../../../models/video/video'
@@ -66,6 +67,7 @@ import { Hooks } from '../../../lib/plugins/hooks'
66import { MVideoDetails, MVideoFullLight } from '@server/typings/models' 67import { MVideoDetails, MVideoFullLight } from '@server/typings/models'
67import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 68import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
68import { getVideoFilePath } from '@server/lib/video-paths' 69import { getVideoFilePath } from '@server/lib/video-paths'
70import toInt from 'validator/lib/toInt'
69 71
70const auditLogger = auditLoggerFactory('videos') 72const auditLogger = auditLoggerFactory('videos')
71const videosRouter = express.Router() 73const videosRouter = express.Router()
@@ -128,6 +130,10 @@ videosRouter.get('/:id/description',
128 asyncMiddleware(videosGetValidator), 130 asyncMiddleware(videosGetValidator),
129 asyncMiddleware(getVideoDescription) 131 asyncMiddleware(getVideoDescription)
130) 132)
133videosRouter.get('/:id/metadata/:videoFileId',
134 asyncMiddleware(videoFileMetadataGetValidator),
135 asyncMiddleware(getVideoFileMetadata)
136)
131videosRouter.get('/:id', 137videosRouter.get('/:id',
132 optionalAuthenticate, 138 optionalAuthenticate,
133 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), 139 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
@@ -206,7 +212,8 @@ async function addVideo (req: express.Request, res: express.Response) {
206 const videoFile = new VideoFileModel({ 212 const videoFile = new VideoFileModel({
207 extname: extname(videoPhysicalFile.filename), 213 extname: extname(videoPhysicalFile.filename),
208 size: videoPhysicalFile.size, 214 size: videoPhysicalFile.size,
209 videoStreamingPlaylistId: null 215 videoStreamingPlaylistId: null,
216 metadata: await getMetadataFromFile<any>(videoPhysicalFile.path)
210 }) 217 })
211 218
212 if (videoFile.isAudio()) { 219 if (videoFile.isAudio()) {
@@ -493,6 +500,11 @@ async function getVideoDescription (req: express.Request, res: express.Response)
493 return res.json({ description }) 500 return res.json({ description })
494} 501}
495 502
503async function getVideoFileMetadata (req: express.Request, res: express.Response) {
504 const videoFile = await VideoFileModel.loadWithMetadata(toInt(req.params.videoFileId))
505 return res.json(videoFile.metadata)
506}
507
496async function listVideos (req: express.Request, res: express.Response) { 508async function listVideos (req: express.Request, res: express.Response) {
497 const countVideos = getCountVideos(req) 509 const countVideos = getCountVideos(req)
498 510