From c9f901b0f47950d87bf82f869b242d678338fe3d Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Mon, 23 Jan 2017 23:00:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B0=D0=BA=20=D0=B6?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=D0=BC=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/content.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/content.js b/lib/content.js index 0f56fa3..0bcfcde 100644 --- a/lib/content.js +++ b/lib/content.js @@ -236,19 +236,36 @@ const ContentCategoryProp = 'contentCategory'; const XXX_BLOCK_WORDS = require('./bad-words'); +// блокируем порнографию +const blockBadName = (torrent, name) => { + let splitName = name.split(/[`~!@#$%^&*()\]\[{}.,+?/\\;:\-_' "|]/); + splitName.some((word) => { + if (XXX_BLOCK_WORDS.some(function(v) { return word == v; })) { + torrent[ContentCategoryProp] = 'xxx'; + } + return torrent[ContentCategoryProp] == 'xxx'; + }) +} + const detectSubCategory = (torrent, files, typesPriority, contentType) => { let name = torrent.name.toLowerCase() // блокируем порнографию - if(contentType == ContentTypes.VIDEO) + if(contentType == ContentTypes.VIDEO || contentType == ContentTypes.PICTURES) { - let splitName = name.split(/[`~!@#$%^&*()\]\[{}.,+?/\\;:\-_' "|]/); - splitName.some((word) => { - if (XXX_BLOCK_WORDS.some(function(v) { return word == v; })) { - torrent[ContentCategoryProp] = 'xxx'; - } - return torrent[ContentCategoryProp] == 'xxx'; - }) + blockBadName(torrent, name); + // блокируем так по названию файлов + if(torrent[ContentCategoryProp] != 'xxx') + { + files.some(({path}) => { + blockBadName(torrent, path.toLowerCase()); + if(torrent[ContentCategoryProp] == 'xxx') + { + console.log('block because file' + path); + } + return torrent[ContentCategoryProp] == 'xxx'; + }) + } } }