Skip to content

Commit

Permalink
feat(filtering): negative name filter
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed May 16, 2018
1 parent 5552284 commit b16ca68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/app/filters-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,21 @@ export default class ConfigPage extends Page {
>
<MenuItem value={String.raw`^[А-Яа-я0-9A-Za-z.!@?#"$%&:;() *\+,\/;\-=[\\\]\^_{|}<>\u0400-\u04FF]+$`} primaryText="Russian + English only (With symbols)" />
<MenuItem value={'^[0-9A-Za-z.!@?#"$%&:;() *\+,\/;\-=[\\\]\^_{|}<>]+$'} primaryText="English only (With symbols)" />
<MenuItem value={'^((?!badword).)*$'} primaryText="Ignore badword" />
</SelectField>
</div>
<Toggle
style={{marginTop: '10px'}}
label="Negative regular extension filtering"
toggled={this.options.filters && this.options.filters.namingRegExpNegative}
onToggle={(e, checked) => {
if(!this.options.filters)
return

this.options.filters.namingRegExpNegative = checked
this.forceUpdate()
}}
/>
<div className='fs0-75' style={{color: 'grey'}}>
* - clean string means disabled
</div>
Expand Down
1 change: 1 addition & 0 deletions src/background/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ let config = {
filters: {
maxFiles: 0,
namingRegExp: '',
namingRegExpNegative: false,
adultFilter: false,
},

Expand Down
7 changes: 6 additions & 1 deletion src/background/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,16 @@ const checkTorrent = (torrent) => {
if(nameRX && nameRX.length > 0)
{
const rx = new RegExp(nameRX)
if(!rx.test(torrent.name))
if(!config.filters.namingRegExpNegative && !rx.test(torrent.name))
{
console.log('ignore', torrent.name, 'by naming rx')
return false
}
else if(config.filters.namingRegExpNegative && rx.test(torrent.name))
{
console.log('ignore', torrent.name, 'by naming rx negative')
return false
}
}

if(torrent.contentType === 'bad')
Expand Down

0 comments on commit b16ca68

Please sign in to comment.