mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-29 17:58:27 +00:00
api/youtube: catch even more innertube errors
This commit is contained in:
parent
f1f9955159
commit
5b445d5c7e
|
@ -143,13 +143,22 @@ export default async function(o) {
|
|||
try {
|
||||
info = await yt.getBasicInfo(o.id, useHLS ? 'IOS' : 'ANDROID');
|
||||
} catch (e) {
|
||||
if (e?.info?.reason === "This video is private") {
|
||||
return { error: "content.video.private" };
|
||||
} else if (e?.message === "This video is unavailable") {
|
||||
return { error: "content.video.unavailable" };
|
||||
} else {
|
||||
return { error: "fetch.fail" };
|
||||
if (e?.info) {
|
||||
const errorInfo = JSON.parse(e?.info);
|
||||
|
||||
if (errorInfo?.reason === "This video is private") {
|
||||
return { error: "content.video.private" };
|
||||
}
|
||||
if (["INVALID_ARGUMENT", "UNAUTHENTICATED"].includes(errorInfo?.error?.status)) {
|
||||
return { error: "youtube.api_error" };
|
||||
}
|
||||
}
|
||||
|
||||
if (e?.message === "This video is unavailable") {
|
||||
return { error: "content.video.unavailable" };
|
||||
}
|
||||
|
||||
return { error: "fetch.fail" };
|
||||
}
|
||||
|
||||
if (!info) return { error: "fetch.fail" };
|
||||
|
|
Loading…
Reference in a new issue