[scraper] retry different resource type for cinemeta if not found

This commit is contained in:
TheBeastLT
2020-03-15 11:55:19 +01:00
parent e904dea5e6
commit dba04c8a69

View File

@@ -18,6 +18,11 @@ function getMetadata(id, type = Type.SERIES) {
return cacheWrapMetadata(key,
() => _requestMetadata(`${KITSU_URL}/meta/${metaType}/${key}.json`)
.catch(() => _requestMetadata(`${CINEMETA_URL}/meta/${metaType}/${key}.json`))
.catch(() => {
// try different type in case there was a mismatch
const otherType = metaType === Type.MOVIE ? Type.SERIES : Type.MOVIE;
return _requestMetadata(`${CINEMETA_URL}/meta/${otherType}/${key}.json`)
})
.catch((error) => {
throw new Error(`failed metadata query ${key} due: ${error.message}`);
}));