import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
import { getServerActor } from '@server/models/application/application'
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
-import { VideoCreate, VideoState, VideoUpdate } from '../../../../shared'
+import { VideoCreate, VideosCommonQuery, VideoState, VideoUpdate } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
-import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils'
import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils'
import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
-import { logger } from '../../../helpers/logger'
+import { logger, loggerTagsFactory } from '../../../helpers/logger'
import { getFormattedObjects } from '../../../helpers/utils'
import { CONFIG } from '../../../initializers/config'
import {
import { rateVideoRouter } from './rate'
import { watchingRouter } from './watching'
+const lTags = loggerTagsFactory('api', 'video')
const auditLogger = auditLoggerFactory('videos')
const videosRouter = express.Router()
}, { transaction: t })
}
+ // Channel has a new content, set as updated
+ await videoCreated.VideoChannel.setAsUpdated(t)
+
await autoBlacklistVideoIfNeeded({
video,
user: res.locals.oauth.token.User,
})
auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
- logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
+ logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid, lTags(videoCreated.uuid))
return { videoCreated }
})
// Create the torrent file in async way because it could be long
createTorrentAndSetInfoHashAsync(video, videoFile)
- .catch(err => logger.error('Cannot create torrent file for video %s', video.url, { err }))
+ .catch(err => logger.error('Cannot create torrent file for video %s', video.url, { err, ...lTags(video.uuid) }))
.then(() => VideoModel.loadAndPopulateAccountAndServerAndTags(video.id))
.then(refreshedVideo => {
if (!refreshedVideo) return
return sequelizeTypescript.transaction(t => federateVideoIfNeeded(refreshedVideo, true, t))
})
})
- .catch(err => logger.error('Cannot federate or notify video creation %s', video.url, { err }))
+ .catch(err => logger.error('Cannot federate or notify video creation %s', video.url, { err, ...lTags(video.uuid) }))
if (video.state === VideoState.TO_TRANSCODE) {
await addOptimizeOrMergeAudioJob(videoCreated, videoFile, res.locals.oauth.token.User)
new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
oldVideoAuditView
)
- logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
+ logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid, lTags(videoInstance.uuid))
return videoInstanceUpdated
})
}
async function listVideos (req: express.Request, res: express.Response) {
+ const query = req.query as VideosCommonQuery
const countVideos = getCountVideos(req)
const apiOptions = await Hooks.wrapObject({
- start: req.query.start,
- count: req.query.count,
- sort: req.query.sort,
+ start: query.start,
+ count: query.count,
+ sort: query.sort,
includeLocalVideos: true,
- categoryOneOf: req.query.categoryOneOf,
- licenceOneOf: req.query.licenceOneOf,
- languageOneOf: req.query.languageOneOf,
- tagsOneOf: req.query.tagsOneOf,
- tagsAllOf: req.query.tagsAllOf,
- nsfw: buildNSFWFilter(res, req.query.nsfw),
- filter: req.query.filter as VideoFilter,
+ categoryOneOf: query.categoryOneOf,
+ licenceOneOf: query.licenceOneOf,
+ languageOneOf: query.languageOneOf,
+ tagsOneOf: query.tagsOneOf,
+ tagsAllOf: query.tagsAllOf,
+ nsfw: buildNSFWFilter(res, query.nsfw),
+ isLive: query.isLive,
+ filter: query.filter,
withFiles: false,
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
countVideos