mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-20 14:12:03 +00:00
add limiter options
This commit is contained in:
parent
94ec4a7a52
commit
8a4eb4cdfe
1 changed files with 2 additions and 1 deletions
|
|
@ -22,13 +22,14 @@ const limiter = new Bottleneck({
|
||||||
highWater: process.env.LIMIT_QUEUE_SIZE || 220,
|
highWater: process.env.LIMIT_QUEUE_SIZE || 220,
|
||||||
strategy: Bottleneck.strategy.OVERFLOW
|
strategy: Bottleneck.strategy.OVERFLOW
|
||||||
});
|
});
|
||||||
|
const limiterOptions = { expiration: 2 * 60 * 1000 }
|
||||||
|
|
||||||
builder.defineStreamHandler((args) => {
|
builder.defineStreamHandler((args) => {
|
||||||
if (!args.id.match(/tt\d+/i) && !args.id.match(/kitsu:\d+/i)) {
|
if (!args.id.match(/tt\d+/i) && !args.id.match(/kitsu:\d+/i)) {
|
||||||
return Promise.resolve({ streams: [] });
|
return Promise.resolve({ streams: [] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return cacheWrapStream(args.id, () => limiter.schedule(() => streamHandler(args)
|
return cacheWrapStream(args.id, () => limiter.schedule(limiterOptions, () => streamHandler(args)
|
||||||
.then(records => records
|
.then(records => records
|
||||||
.sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate)
|
.sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate)
|
||||||
.map(record => toStreamInfo(record)))))
|
.map(record => toStreamInfo(record)))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue