diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 14:58:28 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 14:58:28 +0200 |
commit | a96aed15188174c50885dda0df3164a67295e11f (patch) | |
tree | 7e3941324614e52a2f6ab7755224ab8ae8f8c19f /client | |
parent | bda65bdc9f3ce7d4b6e97cb9afaca25b71added3 (diff) | |
download | PeerTube-a96aed15188174c50885dda0df3164a67295e11f.tar.gz PeerTube-a96aed15188174c50885dda0df3164a67295e11f.tar.zst PeerTube-a96aed15188174c50885dda0df3164a67295e11f.zip |
Add ability to download a video from direct link or torrent file
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/videos/+video-watch/video-download.component.html | 30 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-download.component.ts (renamed from client/src/app/videos/+video-watch/video-magnet.component.ts) | 7 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-magnet.component.html | 20 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.html | 6 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 8 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.module.ts | 4 | ||||
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 7 |
7 files changed, 49 insertions, 33 deletions
diff --git a/client/src/app/videos/+video-watch/video-download.component.html b/client/src/app/videos/+video-watch/video-download.component.html new file mode 100644 index 000000000..ddc57e999 --- /dev/null +++ b/client/src/app/videos/+video-watch/video-download.component.html | |||
@@ -0,0 +1,30 @@ | |||
1 | <div bsModal #modal="bs-modal" class="modal" tabindex="-1"> | ||
2 | <div class="modal-dialog"> | ||
3 | <div class="modal-content modal-lg"> | ||
4 | |||
5 | <div class="modal-header"> | ||
6 | <button type="button" class="close" aria-label="Close" (click)="hide()"> | ||
7 | <span aria-hidden="true">×</span> | ||
8 | </button> | ||
9 | <h4 class="modal-title">Download</h4> | ||
10 | </div> | ||
11 | |||
12 | <div class="modal-body"> | ||
13 | <div *ngFor="let file of video.files" class="resolution-block"> | ||
14 | <label>{{ file.resolutionLabel }}</label> | ||
15 | <a class="btn btn-default " target="_blank" [href]="file.torrentUrl"> | ||
16 | <span class="glyphicon glyphicon-download"></span> | ||
17 | Torrent file | ||
18 | </a> | ||
19 | <a class="btn btn-default" target="_blank" [href]="file.fileUrl"> | ||
20 | <span class="glyphicon glyphicon-download"></span> | ||
21 | Download | ||
22 | </a> | ||
23 | |||
24 | <!-- Don't display magnet URI for now, this is not compatible with most torrent clients --> | ||
25 | <!--<input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="file.magnetUri" />--> | ||
26 | </div> | ||
27 | </div> | ||
28 | </div> | ||
29 | </div> | ||
30 | </div> | ||
diff --git a/client/src/app/videos/+video-watch/video-magnet.component.ts b/client/src/app/videos/+video-watch/video-download.component.ts index f9432e92c..22149aa6b 100644 --- a/client/src/app/videos/+video-watch/video-magnet.component.ts +++ b/client/src/app/videos/+video-watch/video-download.component.ts | |||
@@ -5,10 +5,11 @@ import { ModalDirective } from 'ngx-bootstrap/modal' | |||
5 | import { Video } from '../shared' | 5 | import { Video } from '../shared' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-video-magnet', | 8 | selector: 'my-video-download', |
9 | templateUrl: './video-magnet.component.html' | 9 | templateUrl: './video-download.component.html', |
10 | styles: [ '.resolution-block { margin-top: 20px; }' ] | ||
10 | }) | 11 | }) |
11 | export class VideoMagnetComponent { | 12 | export class VideoDownloadComponent { |
12 | @Input() video: Video = null | 13 | @Input() video: Video = null |
13 | 14 | ||
14 | @ViewChild('modal') modal: ModalDirective | 15 | @ViewChild('modal') modal: ModalDirective |
diff --git a/client/src/app/videos/+video-watch/video-magnet.component.html b/client/src/app/videos/+video-watch/video-magnet.component.html deleted file mode 100644 index 484280c45..000000000 --- a/client/src/app/videos/+video-watch/video-magnet.component.html +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | <div bsModal #modal="bs-modal" class="modal" tabindex="-1"> | ||
2 | <div class="modal-dialog"> | ||
3 | <div class="modal-content modal-lg"> | ||
4 | |||
5 | <div class="modal-header"> | ||
6 | <button type="button" class="close" aria-label="Close" (click)="hide()"> | ||
7 | <span aria-hidden="true">×</span> | ||
8 | </button> | ||
9 | <h4 class="modal-title">Magnet Uri</h4> | ||
10 | </div> | ||
11 | |||
12 | <div class="modal-body"> | ||
13 | <div *ngFor="let file of video.files"> | ||
14 | <label>{{ file.resolutionLabel }}</label> | ||
15 | <input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="file.magnetUri" /> | ||
16 | </div> | ||
17 | </div> | ||
18 | </div> | ||
19 | </div> | ||
20 | </div> | ||
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index 88863131a..5d5827344 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -71,8 +71,8 @@ | |||
71 | </li> | 71 | </li> |
72 | 72 | ||
73 | <li role="menuitem"> | 73 | <li role="menuitem"> |
74 | <a class="dropdown-item" title="Get magnet URI" href="#" (click)="showMagnetUriModal($event)"> | 74 | <a class="dropdown-item" title="Download the video" href="#" (click)="showDownloadModal($event)"> |
75 | <span class="glyphicon glyphicon-magnet"></span> Magnet | 75 | <span class="glyphicon glyphicon-download-alt"></span> Download |
76 | </a> | 76 | </a> |
77 | </li> | 77 | </li> |
78 | 78 | ||
@@ -179,6 +179,6 @@ | |||
179 | 179 | ||
180 | <ng-template [ngIf]="video !== null"> | 180 | <ng-template [ngIf]="video !== null"> |
181 | <my-video-share #videoShareModal [video]="video"></my-video-share> | 181 | <my-video-share #videoShareModal [video]="video"></my-video-share> |
182 | <my-video-magnet #videoMagnetModal [video]="video"></my-video-magnet> | 182 | <my-video-download #videoDownloadModal [video]="video"></my-video-download> |
183 | <my-video-report #videoReportModal [video]="video"></my-video-report> | 183 | <my-video-report #videoReportModal [video]="video"></my-video-report> |
184 | </ng-template> | 184 | </ng-template> |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index bd98e877c..651298c14 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -10,7 +10,7 @@ import { MetaService } from '@ngx-meta/core' | |||
10 | import { NotificationsService } from 'angular2-notifications' | 10 | import { NotificationsService } from 'angular2-notifications' |
11 | 11 | ||
12 | import { AuthService, ConfirmService } from '../../core' | 12 | import { AuthService, ConfirmService } from '../../core' |
13 | import { VideoMagnetComponent } from './video-magnet.component' | 13 | import { VideoDownloadComponent } from './video-download.component' |
14 | import { VideoShareComponent } from './video-share.component' | 14 | import { VideoShareComponent } from './video-share.component' |
15 | import { VideoReportComponent } from './video-report.component' | 15 | import { VideoReportComponent } from './video-report.component' |
16 | import { Video, VideoService } from '../shared' | 16 | import { Video, VideoService } from '../shared' |
@@ -23,7 +23,7 @@ import { UserVideoRateType, VideoRateType } from '../../../../../shared' | |||
23 | styleUrls: [ './video-watch.component.scss' ] | 23 | styleUrls: [ './video-watch.component.scss' ] |
24 | }) | 24 | }) |
25 | export class VideoWatchComponent implements OnInit, OnDestroy { | 25 | export class VideoWatchComponent implements OnInit, OnDestroy { |
26 | @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent | 26 | @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent |
27 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent | 27 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent |
28 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent | 28 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent |
29 | 29 | ||
@@ -160,9 +160,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
160 | this.videoShareModal.show() | 160 | this.videoShareModal.show() |
161 | } | 161 | } |
162 | 162 | ||
163 | showMagnetUriModal (event: Event) { | 163 | showDownloadModal (event: Event) { |
164 | event.preventDefault() | 164 | event.preventDefault() |
165 | this.videoMagnetModal.show() | 165 | this.videoDownloadModal.show() |
166 | } | 166 | } |
167 | 167 | ||
168 | isUserLoggedIn () { | 168 | isUserLoggedIn () { |
diff --git a/client/src/app/videos/+video-watch/video-watch.module.ts b/client/src/app/videos/+video-watch/video-watch.module.ts index 5f20b171e..c6c1344ce 100644 --- a/client/src/app/videos/+video-watch/video-watch.module.ts +++ b/client/src/app/videos/+video-watch/video-watch.module.ts | |||
@@ -7,7 +7,7 @@ import { SharedModule } from '../../shared' | |||
7 | import { VideoWatchComponent } from './video-watch.component' | 7 | import { VideoWatchComponent } from './video-watch.component' |
8 | import { VideoReportComponent } from './video-report.component' | 8 | import { VideoReportComponent } from './video-report.component' |
9 | import { VideoShareComponent } from './video-share.component' | 9 | import { VideoShareComponent } from './video-share.component' |
10 | import { VideoMagnetComponent } from './video-magnet.component' | 10 | import { VideoDownloadComponent } from './video-download.component' |
11 | 11 | ||
12 | @NgModule({ | 12 | @NgModule({ |
13 | imports: [ | 13 | imports: [ |
@@ -18,7 +18,7 @@ import { VideoMagnetComponent } from './video-magnet.component' | |||
18 | declarations: [ | 18 | declarations: [ |
19 | VideoWatchComponent, | 19 | VideoWatchComponent, |
20 | 20 | ||
21 | VideoMagnetComponent, | 21 | VideoDownloadComponent, |
22 | VideoShareComponent, | 22 | VideoShareComponent, |
23 | VideoReportComponent | 23 | VideoReportComponent |
24 | ], | 24 | ], |
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 7cf3ea6cc..19490baf2 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -158,7 +158,12 @@ const peertubePlugin = function (options: PeertubePluginOptions) { | |||
158 | }) | 158 | }) |
159 | 159 | ||
160 | player.torrent.on('error', err => handleError(err)) | 160 | player.torrent.on('error', err => handleError(err)) |
161 | player.torrent.on('warning', err => handleError(err)) | 161 | player.torrent.on('warning', err => { |
162 | // We don't support HTTP tracker but we don't care -> we use the web socket tracker | ||
163 | if (err.message.indexOf('Unsupported tracker protocol: http://') !== -1) return | ||
164 | |||
165 | return handleError(err) | ||
166 | }) | ||
162 | 167 | ||
163 | player.trigger('videoFileUpdate') | 168 | player.trigger('videoFileUpdate') |
164 | 169 | ||