aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-15 14:15:44 +0200
committerChocobozzz <me@florianbigard.com>2020-04-15 14:15:44 +0200
commit652c64165b3d8d1c5d5fc646c29e5cd1c82a3330 (patch)
tree03958b1ca6ace8781e23c8b0210a42ae00828bf2 /server/helpers/youtube-dl.ts
parentba6e9e8f1df29a7f355636d48c2a608bc4cb54ec (diff)
downloadPeerTube-652c64165b3d8d1c5d5fc646c29e5cd1c82a3330.tar.gz
PeerTube-652c64165b3d8d1c5d5fc646c29e5cd1c82a3330.tar.zst
PeerTube-652c64165b3d8d1c5d5fc646c29e5cd1c82a3330.zip
Fix import captions test
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 277422645..6d2e6f6d1 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -21,8 +21,8 @@ export type YoutubeDLInfo = {
21} 21}
22 22
23export type YoutubeDLSubs = { 23export type YoutubeDLSubs = {
24 language: string, 24 language: string
25 filename: string, 25 filename: string
26 path: string 26 path: string
27}[] 27}[]
28 28
@@ -61,15 +61,20 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise<YoutubeDLSubs> {
61 youtubeDL.getSubs(url, options, (err, files) => { 61 youtubeDL.getSubs(url, options, (err, files) => {
62 if (err) return rej(err) 62 if (err) return rej(err)
63 63
64 logger.debug('Get subtitles from youtube dl.', { url, files })
65
64 const subtitles = files.reduce((acc, filename) => { 66 const subtitles = files.reduce((acc, filename) => {
65 const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i) 67 const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i)
66 68
67 if (matched[1]) { 69 if (matched[1]) {
68 return [...acc, { 70 return [
69 language: matched[1], 71 ...acc,
70 path: join(cwd, filename), 72 {
71 filename 73 language: matched[1],
72 }] 74 path: join(cwd, filename),
75 filename
76 }
77 ]
73 } 78 }
74 }, []) 79 }, [])
75 80