mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] moves rd resolver to addon
This commit is contained in:
@@ -4,6 +4,7 @@ const addonInterface = require('./addon');
|
||||
const { manifest } = require('./lib/manifest');
|
||||
const parseConfiguration = require('./lib/configuration');
|
||||
const landingTemplate = require('./lib/landingTemplate');
|
||||
const realDebrid = require('./moch/realdebrid');
|
||||
|
||||
const router = getRouter(addonInterface);
|
||||
const limiter = rateLimit({
|
||||
@@ -68,6 +69,20 @@ router.get('/:configuration/:resource/:type/:id.json', (req, res, next) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/realdebrid/:apiKey/:infoHash/:cachedFileIds/:fileIndex?', (req, res) => {
|
||||
const { apiKey, infoHash, cachedFileIds, fileIndex } = req.params;
|
||||
realDebrid.resolve(apiKey, infoHash, cachedFileIds, isNaN(fileIndex) ? undefined : parseInt(fileIndex))
|
||||
.then(url => {
|
||||
res.writeHead(301, { Location: url });
|
||||
res.end();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
res.statusCode = 404;
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = function (req, res) {
|
||||
router(req, res, function () {
|
||||
res.statusCode = 404;
|
||||
|
||||
Reference in New Issue
Block a user