Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Correctly fix subtitles import

Chocobozzz982f2fc9b425
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 2014aab0a4..bb59309520 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -67,17 +67,16 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise<YoutubeDLSubs> {
const subtitles = files.reduce((acc, filename) => {
const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i)
-
- if (matched[1]) {
- return [
- ...acc,
- {
- language: matched[1],
- path: join(cwd, filename),
- filename
- }
- ]
- }
+ if (!matched || !matched[1]) return acc
+
+ return [
+ ...acc,
+ {
+ language: matched[1],
+ path: join(cwd, filename),
+ filename
+ }
+ ]
}, [])
return res(subtitles)