mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add ability to download a video from direct link or torrent file
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<div bsModal #modal="bs-modal" class="modal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content modal-lg">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" aria-label="Close" (click)="hide()">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">Download</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div *ngFor="let file of video.files" class="resolution-block">
|
||||
<label>{{ file.resolutionLabel }}</label>
|
||||
<a class="btn btn-default " target="_blank" [href]="file.torrentUrl">
|
||||
<span class="glyphicon glyphicon-download"></span>
|
||||
Torrent file
|
||||
</a>
|
||||
<a class="btn btn-default" target="_blank" [href]="file.fileUrl">
|
||||
<span class="glyphicon glyphicon-download"></span>
|
||||
Download
|
||||
</a>
|
||||
|
||||
<!-- Don't display magnet URI for now, this is not compatible with most torrent clients -->
|
||||
<!--<input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="file.magnetUri" />-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5,10 +5,11 @@ import { ModalDirective } from 'ngx-bootstrap/modal'
|
||||
import { Video } from '../shared'
|
||||
|
||||
@Component({
|
||||
selector: 'my-video-magnet',
|
||||
templateUrl: './video-magnet.component.html'
|
||||
selector: 'my-video-download',
|
||||
templateUrl: './video-download.component.html',
|
||||
styles: [ '.resolution-block { margin-top: 20px; }' ]
|
||||
})
|
||||
export class VideoMagnetComponent {
|
||||
export class VideoDownloadComponent {
|
||||
@Input() video: Video = null
|
||||
|
||||
@ViewChild('modal') modal: ModalDirective
|
||||
@@ -1,20 +0,0 @@
|
||||
<div bsModal #modal="bs-modal" class="modal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content modal-lg">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" aria-label="Close" (click)="hide()">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title">Magnet Uri</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div *ngFor="let file of video.files">
|
||||
<label>{{ file.resolutionLabel }}</label>
|
||||
<input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="file.magnetUri" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,8 +71,8 @@
|
||||
</li>
|
||||
|
||||
<li role="menuitem">
|
||||
<a class="dropdown-item" title="Get magnet URI" href="#" (click)="showMagnetUriModal($event)">
|
||||
<span class="glyphicon glyphicon-magnet"></span> Magnet
|
||||
<a class="dropdown-item" title="Download the video" href="#" (click)="showDownloadModal($event)">
|
||||
<span class="glyphicon glyphicon-download-alt"></span> Download
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -179,6 +179,6 @@
|
||||
|
||||
<ng-template [ngIf]="video !== null">
|
||||
<my-video-share #videoShareModal [video]="video"></my-video-share>
|
||||
<my-video-magnet #videoMagnetModal [video]="video"></my-video-magnet>
|
||||
<my-video-download #videoDownloadModal [video]="video"></my-video-download>
|
||||
<my-video-report #videoReportModal [video]="video"></my-video-report>
|
||||
</ng-template>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { MetaService } from '@ngx-meta/core'
|
||||
import { NotificationsService } from 'angular2-notifications'
|
||||
|
||||
import { AuthService, ConfirmService } from '../../core'
|
||||
import { VideoMagnetComponent } from './video-magnet.component'
|
||||
import { VideoDownloadComponent } from './video-download.component'
|
||||
import { VideoShareComponent } from './video-share.component'
|
||||
import { VideoReportComponent } from './video-report.component'
|
||||
import { Video, VideoService } from '../shared'
|
||||
@@ -23,7 +23,7 @@ import { UserVideoRateType, VideoRateType } from '../../../../../shared'
|
||||
styleUrls: [ './video-watch.component.scss' ]
|
||||
})
|
||||
export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent
|
||||
@ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
|
||||
@ViewChild('videoShareModal') videoShareModal: VideoShareComponent
|
||||
@ViewChild('videoReportModal') videoReportModal: VideoReportComponent
|
||||
|
||||
@@ -160,9 +160,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||
this.videoShareModal.show()
|
||||
}
|
||||
|
||||
showMagnetUriModal (event: Event) {
|
||||
showDownloadModal (event: Event) {
|
||||
event.preventDefault()
|
||||
this.videoMagnetModal.show()
|
||||
this.videoDownloadModal.show()
|
||||
}
|
||||
|
||||
isUserLoggedIn () {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { SharedModule } from '../../shared'
|
||||
import { VideoWatchComponent } from './video-watch.component'
|
||||
import { VideoReportComponent } from './video-report.component'
|
||||
import { VideoShareComponent } from './video-share.component'
|
||||
import { VideoMagnetComponent } from './video-magnet.component'
|
||||
import { VideoDownloadComponent } from './video-download.component'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -18,7 +18,7 @@ import { VideoMagnetComponent } from './video-magnet.component'
|
||||
declarations: [
|
||||
VideoWatchComponent,
|
||||
|
||||
VideoMagnetComponent,
|
||||
VideoDownloadComponent,
|
||||
VideoShareComponent,
|
||||
VideoReportComponent
|
||||
],
|
||||
|
||||
@@ -158,7 +158,12 @@ const peertubePlugin = function (options: PeertubePluginOptions) {
|
||||
})
|
||||
|
||||
player.torrent.on('error', err => handleError(err))
|
||||
player.torrent.on('warning', err => handleError(err))
|
||||
player.torrent.on('warning', err => {
|
||||
// We don't support HTTP tracker but we don't care -> we use the web socket tracker
|
||||
if (err.message.indexOf('Unsupported tracker protocol: http://') !== -1) return
|
||||
|
||||
return handleError(err)
|
||||
})
|
||||
|
||||
player.trigger('videoFileUpdate')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user