fix: add verbose logging for resources and fix addon catalog support

This commit is contained in:
Viren070
2025-06-05 18:59:12 +01:00
parent 654b1bc058
commit 4daa6441ee
5 changed files with 57 additions and 11 deletions
+37 -2
View File
@@ -265,7 +265,7 @@ export class AIOStreams {
// step 2
// get the actual catalog id from the id
const actualCatalogId = id.split('.', 2)[1];
const actualCatalogId = id.split('.').slice(1).join('.');
// step 3
// get the catalog from the addon
let catalog = await new Wrapper(addon).getCatalog(
@@ -441,7 +441,7 @@ export class AIOStreams {
// step 2
// get the actual addon catalog id from the id
const actualAddonCatalogId = id.split('.', 2)[1];
const actualAddonCatalogId = id.split('.').slice(1).join('.');
// step 3
// get the addon catalog from the addon
@@ -513,6 +513,12 @@ export class AIOStreams {
const addon = this.addons[Number(index)];
logger.verbose(
`Determined that ${addon.identifyingName} (Index: ${index}) has support for the following resources: ${JSON.stringify(
addonResources
)}`
);
// Filter and merge resources
for (const resource of addonResources) {
if (
@@ -572,6 +578,35 @@ export class AIOStreams {
this.supportedResources[Number(index)] = addonResources;
}
logger.verbose(
`Parsed all catalogs and determined the following catalogs: ${JSON.stringify(
this.finalCatalogs.map((c) => ({
id: c.id,
name: c.name,
type: c.type,
}))
)}`
);
logger.verbose(
`Parsed all addon catalogs and determined the following catalogs: ${JSON.stringify(
this.finalAddonCatalogs?.map((c) => ({
id: c.id,
name: c.name,
type: c.type,
}))
)}`
);
logger.verbose(
`Parsed all resources and determined the following resources: ${JSON.stringify(
this.finalResources.map((r) => ({
name: r.name,
types: r.types,
}))
)}`
);
if (this.userData.catalogModifications) {
this.finalCatalogs = this.finalCatalogs
// Sort catalogs based on catalogModifications order, with non-modified catalogs at the end
+2
View File
@@ -14,6 +14,7 @@ import {
catalog,
meta,
subtitle,
addonCatalog,
} from './routes/stremio';
import {
@@ -73,6 +74,7 @@ stremioAuthRouter.use('/configure.txt', (req, res) => {
stremioAuthRouter.use('/meta', meta);
stremioAuthRouter.use('/catalog', catalog);
stremioAuthRouter.use('/subtitles', subtitle);
stremioAuthRouter.use('/addon_catalog', addonCatalog);
app.use('/stremio', stremioRouter); // For public routes
app.use('/stremio/:uuid/:encryptedPassword', stremioAuthRouter); // For authenticated routes
+1 -1
View File
@@ -27,7 +27,7 @@ export const errorMiddleware = (
let stremioResponse = false;
const match = req.originalUrl.match(
/\/stremio(?:\/[^\/]+){0,2}\/(stream|catalog|subtitles|meta)/
/\/stremio(?:\/[^\/]+){0,2}\/(stream|catalog|subtitles|meta|addon_catalog)/
);
if (match) {
stremioResponse = true;
@@ -22,6 +22,7 @@ const manifest = async (config?: UserData): Promise<Manifest> => {
}
let catalogs: Manifest['catalogs'] = [];
let resources: Manifest['resources'] = [];
let addonCatalogs: Manifest['addonCatalogs'] = [];
if (config) {
const aiostreams = new AIOStreams(config);
@@ -29,6 +30,7 @@ const manifest = async (config?: UserData): Promise<Manifest> => {
catalogs = aiostreams.getCatalogs();
resources = aiostreams.getResources();
addonCatalogs = aiostreams.getAddonCatalogs();
}
return {
name: config?.addonName || Env.ADDON_NAME,
@@ -48,6 +50,7 @@ const manifest = async (config?: UserData): Promise<Manifest> => {
configurable: true,
configurationRequired: config ? false : true,
},
addonCatalogs,
stremioAddonsConfig:
Env.STREMIO_ADDONS_CONFIG_ISSUER && Env.STREMIO_ADDONS_CONFIG_SIGNATURE
? {
+14 -8
View File
@@ -28,17 +28,17 @@ export function createResponse(
const { success, data, error } = options;
let type: string = 'api';
// adapt responses for path specific response types
let stremioResponse = false;
if (adaptResponses && path) {
if (path.match(/\/stremio(?:\/[^\/]+){0,2}\/stream/)) {
type = 'stream';
} else if (path.match(/\/stremio(?:\/[^\/]+){0,2}\/catalog/)) {
type = 'catalog';
} else if (path.match(/\/stremio(?:\/[^\/]+){0,2}\/subtitles/)) {
type = 'subtitles';
} else if (path.match(/\/stremio(?:\/[^\/]+){0,2}\/meta/)) {
type = 'meta';
const match = path?.match(
/\/stremio(?:\/[^\/]+){0,2}\/(stream|catalog|subtitles|meta|addon_catalog)/
);
if (match) {
stremioResponse = true;
type = match[1];
}
}
logger.debug('Creating response object', {
success,
error,
@@ -80,6 +80,12 @@ export function createResponse(
meta: data,
};
}
case 'addon_catalog':
if (success) {
return {
addons: data,
};
}
default:
return {
success,