mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Fix: Enhance error handling for playlist fetch failures by retrying with single video
This commit is contained in:
@@ -22,7 +22,32 @@ async function infoController(req, res){
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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") {
|
if (data._type === "playlist") {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user