From 5511da6289e80f91daf5dcb3b632068c02a24ccb Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Fri, 22 Jun 2018 16:29:01 +0200 Subject: [PATCH] Fix #639 providing magnet URI in player and download modal --- .../modal/video-download.component.html | 5 +++++ .../modal/video-download.component.ts | 16 ++++++++++++++-- client/src/assets/player/peertube-player.ts | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) 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) + } } ] })