From 0727da32367b2d5591f5680eeec17aafd04a3aaa Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 18 Jul 2018 09:13:20 +0300 Subject: [PATCH] feat(filters): add size filter --- src/app/filters-page.js | 22 ++++++++++++++++++++++ src/background/config.js | 6 ++++++ src/background/spider.js | 6 ++++++ translations/en.json | 3 ++- translations/ru.json | 3 ++- translations/ua.json | 3 ++- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/app/filters-page.js b/src/app/filters-page.js index 43c999d..5c63cd1 100644 --- a/src/app/filters-page.js +++ b/src/app/filters-page.js @@ -7,6 +7,7 @@ import TextField from 'material-ui/TextField' import Slider from 'material-ui/Slider' import SelectField from 'material-ui/SelectField'; import MenuItem from 'material-ui/MenuItem'; +import InputSize from './input-size'; import fs from 'fs' @@ -128,6 +129,7 @@ export default class ConfigPage extends Page { +
+
+ * - {__('* - enabled means ignoring all adult content')} +
+
+ { + this.options.filters // bug with props + && +
+ { + this.options.filters.size = size + this.options.filters.maxSize = maxSize + this.options.filters.sizeEnabled = enabled + this.forceUpdate() + }} /> +
+ } { this.toRemoveProbably && this.toRemoveProbably > 0 diff --git a/src/background/config.js b/src/background/config.js index 134951b..1cd0a49 100644 --- a/src/background/config.js +++ b/src/background/config.js @@ -47,6 +47,12 @@ let config = { namingRegExp: '', namingRegExpNegative: false, adultFilter: false, + + size: {max: 0, min: 0}, + maxSize: 1024 * 1024 * 1024 * 1024, + sizeEnabled: false, + + contentType: null }, cleanup: true, diff --git a/src/background/spider.js b/src/background/spider.js index db041e3..2a51013 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -427,6 +427,12 @@ app.get('*', function(req, res) return false } + if(config.filters.sizeEnabled && (torrent.size < config.filters.size.min || torrent.size > config.filters.size.max)) + { + console.log('ignore torrent', torrent.name, 'because size bounds of', torrent.size, ':', config.filters.size) + return false + } + return true } diff --git a/translations/en.json b/translations/en.json index 45499e9..73e01f1 100644 --- a/translations/en.json +++ b/translations/en.json @@ -177,6 +177,7 @@ "Serching metadata in progress... Click will delete this torrent.": "Serching metadata in progress... Click will delete this torrent.", "Pause torrent downloading": "Pause torrent downloading", "P2P torrents replication server": "P2P torrents replication server", - "Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)" + "Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)", + "* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content" } } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index 44eb8b9..3956ac5 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -177,6 +177,7 @@ "Serching metadata in progress... Click will delete this torrent.": "Поиск метаданных в процессе... Нажатие удалит этот торрент.", "Pause torrent downloading": "Пауза скачки торрента", "P2P torrents replication server": "Сервер репликация торрентов через p2p", - "Enable torrents replication server for other rats clients (required for replication)": "Включить сервер репликации для остальных крысиных клиентов (необходим для репликации)" + "Enable torrents replication server for other rats clients (required for replication)": "Включить сервер репликации для остальных крысиных клиентов (необходим для репликации)", + "* - enabled means ignoring all adult content": "* - означает игнорирование всего контента для взрослых" } } \ No newline at end of file diff --git a/translations/ua.json b/translations/ua.json index c15b05e..f41bd0d 100644 --- a/translations/ua.json +++ b/translations/ua.json @@ -177,6 +177,7 @@ "Serching metadata in progress... Click will delete this torrent.": "Serching metadata in progress... Click will delete this torrent.", "Pause torrent downloading": "Pause torrent downloading", "P2P torrents replication server": "P2P torrents replication server", - "Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)" + "Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)", + "* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content" } } \ No newline at end of file