Avoid error when file has no torrent file
This commit is contained in:
parent
3dc8a86c80
commit
c4d125527a
|
@ -402,6 +402,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
|
||||||
return VideoFileModel.destroy(options)
|
return VideoFileModel.destroy(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasTorrent () {
|
||||||
|
return this.infoHash && this.torrentFilename
|
||||||
|
}
|
||||||
|
|
||||||
getVideoOrStreamingPlaylist (this: MVideoFileVideo | MVideoFileStreamingPlaylistVideo): MVideo | MStreamingPlaylistVideo {
|
getVideoOrStreamingPlaylist (this: MVideoFileVideo | MVideoFileStreamingPlaylistVideo): MVideo | MStreamingPlaylistVideo {
|
||||||
if (this.videoId) return (this as MVideoFileVideo).Video
|
if (this.videoId) return (this as MVideoFileVideo).Video
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ function videoFilesModelToFormattedJSON (
|
||||||
label: videoFile.resolution + 'p'
|
label: videoFile.resolution + 'p'
|
||||||
},
|
},
|
||||||
|
|
||||||
magnetUri: includeMagnet && videoFile.torrentFilename
|
magnetUri: includeMagnet && videoFile.hasTorrent()
|
||||||
? generateMagnetUri(video, videoFile, trackerUrls)
|
? generateMagnetUri(video, videoFile, trackerUrls)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|
||||||
|
@ -253,19 +253,21 @@ function addVideoFilesInAPAcc (
|
||||||
fps: file.fps
|
fps: file.fps
|
||||||
})
|
})
|
||||||
|
|
||||||
acc.push({
|
if (file.hasTorrent()) {
|
||||||
type: 'Link',
|
acc.push({
|
||||||
mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
|
type: 'Link',
|
||||||
href: file.getTorrentUrl(),
|
mediaType: 'application/x-bittorrent' as 'application/x-bittorrent',
|
||||||
height: file.resolution
|
href: file.getTorrentUrl(),
|
||||||
})
|
height: file.resolution
|
||||||
|
})
|
||||||
|
|
||||||
acc.push({
|
acc.push({
|
||||||
type: 'Link',
|
type: 'Link',
|
||||||
mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
|
mediaType: 'application/x-bittorrent;x-scheme-handler/magnet' as 'application/x-bittorrent;x-scheme-handler/magnet',
|
||||||
href: generateMagnetUri(video, file, trackerUrls),
|
href: generateMagnetUri(video, file, trackerUrls),
|
||||||
height: file.resolution
|
height: file.resolution
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue