From 912f4042e56dd1a57372b20085ac8c4221729bd7 Mon Sep 17 00:00:00 2001 From: MasterAcnolo <68693319+MasterAcnolo@users.noreply.github.com> Date: Sun, 12 Apr 2026 17:34:17 +0200 Subject: [PATCH] Fix: Enhance error handling for playlist fetch failures by retrying with single video --- server/controller/info.controller.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/server/controller/info.controller.js b/server/controller/info.controller.js index beb85da..8e7cecb 100644 --- a/server/controller/info.controller.js +++ b/server/controller/info.controller.js @@ -22,7 +22,32 @@ async function infoController(req, res){ } try { - const data = await fetchInfo(url); + let data; + let fetchError = null; + + try { + data = await fetchInfo(url); + } catch (err) { + fetchError = err; + + // If it's a playlist URL and fetch failed, try fetching just the single video + if ((url.includes("&list") || url.includes("?list"))) { + logger.info(`Playlist fetch failed: ${err.message}. Retrying with single video...`); + + // Remove the &list parameter + const singleVideoUrl = url.split("&list")[0].split("?list")[0]; + + try { + data = await fetchInfo(singleVideoUrl); + logger.info(`Single video fetch succeeded after playlist failure`); + } catch (retryErr) { + logger.error(`Single video fetch also failed: ${retryErr.message}`); + throw err; // Throw the original error + } + } else { + throw err; + } + } if (data._type === "playlist") {