Move to peertube feed fork
This commit is contained in:
parent
21f2df5d3b
commit
4393b2552c
|
@ -79,6 +79,7 @@
|
|||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.23.0",
|
||||
"@babel/parser": "7.16.8",
|
||||
"@peertube/feed": "^5.0.0",
|
||||
"@peertube/http-signature": "^1.4.0",
|
||||
"@uploadx/core": "^5.0.0",
|
||||
"async": "^3.0.1",
|
||||
|
@ -129,7 +130,6 @@
|
|||
"parse-torrent": "^9.1.0",
|
||||
"password-generator": "^2.0.2",
|
||||
"pem": "^1.12.3",
|
||||
"pfeed": "1.1.11",
|
||||
"pg": "^8.2.1",
|
||||
"prompt": "^1.0.0",
|
||||
"proxy-addr": "^2.0.7",
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import express from 'express'
|
||||
import Feed from 'pfeed'
|
||||
import { Feed } from '@peertube/feed'
|
||||
import { extname } from 'path'
|
||||
import { mdToOneLinePlainText, toSafeHtml } from '@server/helpers/markdown'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
|
||||
import { VideoInclude } from '@shared/models'
|
||||
import { buildNSFWFilter } from '../helpers/express-utils'
|
||||
import { CONFIG } from '../initializers/config'
|
||||
import { FEEDS, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
|
||||
import { FEEDS, MIMETYPES, PREVIEWS_SIZE, ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
commonVideosFiltersValidator,
|
||||
|
@ -258,10 +259,7 @@ function initFeed (parameters: {
|
|||
})
|
||||
}
|
||||
|
||||
function addVideosToFeed (feed, videos: VideoModel[]) {
|
||||
/**
|
||||
* Adding video items to the feed object, one at a time
|
||||
*/
|
||||
function addVideosToFeed (feed: Feed, videos: VideoModel[]) {
|
||||
for (const video of videos) {
|
||||
const formattedVideoFiles = video.getFormattedVideoFilesJSON(false)
|
||||
|
||||
|
@ -273,9 +271,9 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
|
|||
|
||||
const videos = formattedVideoFiles.map(videoFile => {
|
||||
const result = {
|
||||
type: 'video/mp4',
|
||||
type: MIMETYPES.VIDEO.EXT_MIMETYPE[extname(videoFile.fileUrl)],
|
||||
medium: 'video',
|
||||
height: videoFile.resolution.label.replace('p', ''),
|
||||
height: videoFile.resolution.id,
|
||||
fileSize: videoFile.size,
|
||||
url: videoFile.fileUrl,
|
||||
framerate: videoFile.fps,
|
||||
|
@ -309,8 +307,18 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
|
|||
],
|
||||
date: video.publishedAt,
|
||||
nsfw: video.nsfw,
|
||||
torrent: torrents,
|
||||
torrents,
|
||||
|
||||
// Enclosure
|
||||
video: {
|
||||
url: videos[0].url,
|
||||
length: videos[0].fileSize,
|
||||
type: videos[0].type
|
||||
},
|
||||
|
||||
// Media RSS
|
||||
videos,
|
||||
|
||||
embed: {
|
||||
url: video.getEmbedStaticPath(),
|
||||
allowFullscreen: true
|
||||
|
@ -324,7 +332,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
|
|||
views: video.views
|
||||
}
|
||||
},
|
||||
thumbnail: [
|
||||
thumbnails: [
|
||||
{
|
||||
url: WEBSERVER.URL + video.getPreviewStaticPath(),
|
||||
height: PREVIEWS_SIZE.height,
|
||||
|
@ -335,7 +343,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
|
|||
}
|
||||
}
|
||||
|
||||
function sendFeed (feed, req: express.Request, res: express.Response) {
|
||||
function sendFeed (feed: Feed, req: express.Request, res: express.Response) {
|
||||
const format = req.params.format
|
||||
|
||||
if (format === 'atom' || format === 'atom1') {
|
||||
|
|
|
@ -156,9 +156,10 @@ describe('Test syndication feeds', () => {
|
|||
|
||||
const enclosure = xmlDoc.rss.channel.item[0].enclosure
|
||||
expect(enclosure).to.exist
|
||||
expect(enclosure['@_type']).to.equal('application/x-bittorrent')
|
||||
|
||||
expect(enclosure['@_type']).to.equal('video/webm')
|
||||
expect(enclosure['@_length']).to.equal(218910)
|
||||
expect(enclosure['@_url']).to.contain('720.torrent')
|
||||
expect(enclosure['@_url']).to.contain('-720.webm')
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -274,8 +275,8 @@ describe('Test syndication feeds', () => {
|
|||
|
||||
const jsonObj = JSON.parse(json)
|
||||
expect(jsonObj.items.length).to.be.equal(2)
|
||||
expect(jsonObj.items[0].html_content).to.contain('<p>super comment 2</p>')
|
||||
expect(jsonObj.items[1].html_content).to.contain('<p>super comment 1</p>')
|
||||
expect(jsonObj.items[0].content_html).to.contain('<p>super comment 2</p>')
|
||||
expect(jsonObj.items[1].content_html).to.contain('<p>super comment 1</p>')
|
||||
}
|
||||
})
|
||||
|
||||
|
|
29
yarn.lock
29
yarn.lock
|
@ -1449,6 +1449,13 @@
|
|||
"@nodelib/fs.scandir" "2.1.5"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@peertube/feed@^5.0.0":
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@peertube/feed/-/feed-5.0.0.tgz#f8cbc1e526a7af3112fca6d1859362b0bea13024"
|
||||
integrity sha512-YR78vHocVJsHWETz1US1+A4BZlu7Bykd0GuwCTdIQ1nfrfMXDBOiC/HM8+TYBqkp5oAqAbVyeVo6VxhpZzE3sw==
|
||||
dependencies:
|
||||
xml-js "^1.6.11"
|
||||
|
||||
"@peertube/http-signature@^1.4.0":
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@peertube/http-signature/-/http-signature-1.4.0.tgz#5d2bab08dfeca55490d926d145b3ec0cfb392d63"
|
||||
|
@ -5602,7 +5609,7 @@ lodash@4.17.19:
|
|||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
|
||||
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
|
||||
|
||||
lodash@>=4.17.13, lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21:
|
||||
lodash@>=4.17.13, lodash@^4.17.10, lodash@^4.17.20, lodash@^4.17.21:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
@ -6654,14 +6661,6 @@ pem@^1.12.3:
|
|||
os-tmpdir "^1.0.1"
|
||||
which "^2.0.2"
|
||||
|
||||
pfeed@1.1.11:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/pfeed/-/pfeed-1.1.11.tgz#a52f6b18aa01dfd3c8ff3c7189c456dc1b66d28f"
|
||||
integrity sha512-EheEV1A3xCQ61irXBvqy+V2vAEpeKjw7bTqH2Ck64LFMcGh9yOwncESreaWfUftRf6djRa0sXP6kkOnGWX/P7g==
|
||||
dependencies:
|
||||
lodash "^4.17.15"
|
||||
xml "^1.0.1"
|
||||
|
||||
pg-connection-string@^2.5.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.5.0.tgz#538cadd0f7e603fc09a12590f3b8a452c2c0cf34"
|
||||
|
@ -8776,6 +8775,13 @@ xhr@^2.0.1:
|
|||
parse-headers "^2.0.0"
|
||||
xtend "^4.0.0"
|
||||
|
||||
xml-js@^1.6.11:
|
||||
version "1.6.11"
|
||||
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9"
|
||||
integrity sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==
|
||||
dependencies:
|
||||
sax "^1.2.4"
|
||||
|
||||
xml-parse-from-string@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz#a9029e929d3dbcded169f3c6e28238d95a5d5a28"
|
||||
|
@ -8789,11 +8795,6 @@ xml2js@^0.4.23, xml2js@^0.4.5:
|
|||
sax ">=0.6.0"
|
||||
xmlbuilder "~11.0.0"
|
||||
|
||||
xml@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
|
||||
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
|
||||
|
||||
xmlbuilder@~11.0.0:
|
||||
version "11.0.1"
|
||||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
|
||||
|
|
Loading…
Reference in New Issue