diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-20 16:24:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 16:24:49 +0200 |
commit | dc27668fceb1d0270c391c93c3bbc95d12e83218 (patch) | |
tree | ce6621597505f9518cfdf0981977d097c63f9fad /server/helpers | |
parent | 6247b2057b792cea155a1abd9788c363ae7d2cc2 (diff) | |
parent | 0491173a61aed66205c017e0d7e0503ea316c144 (diff) | |
download | PeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.tar.gz PeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.tar.zst PeerTube-dc27668fceb1d0270c391c93c3bbc95d12e83218.zip |
Merge pull request #941 from rigelk/cli-wrapper
adding cli wrapper
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/youtube-dl.ts | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index db2bddf78..25e719cc3 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts | |||
@@ -18,9 +18,9 @@ export type YoutubeDLInfo = { | |||
18 | thumbnailUrl?: string | 18 | thumbnailUrl?: string |
19 | } | 19 | } |
20 | 20 | ||
21 | function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { | 21 | function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> { |
22 | return new Promise<YoutubeDLInfo>(async (res, rej) => { | 22 | return new Promise<YoutubeDLInfo>(async (res, rej) => { |
23 | const options = [ '-j', '--flat-playlist' ] | 23 | const options = opts || [ '-j', '--flat-playlist' ] |
24 | 24 | ||
25 | const youtubeDL = await safeGetYoutubeDL() | 25 | const youtubeDL = await safeGetYoutubeDL() |
26 | youtubeDL.getInfo(url, options, (err, info) => { | 26 | youtubeDL.getInfo(url, options, (err, info) => { |
@@ -110,16 +110,6 @@ async function updateYoutubeDLBinary () { | |||
110 | }) | 110 | }) |
111 | } | 111 | } |
112 | 112 | ||
113 | // --------------------------------------------------------------------------- | ||
114 | |||
115 | export { | ||
116 | updateYoutubeDLBinary, | ||
117 | downloadYoutubeDLVideo, | ||
118 | getYoutubeDLInfo | ||
119 | } | ||
120 | |||
121 | // --------------------------------------------------------------------------- | ||
122 | |||
123 | async function safeGetYoutubeDL () { | 113 | async function safeGetYoutubeDL () { |
124 | let youtubeDL | 114 | let youtubeDL |
125 | 115 | ||
@@ -134,6 +124,17 @@ async function safeGetYoutubeDL () { | |||
134 | return youtubeDL | 124 | return youtubeDL |
135 | } | 125 | } |
136 | 126 | ||
127 | // --------------------------------------------------------------------------- | ||
128 | |||
129 | export { | ||
130 | updateYoutubeDLBinary, | ||
131 | downloadYoutubeDLVideo, | ||
132 | getYoutubeDLInfo, | ||
133 | safeGetYoutubeDL | ||
134 | } | ||
135 | |||
136 | // --------------------------------------------------------------------------- | ||
137 | |||
137 | function normalizeObject (obj: any) { | 138 | function normalizeObject (obj: any) { |
138 | const newObj: any = {} | 139 | const newObj: any = {} |
139 | 140 | ||