блокирование так же по названиям файлов

This commit is contained in:
Alexey Kasyanchuk 2017-01-23 23:00:09 +03:00
parent ccfd5f4734
commit c9f901b0f4

View File

@ -236,19 +236,36 @@ const ContentCategoryProp = 'contentCategory';
const XXX_BLOCK_WORDS = require('./bad-words'); 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) => { const detectSubCategory = (torrent, files, typesPriority, contentType) => {
let name = torrent.name.toLowerCase() let name = torrent.name.toLowerCase()
// блокируем порнографию // блокируем порнографию
if(contentType == ContentTypes.VIDEO) if(contentType == ContentTypes.VIDEO || contentType == ContentTypes.PICTURES)
{ {
let splitName = name.split(/[`~!@#$%^&*()\]\[{}.,+?/\\;:\-_' "|]/); blockBadName(torrent, name);
splitName.some((word) => { // блокируем так по названию файлов
if (XXX_BLOCK_WORDS.some(function(v) { return word == v; })) { if(torrent[ContentCategoryProp] != 'xxx')
torrent[ContentCategoryProp] = 'xxx'; {
} files.some(({path}) => {
return torrent[ContentCategoryProp] == 'xxx'; blockBadName(torrent, path.toLowerCase());
}) if(torrent[ContentCategoryProp] == 'xxx')
{
console.log('block because file' + path);
}
return torrent[ContentCategoryProp] == 'xxx';
})
}
} }
} }