import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
import { APVideoUpdater } from './updater'
-const lTags = loggerTagsFactory('ap', 'video', 'refresh')
-
async function refreshVideoIfNeeded (options: {
video: MVideoThumbnail
fetchedType: VideoFetchByUrlType
? options.video as MVideoAccountLightBlacklistAllFiles
: await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
+ const lTags = loggerTagsFactory('ap', 'video', 'refresh', video.uuid, video.url)
+
try {
const { videoObject } = await fetchRemoteVideo(video.url)
if (videoObject === undefined) {
- logger.warn('Cannot refresh remote video %s: invalid body.', video.url, lTags(video.uuid))
+ logger.warn('Cannot refresh remote video %s: invalid body.', video.url, lTags())
await video.setAsRefreshed()
return video
return video
} catch (err) {
if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
- logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url, lTags(video.uuid))
+ logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url, lTags())
// Video does not exist anymore
await video.destroy()
return undefined
}
- logger.warn('Cannot refresh video %s.', options.video.url, { err, ...lTags(video.uuid) })
+ logger.warn('Cannot refresh video %s.', options.video.url, { err, ...lTags() })
ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId)
video,
type: ThumbnailType.MINIATURE
}).catch(err => {
- logger.warn('Cannot generate thumbnail of %s.', this.videoObject.id, { err, ...this.lTags(video.uuid) })
+ logger.warn('Cannot generate thumbnail of %s.', this.videoObject.id, { err, ...this.lTags() })
return undefined
})
-import { logger, loggerTagsFactory } from '@server/helpers/logger'
+import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger'
import { sequelizeTypescript } from '@server/initializers/database'
import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist'
import { VideoModel } from '@server/models/video/video'
import { getVideoAttributesFromObject } from './object-to-model-attributes'
export class APVideoCreator extends APVideoAbstractBuilder {
- protected lTags = loggerTagsFactory('ap', 'video', 'create')
+ protected lTags: LoggerTagsFn
constructor (protected readonly videoObject: VideoObject) {
super()
+
+ this.lTags = loggerTagsFactory('ap', 'video', 'create', this.videoObject.uuid, this.videoObject.id)
}
async create (waitThumbnail = false) {
- logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags(this.videoObject.uuid))
+ logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags())
const channelActor = await this.getOrCreateVideoChannelFromVideoObject()
const channel = channelActor.VideoChannel
transaction: t
})
- logger.info('Remote video with uuid %s inserted.', this.videoObject.uuid, this.lTags(videoCreated.uuid))
+ logger.info('Remote video with uuid %s inserted.', this.videoObject.uuid, this.lTags())
return { autoBlacklisted, videoCreated }
} catch (err) {
const cleaner = crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, type, crawlStartDate)
return crawlCollectionPage<string>(uri, handler, cleaner)
- .catch(err => logger.error('Cannot add rate of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) }))
+ .catch(err => logger.error('Cannot add rate of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
}
function syncShares (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) {
const cleaner = crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate)
return crawlCollectionPage<string>(uri, handler, cleaner)
- .catch(err => logger.error('Cannot add shares of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) }))
+ .catch(err => logger.error('Cannot add shares of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
}
function syncComments (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) {
const cleaner = crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate)
return crawlCollectionPage<string>(uri, handler, cleaner)
- .catch(err => logger.error('Cannot add comments of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) }))
+ .catch(err => logger.error('Cannot add comments of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
}
import { Transaction } from 'sequelize/types'
import { resetSequelizeInstance } from '@server/helpers/database-utils'
-import { logger, loggerTagsFactory } from '@server/helpers/logger'
+import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger'
import { sequelizeTypescript } from '@server/initializers/database'
import { Notifier } from '@server/lib/notifier'
import { PeerTubeSocket } from '@server/lib/peertube-socket'
private readonly oldVideoChannel: MChannelAccountLight
- protected lTags = loggerTagsFactory('ap', 'video', 'update')
+ protected lTags: LoggerTagsFn
constructor (
protected readonly videoObject: VideoObject,
this.oldVideoChannel = this.video.VideoChannel
this.videoFieldsSave = this.video.toJSON()
+
+ this.lTags = loggerTagsFactory('ap', 'video', 'update', video.uuid, video.url)
}
async update (overrideTo?: string[]) {
logger.debug(
'Updating remote video "%s".', this.videoObject.uuid,
- { videoObject: this.videoObject, ...this.lTags(this.videoObject.uuid) }
+ { videoObject: this.videoObject, ...this.lTags() }
)
try {
PeerTubeSocket.Instance.sendVideoViewsUpdate(videoUpdated)
}
- logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags(this.videoObject.uuid))
+ logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags())
return videoUpdated
} catch (err) {
}
// This is just a debug because we will retry the insert
- logger.debug('Cannot update the remote video.', { err, ...this.lTags(this.videoObject.uuid) })
+ logger.debug('Cannot update the remote video.', { err, ...this.lTags() })
throw err
}
}