aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-02-04 18:00:51 +0100
committerChocobozzz <me@florianbigard.com>2022-02-07 09:38:24 +0100
commit4393b2552c4ecb9fe43ff78480da0826c04709c0 (patch)
tree3449819109ee3635e59172e50eb2d500a2f2bdfb /server/controllers
parent21f2df5d3b3b5c3cf50884845de246e7b22f60e9 (diff)
downloadPeerTube-4393b2552c4ecb9fe43ff78480da0826c04709c0.tar.gz
PeerTube-4393b2552c4ecb9fe43ff78480da0826c04709c0.tar.zst
PeerTube-4393b2552c4ecb9fe43ff78480da0826c04709c0.zip
Move to peertube feed fork
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/feeds.ts30
1 files changed, 19 insertions, 11 deletions
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index e6cdaf94b..90faaf024 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -1,12 +1,13 @@
1import express from 'express' 1import express from 'express'
2import Feed from 'pfeed' 2import { Feed } from '@peertube/feed'
3import { extname } from 'path'
3import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' 4import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown'
4import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
5import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' 6import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
6import { VideoInclude } from '@shared/models' 7import { VideoInclude } from '@shared/models'
7import { buildNSFWFilter } from '../helpers/express-utils' 8import { buildNSFWFilter } from '../helpers/express-utils'
8import { CONFIG } from '../initializers/config' 9import { CONFIG } from '../initializers/config'
9import { FEEDS, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 10import { FEEDS, MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
10import { 11import {
11 asyncMiddleware, 12 asyncMiddleware,
12 commonVideosFiltersValidator, 13 commonVideosFiltersValidator,
@@ -258,10 +259,7 @@ function initFeed (parameters: {
258 }) 259 })
259} 260}
260 261
261function addVideosToFeed (feed, videos: VideoModel[]) { 262function addVideosToFeed (feed: Feed, videos: VideoModel[]) {
262 /**
263 * Adding video items to the feed object, one at a time
264 */
265 for (const video of videos) { 263 for (const video of videos) {
266 const formattedVideoFiles = video.getFormattedVideoFilesJSON(false) 264 const formattedVideoFiles = video.getFormattedVideoFilesJSON(false)
267 265
@@ -273,9 +271,9 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
273 271
274 const videos = formattedVideoFiles.map(videoFile => { 272 const videos = formattedVideoFiles.map(videoFile => {
275 const result = { 273 const result = {
276 type: 'video/mp4', 274 type: MIMETYPES.VIDEO.EXT_MIMETYPE[extname(videoFile.fileUrl)],
277 medium: 'video', 275 medium: 'video',
278 height: videoFile.resolution.label.replace('p', ''), 276 height: videoFile.resolution.id,
279 fileSize: videoFile.size, 277 fileSize: videoFile.size,
280 url: videoFile.fileUrl, 278 url: videoFile.fileUrl,
281 framerate: videoFile.fps, 279 framerate: videoFile.fps,
@@ -309,8 +307,18 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
309 ], 307 ],
310 date: video.publishedAt, 308 date: video.publishedAt,
311 nsfw: video.nsfw, 309 nsfw: video.nsfw,
312 torrent: torrents, 310 torrents,
311
312 // Enclosure
313 video: {
314 url: videos[0].url,
315 length: videos[0].fileSize,
316 type: videos[0].type
317 },
318
319 // Media RSS
313 videos, 320 videos,
321
314 embed: { 322 embed: {
315 url: video.getEmbedStaticPath(), 323 url: video.getEmbedStaticPath(),
316 allowFullscreen: true 324 allowFullscreen: true
@@ -324,7 +332,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
324 views: video.views 332 views: video.views
325 } 333 }
326 }, 334 },
327 thumbnail: [ 335 thumbnails: [
328 { 336 {
329 url: WEBSERVER.URL + video.getPreviewStaticPath(), 337 url: WEBSERVER.URL + video.getPreviewStaticPath(),
330 height: PREVIEWS_SIZE.height, 338 height: PREVIEWS_SIZE.height,
@@ -335,7 +343,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
335 } 343 }
336} 344}
337 345
338function sendFeed (feed, req: express.Request, res: express.Response) { 346function sendFeed (feed: Feed, req: express.Request, res: express.Response) {
339 const format = req.params.format 347 const format = req.params.format
340 348
341 if (format === 'atom' || format === 'atom1') { 349 if (format === 'atom' || format === 'atom1') {