fent / fent/node-ytdl-core

MinigetError: Status code: 410

Open
#1,309 2 comments 6 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.7k
Forks
852
PR merge metrics
No merged PRs in 30d

Description

using this package for more than year, suddenly it stopped working and getting this error while trying to get video info, that will be then used to get video captions
**Error getting info for videoId: hTcRmj-XLEs MinigetError: Status code: 410
at ClientRequest. (/var/task/node_modules/miniget/dist/index.js:206:27)
at Object.onceWrapper (node:events:632:26)
at ClientRequest.emit (node:events:529:35)
at HTTPParser.parserOnIncomingClient (node:_http_client:700:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
at TLSSocket.socketOnData (node:_http_client:541:22)
at TLSSocket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10) {
statusCode: 410
}**
here is my code
try {
const { videoId } = body;
console.log("got: ", videoId);
const format = "xml"; // Default format is XML
const clientLang = query.lang || "en"; // Default language is English

let info;
try {

info = await ytdl.getInfo(videoId, { lang: clientLang });


} catch (error) {
console.error("Error getting info for videoId:", videoId, error);
return null;
}
if (info) {
const autoLangCode = detect(info.videoDetails.title);
console.log("autoLangCode found===> ,clientLang", clientLang, autoLangCode);

const tracks =
info.player_response.captions.playerCaptionsTracklistRenderer
.captionTracks;

if (tracks && tracks.length) {
let track = tracks.find(
(t) => t.languageCode === (clientLang || autoLangCode || "en")
);

if (track) {
const captionLink = `${track.baseUrl}&fmt=${
format !== "xml" ? format : ""
}`;

const xmlData = await new Promise((resolve, reject) => {
https
.get(captionLink, (response) => {
let data = "";

response.on("data", (chunk) => {
data += chunk;
});

response.on("end", () => {
resolve(data);
});
})
.on("error", (error) => {
reject(error);
});
});

const parser = new xml2js.Parser();
parser.parseString(xmlData, async (err, result) => {
if (err) {
console.error("Error parsing XML:", err);
} else {
const textContent = result.transcript.text.map(
(textElement) => textElement._
);
const processedText = textContent.join(" ");

// Send the response based on the selected file format
if (selectedFormat === "xml") {
res.status(200).send(xmlData);
} else if (selectedFormat === "txt") {
res.status(200).send(processedText);
} else {
res
.status(400)
.json({ error: "Invalid file format selected" });
}
}
});
} else {
res
.status(404)
.json({
error:
"Could not find captions for the specified language",
});
}
} else {
res
.status(404)
.json({ error: "No captions found for this video" });
}
} else {
console.error("No Info found for videoId:", videoId);
}
} catch (error) {
console.error("Error in download-caption process:", error);
res
.status(500)
.json({ error: "Internal Server Error", details: error.message });
}
Code is working fine on localhost , bt getting this error on my production server (vercel)
Please help me resolving this issue asap.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.