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'; + }) + } } }