Clearer feed controller

This commit is contained in:
Chocobozzz 2019-12-09 09:40:16 +01:00
parent 7fc441cc4e
commit c4b4ab719c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 26 additions and 15 deletions

View File

@ -113,22 +113,36 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
// Adding video items to the feed, one at a time // Adding video items to the feed, one at a time
resultList.data.forEach(video => { resultList.data.forEach(video => {
const formattedVideoFiles = video.getFormattedVideoFilesJSON() const formattedVideoFiles = video.getFormattedVideoFilesJSON()
const torrents = formattedVideoFiles.map(videoFile => ({ const torrents = formattedVideoFiles.map(videoFile => ({
title: video.name, title: video.name,
url: videoFile.torrentUrl, url: videoFile.torrentUrl,
size_in_bytes: videoFile.size size_in_bytes: videoFile.size
})) }))
const videos = formattedVideoFiles.map(videoFile => (Object.assign({
type: 'video/mp4', const videos = formattedVideoFiles.map(videoFile => {
medium: 'video', const result = {
height: videoFile.resolution.label.replace('p', ''), type: 'video/mp4',
fileSize: videoFile.size, medium: 'video',
url: videoFile.fileUrl, height: videoFile.resolution.label.replace('p', ''),
framerate: videoFile.fps, fileSize: videoFile.size,
duration: video.duration url: videoFile.fileUrl,
}, video.language ? { framerate: videoFile.fps,
lang: video.language duration: video.duration
} : {}))) }
if (video.language) Object.assign(result, { lang: video.language })
return result
})
const categories: { value: number, label: string }[] = []
if (video.category) {
categories.push({
value: video.category,
label: VideoModel.getCategoryLabel(video.category)
})
}
feed.addItem({ feed.addItem({
title: video.name, title: video.name,
@ -153,10 +167,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
player: { player: {
url: video.getWatchStaticPath() url: video.getWatchStaticPath()
}, },
categories: [video.category ? { categories,
value: video.category,
label: VideoModel.getCategoryLabel(video.category)
} : null].filter(Boolean),
community: { community: {
statistics: { statistics: {
views: video.views views: video.views