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

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