throw a critical error when youtube api returns a stub
This commit is contained in:
parent
0014c8b9fb
commit
a4349b4c41
4 changed files with 19 additions and 5 deletions
|
@ -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",
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue