базовая пометка запрещенного контента
This commit is contained in:
@ -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;
|
Reference in New Issue
Block a user