aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video-import
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-02 15:34:09 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commitfbad87b0472f574409f7aa3ae7f8b54927d0cdd6 (patch)
tree197b4209e75d57dabae7cdd6f2da5f765e427023 /client/src/app/shared/video-import
parent5e319fb7898fd0482c399cc3ae9dcfc20d274a58 (diff)
downloadPeerTube-fbad87b0472f574409f7aa3ae7f8b54927d0cdd6.tar.gz
PeerTube-fbad87b0472f574409f7aa3ae7f8b54927d0cdd6.tar.zst
PeerTube-fbad87b0472f574409f7aa3ae7f8b54927d0cdd6.zip
Add ability to import video with youtube-dl
Diffstat (limited to 'client/src/app/shared/video-import')
-rw-r--r--client/src/app/shared/video-import/index.ts1
-rw-r--r--client/src/app/shared/video-import/video-import.service.ts56
2 files changed, 57 insertions, 0 deletions
diff --git a/client/src/app/shared/video-import/index.ts b/client/src/app/shared/video-import/index.ts
new file mode 100644
index 000000000..9bb73ec2c
--- /dev/null
+++ b/client/src/app/shared/video-import/index.ts
@@ -0,0 +1 @@
export * from './video-import.service'
diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.ts
new file mode 100644
index 000000000..b4709866a
--- /dev/null
+++ b/client/src/app/shared/video-import/video-import.service.ts
@@ -0,0 +1,56 @@
1import { catchError } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { Observable } from 'rxjs'
5import { VideoImport } from '../../../../../shared'
6import { environment } from '../../../environments/environment'
7import { RestExtractor, RestService } from '../rest'
8import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model'
9import { objectToFormData } from '@app/shared/misc/utils'
10import { VideoUpdate } from '../../../../../shared/models/videos'
11
12@Injectable()
13export class VideoImportService {
14 private static BASE_VIDEO_IMPORT_URL = environment.apiUrl + '/api/v1/videos/imports/'
15
16 constructor (
17 private authHttp: HttpClient,
18 private restService: RestService,
19 private restExtractor: RestExtractor
20 ) {}
21
22 importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> {
23 const url = VideoImportService.BASE_VIDEO_IMPORT_URL
24 const language = video.language || null
25 const licence = video.licence || null
26 const category = video.category || null
27 const description = video.description || null
28 const support = video.support || null
29 const scheduleUpdate = video.scheduleUpdate || null
30
31 const body: VideoImportCreate = {
32 targetUrl,
33
34 name: video.name,
35 category,
36 licence,
37 language,
38 support,
39 description,
40 channelId: video.channelId,
41 privacy: video.privacy,
42 tags: video.tags,
43 nsfw: video.nsfw,
44 waitTranscoding: video.waitTranscoding,
45 commentsEnabled: video.commentsEnabled,
46 thumbnailfile: video.thumbnailfile,
47 previewfile: video.previewfile,
48 scheduleUpdate
49 }
50
51 const data = objectToFormData(body)
52 return this.authHttp.post<VideoImport>(url, data)
53 .pipe(catchError(res => this.restExtractor.handleError(res)))
54 }
55
56}