diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-04 18:00:51 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-02-07 09:38:24 +0100 |
commit | 4393b2552c4ecb9fe43ff78480da0826c04709c0 (patch) | |
tree | 3449819109ee3635e59172e50eb2d500a2f2bdfb /server/controllers | |
parent | 21f2df5d3b3b5c3cf50884845de246e7b22f60e9 (diff) | |
download | PeerTube-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.ts | 30 |
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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import Feed from 'pfeed' | 2 | import { Feed } from '@peertube/feed' |
3 | import { extname } from 'path' | ||
3 | import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' | 4 | import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown' |
4 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
5 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' | 6 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' |
6 | import { VideoInclude } from '@shared/models' | 7 | import { VideoInclude } from '@shared/models' |
7 | import { buildNSFWFilter } from '../helpers/express-utils' | 8 | import { buildNSFWFilter } from '../helpers/express-utils' |
8 | import { CONFIG } from '../initializers/config' | 9 | import { CONFIG } from '../initializers/config' |
9 | import { FEEDS, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' | 10 | import { FEEDS, MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' |
10 | import { | 11 | import { |
11 | asyncMiddleware, | 12 | asyncMiddleware, |
12 | commonVideosFiltersValidator, | 13 | commonVideosFiltersValidator, |
@@ -258,10 +259,7 @@ function initFeed (parameters: { | |||
258 | }) | 259 | }) |
259 | } | 260 | } |
260 | 261 | ||
261 | function addVideosToFeed (feed, videos: VideoModel[]) { | 262 | function 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 | ||
338 | function sendFeed (feed, req: express.Request, res: express.Response) { | 346 | function 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') { |