diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-07 09:54:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 09:30:31 +0200 |
commit | 990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66 (patch) | |
tree | 8aaa0638798bfa14813f4d6ed5247242313b9ce6 /client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts | |
parent | ce33919c24e7402d92d81f3cd8e545df52d98240 (diff) | |
download | PeerTube-990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66.tar.gz PeerTube-990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66.tar.zst PeerTube-990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66.zip |
Import torrents with webtorrent
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts index 330c37718..9623c2bf4 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, EventEmitter, OnInit, Output } from '@angular/core' | 1 | import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { VideoPrivacy, VideoUpdate } from '../../../../../../shared/models/videos' | 4 | import { VideoPrivacy, VideoUpdate } from '../../../../../../shared/models/videos' |
@@ -23,6 +23,7 @@ import { VideoImportService } from '@app/shared/video-import' | |||
23 | }) | 23 | }) |
24 | export class VideoImportTorrentComponent extends VideoSend implements OnInit, CanComponentDeactivate { | 24 | export class VideoImportTorrentComponent extends VideoSend implements OnInit, CanComponentDeactivate { |
25 | @Output() firstStepDone = new EventEmitter<string>() | 25 | @Output() firstStepDone = new EventEmitter<string>() |
26 | @ViewChild('torrentfileInput') torrentfileInput | ||
26 | 27 | ||
27 | videoFileName: string | 28 | videoFileName: string |
28 | magnetUri = '' | 29 | magnetUri = '' |
@@ -33,7 +34,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca | |||
33 | 34 | ||
34 | video: VideoEdit | 35 | video: VideoEdit |
35 | 36 | ||
36 | protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PRIVATE | 37 | protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC |
37 | 38 | ||
38 | constructor ( | 39 | constructor ( |
39 | protected formValidatorService: FormValidatorService, | 40 | protected formValidatorService: FormValidatorService, |
@@ -62,7 +63,14 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca | |||
62 | return !!this.magnetUri | 63 | return !!this.magnetUri |
63 | } | 64 | } |
64 | 65 | ||
65 | importVideo () { | 66 | fileChange () { |
67 | const torrentfile = this.torrentfileInput.nativeElement.files[0] as File | ||
68 | if (!torrentfile) return | ||
69 | |||
70 | this.importVideo(torrentfile) | ||
71 | } | ||
72 | |||
73 | importVideo (torrentfile?: Blob) { | ||
66 | this.isImportingVideo = true | 74 | this.isImportingVideo = true |
67 | 75 | ||
68 | const videoUpdate: VideoUpdate = { | 76 | const videoUpdate: VideoUpdate = { |
@@ -74,7 +82,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca | |||
74 | 82 | ||
75 | this.loadingBar.start() | 83 | this.loadingBar.start() |
76 | 84 | ||
77 | this.videoImportService.importVideoTorrent(this.magnetUri, videoUpdate).subscribe( | 85 | this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( |
78 | res => { | 86 | res => { |
79 | this.loadingBar.complete() | 87 | this.loadingBar.complete() |
80 | this.firstStepDone.emit(res.video.name) | 88 | this.firstStepDone.emit(res.video.name) |