mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] adds experimental realdebrid support for cached torrents
This commit is contained in:
@@ -4,8 +4,9 @@ const addonInterface = require('./addon');
|
||||
const { manifest } = require('./lib/manifest');
|
||||
const parseConfiguration = require('./lib/configuration');
|
||||
const landingTemplate = require('./lib/landingTemplate');
|
||||
const router = getRouter(addonInterface);
|
||||
const realDebrid = require('./moch/realdebrid');
|
||||
|
||||
const router = getRouter(addonInterface);
|
||||
const limiter = rateLimit({
|
||||
windowMs: 10 * 1000, // 10 seconds
|
||||
max: 10, // limit each IP to 10 requests per windowMs
|
||||
@@ -68,6 +69,20 @@ router.get('/:configuration/:resource/:type/:id.json', (req, res, next) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/realdebrid/:apiKey/:infoHash/:fileIndex?', (req, res) => {
|
||||
const { apiKey, infoHash, fileIndex } = req.params;
|
||||
console.time(infoHash);
|
||||
realDebrid.unrestrict(apiKey, infoHash, isNaN(fileIndex) ? undefined : parseInt(fileIndex))
|
||||
.then(url => {
|
||||
console.timeEnd(infoHash);
|
||||
res.redirect(301, url)
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
res.sendStatus(404);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = function (req, res) {
|
||||
router(req, res, function () {
|
||||
res.statusCode = 404;
|
||||
|
||||
Reference in New Issue
Block a user