feat(filter): torrents filters (basic maxFiles filter)
This commit is contained in:
@ -447,6 +447,16 @@ const cleanupTorrents = (cleanTorrents = 1) => {
|
||||
*/
|
||||
}
|
||||
|
||||
const checkTorrent = (torrent) => {
|
||||
if(config.filters.maxFiles > 0 && torrent.files > config.filters.maxFiles)
|
||||
{
|
||||
console.log('ignore', torrent.name, 'because files', torrent.files, '>', config.filters.maxFiles)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const insertTorrentToDB = (torrent) => {
|
||||
if(!torrent)
|
||||
return
|
||||
@ -463,6 +473,11 @@ const insertTorrentToDB = (torrent) => {
|
||||
delete torrent.contenttype;
|
||||
}
|
||||
|
||||
if(!checkTorrent(torrent))
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
const { filesList } = torrent
|
||||
delete torrent.filesList;
|
||||
|
||||
@ -533,6 +548,12 @@ const insertTorrentToDB = (torrent) => {
|
||||
})
|
||||
}
|
||||
|
||||
const removeTorrentFromDB = (torrent) => {
|
||||
const {hash} = torrent
|
||||
mysqlSingle.query('DELETE FROM torrents WHERE hash = ?', hash)
|
||||
mysqlSingle.query('DELETE FROM files WHERE hash = ?', hash)
|
||||
}
|
||||
|
||||
const updateTorrent = (metadata, infohash, rinfo) => {
|
||||
console.log('finded torrent', metadata.info.name, ' and add to database');
|
||||
|
||||
@ -713,7 +734,9 @@ API({
|
||||
spider,
|
||||
upnp,
|
||||
crypto,
|
||||
insertTorrentToDB
|
||||
insertTorrentToDB,
|
||||
removeTorrentFromDB,
|
||||
checkTorrent
|
||||
})
|
||||
|
||||
if(config.indexer) {
|
||||
|
||||
Reference in New Issue
Block a user