From 817d64f2ebdf6c3fd4e6969f20698dcf1a5a0f8d Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Mon, 15 Feb 2021 17:43:03 +0100 Subject: [PATCH] [scraper] disallow rutor russian series without imdb id --- scraper/scrapers/rutor/rutor_scraper.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scraper/scrapers/rutor/rutor_scraper.js b/scraper/scrapers/rutor/rutor_scraper.js index b537353..e7bf485 100644 --- a/scraper/scrapers/rutor/rutor_scraper.js +++ b/scraper/scrapers/rutor/rutor_scraper.js @@ -1,5 +1,6 @@ const moment = require('moment'); const Bottleneck = require('bottleneck'); +const { parse } = require('parse-torrent-title'); const rutor = require('./rutor_api'); const { Type } = require('../../lib/types'); const repository = require('../../lib/repository'); @@ -17,8 +18,7 @@ const TYPE_MAPPING = { 'tv': Type.SERIES, 'multiki': Type.MOVIE, 'anime': Type.ANIME -} -const ALLOWED_WITHOUT_IMDB = ['kino', 'seriali', 'anime']; +}; const api_limiter = new Bottleneck({ maxConcurrent: 1, minTime: 5000 }); const api_entry_limiter = new Bottleneck({ maxConcurrent: 1, minTime: 2500 }); @@ -90,7 +90,7 @@ async function processTorrentRecord(record) { if (!foundTorrent || !TYPE_MAPPING[foundTorrent.category]) { return Promise.resolve(`${NAME}: Invalid torrent record: ${record.torrentId}`); } - if (!foundTorrent.imdbId && !ALLOWED_WITHOUT_IMDB.includes(foundTorrent.category)) { + if (!foundTorrent.imdbId && disallowWithoutImdbId(foundTorrent)) { return Promise.resolve(`${NAME}: No imdbId defined: ${record.torrentId}`); } @@ -122,4 +122,12 @@ function getMaxPage(category) { } } +function disallowWithoutImdbId(torrent) { + if (['kino', 'anime'].includes(torrent.category)) { + return false; // allow to search foreign movie and anime ids via search + } + // allow to search id for non russian series titles via search + return !(torrent.category === 'seriali' && !parse(torrent.title).title.match(/[\u0400-\u04ff]/i)); +} + module.exports = { scrape, updateSeeders, NAME }; \ No newline at end of file