feat: improve handling of unsupport meta id and type

This commit is contained in:
Viren070
2025-06-16 02:22:38 +01:00
parent 6a874806b8
commit 3779ea09d3
3 changed files with 22 additions and 7 deletions
+9 -4
View File
@@ -410,10 +410,15 @@ export class AIOStreams {
}
if (candidates.length === 0) {
logger.error(`No addon found supporting meta resource for type ${type}`);
throw new Error(
`No addon found supporting meta resource for type ${type}`
);
logger.warn(`No supported addon was found for the requested meta`, {
type,
id,
});
return {
success: false,
data: null,
errors: [],
};
}
// Try each candidate in order, collecting errors
+7 -1
View File
@@ -201,9 +201,15 @@ export class StremioTransformer {
};
}
transformMeta(response: AIOStreamsResponse<Meta | null>): MetaResponse {
transformMeta(
response: AIOStreamsResponse<Meta | null>
): MetaResponse | null {
const { data: meta, errors } = response;
if (!meta && errors.length === 0) {
return null;
}
if (this.showError('meta', errors) || !meta) {
return {
meta: StremioTransformer.createErrorMeta({
+6 -2
View File
@@ -34,8 +34,12 @@ router.get(
await aiostreams.initialise();
const meta = await aiostreams.getMeta(type, id);
res.status(200).json(transformer.transformMeta(meta));
const transformed = transformer.transformMeta(meta);
if (!transformed) {
next();
} else {
res.status(200).json(transformed);
}
} catch (error) {
next(error);
}