From 3bfb3212b846c85bd5b4e5ac9143fca42231db09 Mon Sep 17 00:00:00 2001 From: snobu Date: Mon, 30 Mar 2020 13:29:59 +0300 Subject: [PATCH] I've made the code worse since map is an antipattern if you discard the resulting array but YOLO --- destreamer.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/destreamer.ts b/destreamer.ts index 1453497..0221087 100644 --- a/destreamer.ts +++ b/destreamer.ts @@ -234,11 +234,14 @@ async function getVideoInfo(videoID: string, session: any) { } let playbackUrl = null; try { - playbackUrl = data["playbackUrls"].filter( - (item: { [x: string]: string; }) => item["mimeType"] == "application/vnd.apple.mpegurl")[0]["playbackUrl"]; + playbackUrl = data["playbackUrls"] + .filter((item: { [x: string]: string; }) => + item["mimeType"] == "application/vnd.apple.mpegurl") + .map((item: { [x: string]: string }) => + { return item["playbackUrl"] })[0]; } catch (e) { - console.error(`Error fetching hlsUrl: ${e}`); + console.error(`Error fetching HLS URL: ${e}.\n playbackUrl is ${playbackUrl}`); process.exit(27); }