mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] retry different resource type for cinemeta if not found
This commit is contained in:
@@ -18,6 +18,11 @@ function getMetadata(id, type = Type.SERIES) {
|
|||||||
return cacheWrapMetadata(key,
|
return cacheWrapMetadata(key,
|
||||||
() => _requestMetadata(`${KITSU_URL}/meta/${metaType}/${key}.json`)
|
() => _requestMetadata(`${KITSU_URL}/meta/${metaType}/${key}.json`)
|
||||||
.catch(() => _requestMetadata(`${CINEMETA_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) => {
|
.catch((error) => {
|
||||||
throw new Error(`failed metadata query ${key} due: ${error.message}`);
|
throw new Error(`failed metadata query ${key} due: ${error.message}`);
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user