2021-06-24 15:18:54 +02:00
|
|
|
import { logger } from '../../helpers/logger'
|
|
|
|
import { CONFIG } from '../../initializers/constants'
|
|
|
|
import { DBVideo, IndexableVideo } from '../../types/video.model'
|
2021-07-28 13:25:39 +02:00
|
|
|
import { buildVideosMapping, formatVideoForDB } from '../elastic-search/elastic-search-videos'
|
2021-06-24 15:18:54 +02:00
|
|
|
import { getVideo } from '../requests/peertube-instance'
|
|
|
|
import { AbstractIndexer } from './shared'
|
|
|
|
|
|
|
|
export class VideoIndexer extends AbstractIndexer <IndexableVideo, DBVideo> {
|
|
|
|
|
|
|
|
constructor () {
|
|
|
|
super(CONFIG.ELASTIC_SEARCH.INDEXES.VIDEOS, formatVideoForDB)
|
|
|
|
}
|
|
|
|
|
|
|
|
async indexSpecificElement (host: string, uuid: string) {
|
|
|
|
const video = await getVideo(host, uuid)
|
|
|
|
|
|
|
|
logger.info('Indexing specific video %s of %s.', uuid, host)
|
|
|
|
|
|
|
|
return this.indexElements([ video ], true)
|
|
|
|
}
|
2021-07-28 13:25:39 +02:00
|
|
|
|
|
|
|
buildMapping () {
|
|
|
|
return buildVideosMapping()
|
|
|
|
}
|
2021-06-24 15:18:54 +02:00
|
|
|
}
|