diff options
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 @@ | |||
24 | <input type="radio" name="download" id="download-direct" [(ngModel)]="downloadType" value="direct"> | 24 | <input type="radio" name="download" id="download-direct" [(ngModel)]="downloadType" value="direct"> |
25 | <label i18n for="download-direct">Direct download</label> | 25 | <label i18n for="download-direct">Direct download</label> |
26 | </div> | 26 | </div> |
27 | |||
28 | <div class="peertube-radio-container"> | ||
29 | <input type="radio" name="download" id="download-magnet" [(ngModel)]="downloadType" value="magnet"> | ||
30 | <label i18n for="download-magnet">Torrent (magnet)</label> | ||
31 | </div> | ||
27 | </div> | 32 | </div> |
28 | 33 | ||
29 | <div class="form-group inputs"> | 34 | <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.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 { | |||
12 | 12 | ||
13 | @ViewChild('modal') modal: ModalDirective | 13 | @ViewChild('modal') modal: ModalDirective |
14 | 14 | ||
15 | downloadType: 'direct' | 'torrent' = 'torrent' | 15 | downloadType: 'direct' | 'torrent' | 'magnet' = 'torrent' |
16 | resolutionId: number | string = -1 | 16 | resolutionId: number | string = -1 |
17 | 17 | ||
18 | constructor () { | 18 | constructor () { |
@@ -41,7 +41,19 @@ export class VideoDownloadComponent implements OnInit { | |||
41 | return | 41 | return |
42 | } | 42 | } |
43 | 43 | ||
44 | const link = this.downloadType === 'direct' ? file.fileDownloadUrl : file.torrentDownloadUrl | 44 | const link = (() => { |
45 | switch (this.downloadType) { | ||
46 | case 'direct': { | ||
47 | return file.fileDownloadUrl | ||
48 | } | ||
49 | case 'torrent': { | ||
50 | return file.torrentDownloadUrl | ||
51 | } | ||
52 | case 'magnet': { | ||
53 | return file.magnetUri | ||
54 | } | ||
55 | } | ||
56 | })() | ||
45 | window.location.assign(link) | 57 | window.location.assign(link) |
46 | } | 58 | } |
47 | } | 59 | } |
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) { | |||
143 | listener: () => { | 143 | listener: () => { |
144 | copyToClipboard(buildVideoEmbed(videoEmbedUrl)) | 144 | copyToClipboard(buildVideoEmbed(videoEmbedUrl)) |
145 | } | 145 | } |
146 | }, | ||
147 | { | ||
148 | label: player.localize('Copy magnet URI'), | ||
149 | listener: function () { | ||
150 | const player = this | ||
151 | copyToClipboard(player.peertube().getCurrentVideoFile().magnetUri) | ||
152 | } | ||
146 | } | 153 | } |
147 | ] | 154 | ] |
148 | }) | 155 | }) |