aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-20 16:24:49 +0200
committerGitHub <noreply@github.com>2018-09-20 16:24:49 +0200
commitdc27668fceb1d0270c391c93c3bbc95d12e83218 (patch)
treece6621597505f9518cfdf0981977d097c63f9fad /server/helpers/youtube-dl.ts
parent6247b2057b792cea155a1abd9788c363ae7d2cc2 (diff)
parent0491173a61aed66205c017e0d7e0503ea316c144 (diff)
downloadPeerTube-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/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts25
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
21function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { 21function 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
115export {
116 updateYoutubeDLBinary,
117 downloadYoutubeDLVideo,
118 getYoutubeDLInfo
119}
120
121// ---------------------------------------------------------------------------
122
123async function safeGetYoutubeDL () { 113async 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
129export {
130 updateYoutubeDLBinary,
131 downloadYoutubeDLVideo,
132 getYoutubeDLInfo,
133 safeGetYoutubeDL
134}
135
136// ---------------------------------------------------------------------------
137
137function normalizeObject (obj: any) { 138function normalizeObject (obj: any) {
138 const newObj: any = {} 139 const newObj: any = {}
139 140