mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] reduces number of calls to 1337x
This commit is contained in:
@@ -163,13 +163,10 @@ function getProvider(provider) {
|
||||
}
|
||||
|
||||
function getTorrent(torrent) {
|
||||
return Torrent.findByPk(torrent.infoHash)
|
||||
.then((result) => {
|
||||
if (!result) {
|
||||
throw new Error(`torrent not found: ${torrent.infoHash}`);
|
||||
}
|
||||
return result;
|
||||
})
|
||||
const where = torrent.infoHash
|
||||
? { infoHash: torrent.infoHash }
|
||||
: { provider: torrent.provider, torrentId: torrent.torrentId }
|
||||
return Torrent.findOne({ where: where });
|
||||
}
|
||||
|
||||
function getTorrentsBasedOnTitle(titleQuery, type) {
|
||||
@@ -212,10 +209,13 @@ function createTorrent(torrent) {
|
||||
.then(() => createSubtitles(torrent.infoHash, torrent.subtitles));
|
||||
}
|
||||
|
||||
function setTorrentSeeders(infoHash, seeders) {
|
||||
function setTorrentSeeders(torrent, seeders) {
|
||||
const where = torrent.infoHash
|
||||
? { infoHash: torrent.infoHash }
|
||||
: { provider: torrent.provider, torrentId: torrent.torrentId }
|
||||
return Torrent.update(
|
||||
{ seeders: seeders },
|
||||
{ where: { infoHash: infoHash } }
|
||||
{ where: where }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user