ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix #639 providing magnet URI in player and download modal
Rigel Kent5511da6289e8
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.htmlindex d30a49345d..316bd635cb 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 @@<input type="radio" name="download" id="download-direct" [(ngModel)]="downloadType" value="direct"><label i18n for="download-direct">Direct download</label></div>++ <div class="peertube-radio-container">+ <input type="radio" name="download" id="download-magnet" [(ngModel)]="downloadType" value="magnet">+ <label i18n for="download-magnet">Torrent (magnet)</label>+ </div></div><div class="form-group inputs">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.tsindex 12f31b011a..2de706e47a 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 = -1constructor () {@@ -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.tsindex 6b8bba2119..7c9a43ed97 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)+ }}]})