Skip to content

best way to save what you love

api/youtube: catch even more innertube errors

wukko5b445d5c7e5d
diff --git a/api/src/processing/services/youtube.js b/api/src/processing/services/youtube.js
index e63a21b2..9e99d62f 100644
--- a/api/src/processing/services/youtube.js
+++ b/api/src/processing/services/youtube.js
@@ -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") {
+ 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" };
- } else {
- return { error: "fetch.fail" };
}
+
+ return { error: "fetch.fail" };
}
if (!info) return { error: "fetch.fail" };