aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-13 14:27:44 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-09-14 11:08:55 +0200
commit8704acf49efc770d73bf07c10468ed8c74d28a83 (patch)
treeffd46289fcf9a13ac4412b167e9f71dfb35753c5 /server/helpers
parent1d9d9cfdcf3983e3fd89026bc4b5633a8abf5752 (diff)
downloadPeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.gz
PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.tar.zst
PeerTube-8704acf49efc770d73bf07c10468ed8c74d28a83.zip
one cli to unite them all
Ash nazg thrakatulûk agh burzum-ishi krimpatul - refactor import-videos to use the youtubeDL helper - add very basic tests for the cli
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/youtube-dl.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 6738090f3..8b2bc1782 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -14,9 +14,9 @@ export type YoutubeDLInfo = {
14 thumbnailUrl?: string 14 thumbnailUrl?: string
15} 15}
16 16
17function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { 17function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> {
18 return new Promise<YoutubeDLInfo>(async (res, rej) => { 18 return new Promise<YoutubeDLInfo>(async (res, rej) => {
19 const options = [ '-j', '--flat-playlist' ] 19 const options = opts || [ '-j', '--flat-playlist' ]
20 20
21 const youtubeDL = await safeGetYoutubeDL() 21 const youtubeDL = await safeGetYoutubeDL()
22 youtubeDL.getInfo(url, options, (err, info) => { 22 youtubeDL.getInfo(url, options, (err, info) => {
@@ -48,15 +48,6 @@ function downloadYoutubeDLVideo (url: string) {
48 }) 48 })
49} 49}
50 50
51// ---------------------------------------------------------------------------
52
53export {
54 downloadYoutubeDLVideo,
55 getYoutubeDLInfo
56}
57
58// ---------------------------------------------------------------------------
59
60async function safeGetYoutubeDL () { 51async function safeGetYoutubeDL () {
61 let youtubeDL 52 let youtubeDL
62 53
@@ -71,6 +62,16 @@ async function safeGetYoutubeDL () {
71 return youtubeDL 62 return youtubeDL
72} 63}
73 64
65// ---------------------------------------------------------------------------
66
67export {
68 downloadYoutubeDLVideo,
69 getYoutubeDLInfo,
70 safeGetYoutubeDL
71}
72
73// ---------------------------------------------------------------------------
74
74function normalizeObject (obj: any) { 75function normalizeObject (obj: any) {
75 const newObj: any = {} 76 const newObj: any = {}
76 77