]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix feeds
authorChocobozzz <me@florianbigard.com>
Thu, 18 Feb 2021 10:22:35 +0000 (11:22 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Thu, 18 Feb 2021 12:38:09 +0000 (13:38 +0100)
server/controllers/feeds.ts
server/models/video/video-format-utils.ts
server/models/video/video.ts
shared/models/videos/video-file.model.ts

index 2182b42f56976df03a019749e09869f817bd2e3c..e29a8fe1db9ee28efd7900935e6a7ac8d14c7943 100644 (file)
@@ -255,7 +255,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
    * Adding video items to the feed object, one at a time
    */
   for (const video of videos) {
-    const formattedVideoFiles = video.getFormattedVideoFilesJSON()
+    const formattedVideoFiles = video.getFormattedVideoFilesJSON(false)
 
     const torrents = formattedVideoFiles.map(videoFile => ({
       title: video.name,
index 9dc3e772273916d38686f5644dcd35871a61e06b..455597d22e1ffad314802047ce42805d5817f80e 100644 (file)
@@ -188,9 +188,12 @@ function sortByResolutionDesc (fileA: MVideoFile, fileB: MVideoFile) {
 
 function videoFilesModelToFormattedJSON (
   video: MVideoFormattableDetails,
-  videoFiles: MVideoFileRedundanciesOpt[]
+  videoFiles: MVideoFileRedundanciesOpt[],
+  includeMagnet = true
 ): VideoFile[] {
-  const trackerUrls = video.getTrackerUrls()
+  const trackerUrls = includeMagnet
+    ? video.getTrackerUrls()
+    : []
 
   return [ ...videoFiles ]
     .filter(f => !f.isLive())
@@ -202,8 +205,9 @@ function videoFilesModelToFormattedJSON (
           label: videoFile.resolution + 'p'
         },
 
-        // FIXME: deprecated in 3.2
-        magnetUri: generateMagnetUri(video, videoFile, trackerUrls),
+        magnetUri: includeMagnet
+          ? generateMagnetUri(video, videoFile, trackerUrls)
+          : undefined,
 
         size: videoFile.size,
         fps: videoFile.fps,
index 9e67ca0f4d55a2174b6d57fd44a586f5ff8ba39c..48d4ba47a4dc6cfb0f90188298195e351dc73c9c 100644 (file)
@@ -1904,16 +1904,16 @@ export class VideoModel extends Model {
     return videoModelToFormattedDetailsJSON(this)
   }
 
-  getFormattedVideoFilesJSON (): VideoFile[] {
+  getFormattedVideoFilesJSON (includeMagnet = true): VideoFile[] {
     let files: VideoFile[] = []
 
     if (Array.isArray(this.VideoFiles)) {
-      const result = videoFilesModelToFormattedJSON(this, this.VideoFiles)
+      const result = videoFilesModelToFormattedJSON(this, this.VideoFiles, includeMagnet)
       files = files.concat(result)
     }
 
     for (const p of (this.VideoStreamingPlaylists || [])) {
-      const result = videoFilesModelToFormattedJSON(this, p.VideoFiles)
+      const result = videoFilesModelToFormattedJSON(this, p.VideoFiles, includeMagnet)
       files = files.concat(result)
     }
 
index f3d93f0eddf7a60748d8b049a436b6984ed033c3..1e830b19c865ee6f1ffaa008f37cbe48b000c41b 100644 (file)
@@ -17,6 +17,5 @@ export interface VideoFile {
   metadata?: VideoFileMetadata
   metadataUrl?: string
 
-  // FIXME: deprecated in 3.2
-  magnetUri: string
+  magnetUri: string | null
 }