From 429263e61e8590a9a74bb189c6f3d45c1975ad64 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Sun, 2 Sep 2018 22:05:39 +0300 Subject: [PATCH] feat(rutor): category rutor --- src/background/strategies/rutor.js | 14 +++++++++++++- tests/strategies/rutor.test.js | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/background/strategies/rutor.js b/src/background/strategies/rutor.js index 25704ee..f6b77fc 100644 --- a/src/background/strategies/rutor.js +++ b/src/background/strategies/rutor.js @@ -127,11 +127,23 @@ module.exports = class Rutor if(!topicTitle) return + let contentCategory + $('#details tr').each(function(i, elem) { + const row = $(this) + const field = row.find('td.header').text() + if(field == 'Категория') + { + contentCategory = row.find('td').next().text().trim() + } + }); + + return { name: topicTitle, poster: $('#details tbody img').attr('src'), description: $('#details tbody').first().text(), - rutorThreadId: parseInt(id) + rutorThreadId: parseInt(id), + contentCategory } } diff --git a/tests/strategies/rutor.test.js b/tests/strategies/rutor.test.js index dc2a079..f127b04 100644 --- a/tests/strategies/rutor.test.js +++ b/tests/strategies/rutor.test.js @@ -15,6 +15,7 @@ describe("rutor", () => { const data = await rutor.findHash('158448f6afbedb079aaf3c4695fb43e7dfa54515') assert.equal(data.name, 'Наруто: Ураганные Хроники / Naruto Shippuuden Movie [4 фильм] (2007) DVDRip') assert.equal(data.rutorThreadId, 5850) + assert.equal(data.contentCategory, 'Аниме') }) it("notFound", async function() {