базовая пометка запрещенного контента

This commit is contained in:
Alexey Kasyanchuk
2017-01-05 12:08:15 +03:00
parent a100575779
commit db5d53ebc7
5 changed files with 281 additions and 6 deletions

View File

@ -173,6 +173,24 @@ const ExtesionBase = {
const ContentTypeProp = 'contentType';
const ContentCategoryProp = 'contentCategory';
const XXX_BLOCK_WORDS = require('./bad-words');
const detectSubCategory = (torrent, files, typesPriority, contentType) => {
let name = torrent.name.toLowerCase()
// блокируем порнографию
if(contentType == ContentTypes.VIDEO)
{
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 fileDetect = (file) => {
let name = file.path.split('/').pop();
let extension = name.split('.').pop();
@ -180,13 +198,12 @@ const fileDetect = (file) => {
return;
if(extension.length == 0)
return;
extension = extension.toLowerCase();
return ExtesionBase[extension];
}
const torrentTypeDetect = (torrent, files) => {
let name = torrent.name;
let typesPriority = {};
for(let i = 0; i < files.length; i++) {
@ -205,6 +222,8 @@ const torrentTypeDetect = (torrent, files) => {
});
if(priority.length > 0)
torrent[ContentTypeProp] = priority[0];
detectSubCategory(torrent, files, typesPriority, torrent[ContentTypeProp]);
}
module.exports = torrentTypeDetect;