From: Rigel Kent Date: Fri, 22 Jun 2018 14:29:01 +0000 (+0200) Subject: Fix #639 providing magnet URI in player and download modal X-Git-Tag: v1.0.0-beta.9~4 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=5511da6289e80f91daf5dcb3b632068c02a24ccb;hp=92d83c6a78e86c66a55958f8e36a7f2e123efdf8;p=github%2FChocobozzz%2FPeerTube.git Fix #639 providing magnet URI in player and download modal --- diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.html b/client/src/app/videos/+video-watch/modal/video-download.component.html index d30a49345..316bd635c 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.html +++ b/client/src/app/videos/+video-watch/modal/video-download.component.html @@ -24,6 +24,11 @@ + +
+ + +
diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.ts b/client/src/app/videos/+video-watch/modal/video-download.component.ts index 12f31b011..2de706e47 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-download.component.ts @@ -12,7 +12,7 @@ export class VideoDownloadComponent implements OnInit { @ViewChild('modal') modal: ModalDirective - downloadType: 'direct' | 'torrent' = 'torrent' + downloadType: 'direct' | 'torrent' | 'magnet' = 'torrent' resolutionId: number | string = -1 constructor () { @@ -41,7 +41,19 @@ export class VideoDownloadComponent implements OnInit { return } - const link = this.downloadType === 'direct' ? file.fileDownloadUrl : file.torrentDownloadUrl + const link = (() => { + switch (this.downloadType) { + case 'direct': { + return file.fileDownloadUrl + } + case 'torrent': { + return file.torrentDownloadUrl + } + case 'magnet': { + return file.magnetUri + } + } + })() window.location.assign(link) } } diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 6b8bba211..7c9a43ed9 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -143,6 +143,13 @@ function addContextMenu (player: any, videoEmbedUrl: string) { listener: () => { copyToClipboard(buildVideoEmbed(videoEmbedUrl)) } + }, + { + label: player.localize('Copy magnet URI'), + listener: function () { + const player = this + copyToClipboard(player.peertube().getCurrentVideoFile().magnetUri) + } } ] })