const { serveHTTP } = require("stremio-addon-sdk"); const addonInterface = require("./addon"); // Use STREMIO_BIND_ADDR if available (for Stremio system addons) const bindAddr = process.env.STREMIO_BIND_ADDR || "127.0.0.1"; const PORT = process.env.PORT || 59627; // Start the server with minimal caching serveHTTP(addonInterface, { port: PORT, bindAddr: bindAddr, cacheMaxAge: 5 * 60, // 5 minutes getRouter: (addonInterface) => { const router = serveHTTP.getRouter(addonInterface); // Add healthcheck route router.get('/health', (req, res) => { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({ status: 'ok' })); }); return router; } }); console.log(`\n=== STREMIO YOUTUBE DOCUMENTARIES ADDON ===`); console.log(`📡 Addon server started on: http://${bindAddr}:${PORT}`); console.log(`🔗 Add to Stremio: http://${bindAddr}:${PORT}/manifest.json`); console.log(`🎬 Default catalog: http://${bindAddr}:${PORT}/catalog/movie/ytdocs.json`); console.log(`🎭 Categories: http://${bindAddr}:${PORT}/catalog/movie/ytdocs/genre=nature.json`); console.log(`💡 Search: http://${bindAddr}:${PORT}/catalog/movie/ytdocs/search=conspiracy.json`); console.log(`⚙️ Using YouTube API key: ${process.env.YT_API_KEY ? "From environment" : "Default"}`); console.log(`===========================================\n`);