mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: improve handling of unsupport meta id and type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user