]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-format-utils.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / video / video-format-utils.ts
index a6a1a4f0d864bde3f87b1b58ba4b56df90f9b8eb..551cb2842aa6883ae69f02506c802c843b63e9ec 100644 (file)
@@ -205,7 +205,7 @@ function videoFilesModelToFormattedJSON (
           label: videoFile.resolution + 'p'
         },
 
-        magnetUri: includeMagnet
+        magnetUri: includeMagnet && videoFile.hasTorrent()
           ? generateMagnetUri(video, videoFile, trackerUrls)
           : undefined,
 
@@ -253,19 +253,21 @@ function addVideoFilesInAPAcc (
       fps: file.fps
     })
 
-    acc.push({
-      type: 'Link',
-      mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
-      href: file.getTorrentUrl(),
-      height: file.resolution
-    })
-
-    acc.push({
-      type: 'Link',
-      mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
-      href: generateMagnetUri(video, file, trackerUrls),
-      height: file.resolution
-    })
+    if (file.hasTorrent()) {
+      acc.push({
+        type: 'Link',
+        mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
+        href: file.getTorrentUrl(),
+        height: file.resolution
+      })
+
+      acc.push({
+        type: 'Link',
+        mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
+        href: generateMagnetUri(video, file, trackerUrls),
+        height: file.resolution
+      })
+    }
   }
 }