mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-17 22:00:00 +00:00
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:
commit
64790b9820
4 changed files with 19 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "cobalt",
|
||||
"description": "save what you love",
|
||||
"version": "7.7.4",
|
||||
"version": "7.7.5",
|
||||
"author": "wukko",
|
||||
"exports": "./src/cobalt.js",
|
||||
"type": "module",
|
||||
|
|
|
@ -151,8 +151,14 @@ export default async function(host, patternMatch, url, lang, obj) {
|
|||
if (r.isAudioOnly) isAudioOnly = true;
|
||||
let isAudioMuted = isAudioOnly ? false : obj.isAudioMuted;
|
||||
|
||||
if (r.error) return apiJSON(0, {
|
||||
t: Array.isArray(r.error) ? loc(lang, r.error[0], r.error[1]) : loc(lang, r.error)
|
||||
if (r.error && r.critical)
|
||||
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)
|
||||
|
|
|
@ -83,6 +83,12 @@ export default async function(o) {
|
|||
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 {
|
||||
type: "render",
|
||||
isAudioOnly: true,
|
||||
|
|
|
@ -35,11 +35,13 @@ export function apiJSON(type, obj) {
|
|||
break;
|
||||
}
|
||||
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:
|
||||
return { status: 400, body: { status: "error", text: "Bad Request" } };
|
||||
}
|
||||
} 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) {
|
||||
|
|
Loading…
Reference in a new issue