[addon] remove cache control
This commit is contained in:
@@ -5,6 +5,7 @@ const GLOBAL_KEY_PREFIX = 'torrentio-addon';
|
|||||||
const STREAM_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|stream`;
|
const STREAM_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|stream`;
|
||||||
const REALDEBRID_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|realdebrid`;
|
const REALDEBRID_KEY_PREFIX = `${GLOBAL_KEY_PREFIX}|realdebrid`;
|
||||||
|
|
||||||
|
const REDIRECT_TTL = process.env.STREAM_EMPTY_TTL || 2 * 60; // 2 hours
|
||||||
const STREAM_TTL = process.env.STREAM_TTL || 4 * 60 * 60; // 4 hours
|
const STREAM_TTL = process.env.STREAM_TTL || 4 * 60 * 60; // 4 hours
|
||||||
const STREAM_EMPTY_TTL = process.env.STREAM_EMPTY_TTL || 30 * 60; // 30 minutes
|
const STREAM_EMPTY_TTL = process.env.STREAM_EMPTY_TTL || 30 * 60; // 30 minutes
|
||||||
// When the streams are empty we want to cache it for less time in case of timeouts or failures
|
// When the streams are empty we want to cache it for less time in case of timeouts or failures
|
||||||
@@ -58,7 +59,7 @@ function cacheWrapStream(id, method) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cacheWrapUnrestricted(id, method) {
|
function cacheWrapUnrestricted(id, method) {
|
||||||
return cacheWrap(memoryCache, `${REALDEBRID_KEY_PREFIX}:${id}`, method, { ttl: 60 });
|
return cacheWrap(memoryCache, `${REALDEBRID_KEY_PREFIX}:${id}`, method, { ttl: REDIRECT_TTL });
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { cacheWrapStream, cacheWrapUnrestricted };
|
module.exports = { cacheWrapStream, cacheWrapUnrestricted };
|
||||||
|
|||||||
@@ -69,16 +69,13 @@ router.get('/:configuration/:resource/:type/:id.json', (req, res, next) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/realdebrid/:apiKey/:infoHash/:fileIndex?.json', (req, res) => {
|
router.get('/realdebrid/:apiKey/:infoHash/:fileIndex?', (req, res) => {
|
||||||
const { apiKey, infoHash, fileIndex } = req.params;
|
const { apiKey, infoHash, fileIndex } = req.params;
|
||||||
console.time(infoHash);
|
console.time(infoHash);
|
||||||
realDebrid.unrestrict(apiKey, infoHash, isNaN(fileIndex) ? undefined : parseInt(fileIndex))
|
realDebrid.unrestrict(apiKey, infoHash, isNaN(fileIndex) ? undefined : parseInt(fileIndex))
|
||||||
.then(url => {
|
.then(url => {
|
||||||
console.timeEnd(infoHash);
|
console.timeEnd(infoHash);
|
||||||
res.writeHead(301, {
|
res.writeHead(301, { Location: url });
|
||||||
'Location': url,
|
|
||||||
'Cache-Control': 'max-age=7200, public'
|
|
||||||
});
|
|
||||||
res.end();
|
res.end();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user