]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/feeds.ts
miniature duration visibility and overlay background opacity
[github/Chocobozzz/PeerTube.git] / server / controllers / feeds.ts
index 24c41d946cab111c54a75fcc6816c9ba18b19379..6b64ff22720be688d1132b604bab92a71a168ad8 100644 (file)
@@ -1,6 +1,5 @@
 import * as express from 'express'
-import { FEEDS, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
-import { THUMBNAILS_SIZE } from '../initializers'
+import { FEEDS, ROUTE_CACHE_LIFETIME, THUMBNAILS_SIZE, WEBSERVER } from '../initializers/constants'
 import {
   asyncMiddleware,
   commonVideosFiltersValidator,
@@ -44,7 +43,7 @@ export {
 async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
   const start = 0
 
-  const video = res.locals.video
+  const video = res.locals.videoAll
   const videoId: number = video ? video.id : undefined
 
   const comments = await VideoCommentModel.listForFeed(start, FEEDS.COUNT, videoId)
@@ -119,6 +118,17 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
       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
+    } : {})))
 
     feed.addItem({
       title: video.name,
@@ -133,12 +143,28 @@ async function generateVideoFeed (req: express.Request, res: express.Response) {
         }
       ],
       date: video.publishedAt,
-      language: video.language,
       nsfw: video.nsfw,
       torrent: torrents,
+      videos,
+      embed: {
+        url: video.getEmbedStaticPath(),
+        allowFullscreen: true
+      },
+      player: {
+        url: video.getWatchStaticPath()
+      },
+      categories: [video.category ? {
+        value: video.category,
+        label: VideoModel.getCategoryLabel(video.category)
+      } : null].filter(Boolean),
+      community: {
+        statistics: {
+          views: video.views
+        }
+      },
       thumbnail: [
         {
-          url: WEBSERVER.URL + video.getThumbnailStaticPath(),
+          url: WEBSERVER.URL + video.getMiniatureStaticPath(),
           height: THUMBNAILS_SIZE.height,
           width: THUMBNAILS_SIZE.width
         }