1
0
Fork 0

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
resultList.data.forEach(video => {
const formattedVideoFiles = video.getFormattedVideoFilesJSON()
const torrents = formattedVideoFiles.map(videoFile => ({
title: video.name,
url: videoFile.torrentUrl,
size_in_bytes: videoFile.size
}))
const videos = formattedVideoFiles.map(videoFile => (Object.assign({
type: 'video/mp4',
medium: 'video',
height: videoFile.resolution.label.replace('p', ''),
fileSize: videoFile.size,
url: videoFile.fileUrl,
framerate: videoFile.fps,
duration: video.duration
}, video.language ? {
lang: video.language
} : {})))
const videos = formattedVideoFiles.map(videoFile => {
const result = {
type: 'video/mp4',
medium: 'video',
height: videoFile.resolution.label.replace('p', ''),
fileSize: videoFile.size,
url: videoFile.fileUrl,
framerate: videoFile.fps,
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({
title: video.name,
@ -153,10 +167,7 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
player: {
url: video.getWatchStaticPath()
},
categories: [video.category ? {
value: video.category,
label: VideoModel.getCategoryLabel(video.category)
} : null].filter(Boolean),
categories,
community: {
statistics: {
views: video.views