Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -10,11 +10,6 @@ const handlers = require('./handlers');
|
|
| 10 |
const { queryBuilder, transformModel, validate, parseTorrent } = require('./commons');
|
| 11 |
const { env } = require('./config');
|
| 12 |
|
| 13 |
-
// Import Catalog, Meta, and Stream modules
|
| 14 |
-
const Catalog = require('./catalog');
|
| 15 |
-
const Meta = require('./meta');
|
| 16 |
-
const Stream = require('./stream');
|
| 17 |
-
|
| 18 |
// Log the environment variables to ensure they load correctly
|
| 19 |
console.log("Environment Variables Loaded:");
|
| 20 |
console.log("SEARCH_URL:", process.env.SEARCH_URL);
|
|
@@ -24,19 +19,7 @@ console.log("STREAM_URL:", process.env.STREAM_URL);
|
|
| 24 |
|
| 25 |
const PORT = process.env.PORT || env.port;
|
| 26 |
|
| 27 |
-
//
|
| 28 |
-
const dependencies = {
|
| 29 |
-
httpClient: axios,
|
| 30 |
-
env: {
|
| 31 |
-
url: {
|
| 32 |
-
search: 'https://archive.org/advancedsearch.php',
|
| 33 |
-
metadata: 'https://archive.org/metadata',
|
| 34 |
-
stream: 'https://archive.org/download',
|
| 35 |
-
},
|
| 36 |
-
},
|
| 37 |
-
};
|
| 38 |
-
|
| 39 |
-
// Initialize handlers with the dependencies and use cases
|
| 40 |
const { searchCatalog, getMeta, getStreams } = handlers({
|
| 41 |
env,
|
| 42 |
...transformModel({ env, ...parseTorrent() }),
|
|
@@ -48,7 +31,6 @@ const { searchCatalog, getMeta, getStreams } = handlers({
|
|
| 48 |
}),
|
| 49 |
});
|
| 50 |
|
| 51 |
-
// Initialize add-on builder with environment
|
| 52 |
const addon = builder({ env });
|
| 53 |
|
| 54 |
// Define the Catalog Handler
|
|
@@ -57,7 +39,6 @@ addon.defineCatalogHandler(async (args) => {
|
|
| 57 |
console.log("Extra Arguments:", args.extra);
|
| 58 |
|
| 59 |
try {
|
| 60 |
-
// Get the query using the queryBuilder from the dependencies
|
| 61 |
const query = queryBuilder(args);
|
| 62 |
console.log("Generated Lucene Query:", query);
|
| 63 |
|
|
@@ -84,11 +65,10 @@ addon.defineCatalogHandler(async (args) => {
|
|
| 84 |
return { metas: [] };
|
| 85 |
}
|
| 86 |
|
| 87 |
-
// Map the response to the required metadata for Stremio
|
| 88 |
const metas = response.data.response.docs.map((item) => ({
|
| 89 |
id: item.identifier,
|
| 90 |
name: item.title || "Unknown Title",
|
| 91 |
-
poster:
|
| 92 |
type: 'movie',
|
| 93 |
}));
|
| 94 |
|
|
@@ -98,7 +78,5 @@ addon.defineCatalogHandler(async (args) => {
|
|
| 98 |
console.error("Error in Catalog Handler:", error.response?.data || error.message); // Improved error logging
|
| 99 |
return { metas: [] };
|
| 100 |
}
|
| 101 |
-
});
|
| 102 |
|
| 103 |
-
// Start the server
|
| 104 |
-
server.serve({ port: PORT });
|
|
|
|
| 10 |
const { queryBuilder, transformModel, validate, parseTorrent } = require('./commons');
|
| 11 |
const { env } = require('./config');
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
// Log the environment variables to ensure they load correctly
|
| 14 |
console.log("Environment Variables Loaded:");
|
| 15 |
console.log("SEARCH_URL:", process.env.SEARCH_URL);
|
|
|
|
| 19 |
|
| 20 |
const PORT = process.env.PORT || env.port;
|
| 21 |
|
| 22 |
+
// Initialize handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
const { searchCatalog, getMeta, getStreams } = handlers({
|
| 24 |
env,
|
| 25 |
...transformModel({ env, ...parseTorrent() }),
|
|
|
|
| 31 |
}),
|
| 32 |
});
|
| 33 |
|
|
|
|
| 34 |
const addon = builder({ env });
|
| 35 |
|
| 36 |
// Define the Catalog Handler
|
|
|
|
| 39 |
console.log("Extra Arguments:", args.extra);
|
| 40 |
|
| 41 |
try {
|
|
|
|
| 42 |
const query = queryBuilder(args);
|
| 43 |
console.log("Generated Lucene Query:", query);
|
| 44 |
|
|
|
|
| 65 |
return { metas: [] };
|
| 66 |
}
|
| 67 |
|
|
|
|
| 68 |
const metas = response.data.response.docs.map((item) => ({
|
| 69 |
id: item.identifier,
|
| 70 |
name: item.title || "Unknown Title",
|
| 71 |
+
poster: ${process.env.IMAGE_URL}/${item.identifier},
|
| 72 |
type: 'movie',
|
| 73 |
}));
|
| 74 |
|
|
|
|
| 78 |
console.error("Error in Catalog Handler:", error.response?.data || error.message); // Improved error logging
|
| 79 |
return { metas: [] };
|
| 80 |
}
|
| 81 |
+
});
|
| 82 |
|
|
|
|
|
|