7.7.5: throw a critical error when youtube api returns a stub

merge pull request #283 from wukko/detect-youtube-stub
This commit is contained in:
wukko 2023-12-25 13:01:26 +06:00 committed by GitHub
commit 64790b9820
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 5 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "cobalt", "name": "cobalt",
"description": "save what you love", "description": "save what you love",
"version": "7.7.4", "version": "7.7.5",
"author": "wukko", "author": "wukko",
"exports": "./src/cobalt.js", "exports": "./src/cobalt.js",
"type": "module", "type": "module",

View file

@ -151,9 +151,15 @@ export default async function(host, patternMatch, url, lang, obj) {
if (r.isAudioOnly) isAudioOnly = true; if (r.isAudioOnly) isAudioOnly = true;
let isAudioMuted = isAudioOnly ? false : obj.isAudioMuted; let isAudioMuted = isAudioOnly ? false : obj.isAudioMuted;
if (r.error) return apiJSON(0, { if (r.error && r.critical)
t: Array.isArray(r.error) ? loc(lang, r.error[0], r.error[1]) : loc(lang, r.error) return apiJSON(6, { t: loc(lang, r.error) })
})
if (r.error)
return apiJSON(0, {
t: Array.isArray(r.error)
? loc(lang, r.error[0], r.error[1])
: loc(lang, r.error)
})
return matchActionDecider(r, host, obj.aFormat, isAudioOnly, lang, isAudioMuted, disableMetadata, obj.filenamePattern) return matchActionDecider(r, host, obj.aFormat, isAudioOnly, lang, isAudioMuted, disableMetadata, obj.filenamePattern)
} catch (e) { } catch (e) {

View file

@ -83,6 +83,12 @@ export default async function(o) {
youtubeDubName: isDubbed ? o.dubLang : false youtubeDubName: isDubbed ? o.dubLang : false
} }
if (filenameAttributes.title === "Video Not Available" && filenameAttributes.author === "YouTube Viewers")
return {
error: 'ErrorCantConnectToServiceAPI',
critical: true
}
if (hasAudio && o.isAudioOnly) return { if (hasAudio && o.isAudioOnly) return {
type: "render", type: "render",
isAudioOnly: true, isAudioOnly: true,

View file

@ -35,11 +35,13 @@ export function apiJSON(type, obj) {
break; break;
} }
return { status: 200, body: { status: "picker", pickerType: pickerType, picker: obj.picker, audio: audio } }; return { status: 200, body: { status: "picker", pickerType: pickerType, picker: obj.picker, audio: audio } };
case 6: // critical error, action should be taken by balancer/other server software
return { status: 500, body: { status: "error", text: obj.t, critical: true } };
default: default:
return { status: 400, body: { status: "error", text: "Bad Request" } }; return { status: 400, body: { status: "error", text: "Bad Request" } };
} }
} catch (e) { } catch (e) {
return { status: 500, body: { status: "error", text: "Internal Server Error" } }; return { status: 500, body: { status: "error", text: "Internal Server Error", critical: true } };
} }
} }
export function metadataManager(obj) { export function metadataManager(obj) {