aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-format-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-25 11:30:00 +0200
committerChocobozzz <me@florianbigard.com>2021-05-25 11:35:29 +0200
commitc4d125527a433db9ba536bf3bb8ef19569a85a73 (patch)
treea05d388e047d3088eb037489919b64dd497981ac /server/models/video/video-format-utils.ts
parent3dc8a86c80a6d2fbcf4c7c02a31c1c60c8e6b598 (diff)
downloadPeerTube-c4d125527a433db9ba536bf3bb8ef19569a85a73.tar.gz
PeerTube-c4d125527a433db9ba536bf3bb8ef19569a85a73.tar.zst
PeerTube-c4d125527a433db9ba536bf3bb8ef19569a85a73.zip
Avoid error when file has no torrent file
Diffstat (limited to 'server/models/video/video-format-utils.ts')
-rw-r--r--server/models/video/video-format-utils.ts30
1 files changed, 16 insertions, 14 deletions
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index bcba90093..551cb2842 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -205,7 +205,7 @@ function videoFilesModelToFormattedJSON (
205 label: videoFile.resolution + 'p' 205 label: videoFile.resolution + 'p'
206 }, 206 },
207 207
208 magnetUri: includeMagnet && videoFile.torrentFilename 208 magnetUri: includeMagnet && videoFile.hasTorrent()
209 ? generateMagnetUri(video, videoFile, trackerUrls) 209 ? generateMagnetUri(video, videoFile, trackerUrls)
210 : undefined, 210 : undefined,
211 211
@@ -253,19 +253,21 @@ function addVideoFilesInAPAcc (
253 fps: file.fps 253 fps: file.fps
254 }) 254 })
255 255
256 acc.push({ 256 if (file.hasTorrent()) {
257 type: 'Link', 257 acc.push({
258 mediaType: 'application/x-bittorrent' as 'application/x-bittorrent', 258 type: 'Link',
259 href: file.getTorrentUrl(), 259 mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
260 height: file.resolution 260 href: file.getTorrentUrl(),
261 }) 261 height: file.resolution
262 262 })
263 acc.push({ 263
264 type: 'Link', 264 acc.push({
265 mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet', 265 type: 'Link',
266 href: generateMagnetUri(video, file, trackerUrls), 266 mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
267 height: file.resolution 267 href: generateMagnetUri(video, file, trackerUrls),
268 }) 268 height: file.resolution
269 })
270 }
269 } 271 }
270} 272}
271 273