mirror of https://github.com/Chocobozzz/PeerTube
Fix feeds
parent
b3d5cb92b1
commit
f66db4d5c8
|
@ -255,7 +255,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
|
||||||
* Adding video items to the feed object, one at a time
|
* Adding video items to the feed object, one at a time
|
||||||
*/
|
*/
|
||||||
for (const video of videos) {
|
for (const video of videos) {
|
||||||
const formattedVideoFiles = video.getFormattedVideoFilesJSON()
|
const formattedVideoFiles = video.getFormattedVideoFilesJSON(false)
|
||||||
|
|
||||||
const torrents = formattedVideoFiles.map(videoFile => ({
|
const torrents = formattedVideoFiles.map(videoFile => ({
|
||||||
title: video.name,
|
title: video.name,
|
||||||
|
|
|
@ -188,9 +188,12 @@ function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) {
|
||||||
|
|
||||||
function videoFilesModelToFormattedJSON (
|
function videoFilesModelToFormattedJSON (
|
||||||
video: MVideoFormattableDetails,
|
video: MVideoFormattableDetails,
|
||||||
videoFiles: MVideoFileRedundanciesOpt[]
|
videoFiles: MVideoFileRedundanciesOpt[],
|
||||||
|
includeMagnet = true
|
||||||
): VideoFile[] {
|
): VideoFile[] {
|
||||||
const trackerUrls = video.getTrackerUrls()
|
const trackerUrls = includeMagnet
|
||||||
|
? video.getTrackerUrls()
|
||||||
|
: []
|
||||||
|
|
||||||
return [ ...videoFiles ]
|
return [ ...videoFiles ]
|
||||||
.filter(f => !f.isLive())
|
.filter(f => !f.isLive())
|
||||||
|
@ -202,8 +205,9 @@ function videoFilesModelToFormattedJSON (
|
||||||
label: videoFile.resolution + 'p'
|
label: videoFile.resolution + 'p'
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: deprecated in 3.2
|
magnetUri: includeMagnet
|
||||||
magnetUri: generateMagnetUri(video, videoFile, trackerUrls),
|
? generateMagnetUri(video, videoFile, trackerUrls)
|
||||||
|
: undefined,
|
||||||
|
|
||||||
size: videoFile.size,
|
size: videoFile.size,
|
||||||
fps: videoFile.fps,
|
fps: videoFile.fps,
|
||||||
|
|
|
@ -1904,16 +1904,16 @@ export class VideoModel extends Model {
|
||||||
return videoModelToFormattedDetailsJSON(this)
|
return videoModelToFormattedDetailsJSON(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormattedVideoFilesJSON (): VideoFile[] {
|
getFormattedVideoFilesJSON (includeMagnet = true): VideoFile[] {
|
||||||
let files: VideoFile[] = []
|
let files: VideoFile[] = []
|
||||||
|
|
||||||
if (Array.isArray(this.VideoFiles)) {
|
if (Array.isArray(this.VideoFiles)) {
|
||||||
const result = videoFilesModelToFormattedJSON(this, this.VideoFiles)
|
const result = videoFilesModelToFormattedJSON(this, this.VideoFiles, includeMagnet)
|
||||||
files = files.concat(result)
|
files = files.concat(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const p of (this.VideoStreamingPlaylists || [])) {
|
for (const p of (this.VideoStreamingPlaylists || [])) {
|
||||||
const result = videoFilesModelToFormattedJSON(this, p.VideoFiles)
|
const result = videoFilesModelToFormattedJSON(this, p.VideoFiles, includeMagnet)
|
||||||
files = files.concat(result)
|
files = files.concat(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,5 @@ export interface VideoFile {
|
||||||
metadata?: VideoFileMetadata
|
metadata?: VideoFileMetadata
|
||||||
metadataUrl?: string
|
metadataUrl?: string
|
||||||
|
|
||||||
// FIXME: deprecated in 3.2
|
magnetUri: string | null
|
||||||
magnetUri: string
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue