mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
feat(indexers): irc parse support ignoring lines (#641)
feat(indexers): irc support ignore line
This commit is contained in:
parent
e014528c97
commit
626fa6f156
3 changed files with 16 additions and 4 deletions
|
@ -79,7 +79,7 @@ func (a *announceProcessor) processQueue(queue chan string) {
|
||||||
|
|
||||||
// check should ignore
|
// check should ignore
|
||||||
|
|
||||||
match, err := a.parseLine(parseLine.Pattern, parseLine.Vars, tmpVars, line)
|
match, err := a.parseLine(parseLine.Pattern, parseLine.Vars, tmpVars, line, parseLine.Ignore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.log.Error().Err(err).Msgf("error parsing extract for line: %v", line)
|
a.log.Error().Err(err).Msgf("error parsing extract for line: %v", line)
|
||||||
|
|
||||||
|
@ -135,12 +135,12 @@ func (a *announceProcessor) AddLineToQueue(channel string, line string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *announceProcessor) parseLine(pattern string, vars []string, tmpVars map[string]string, line string) (bool, error) {
|
func (a *announceProcessor) parseLine(pattern string, vars []string, tmpVars map[string]string, line string, ignore bool) (bool, error) {
|
||||||
if len(vars) > 0 {
|
if len(vars) > 0 {
|
||||||
return a.parseExtract(pattern, vars, tmpVars, line)
|
return a.parseExtract(pattern, vars, tmpVars, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.parseMatchRegexp(pattern, tmpVars, line)
|
return a.parseMatchRegexp(pattern, tmpVars, line, ignore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *announceProcessor) parseExtract(pattern string, vars []string, tmpVars map[string]string, line string) (bool, error) {
|
func (a *announceProcessor) parseExtract(pattern string, vars []string, tmpVars map[string]string, line string) (bool, error) {
|
||||||
|
@ -168,12 +168,17 @@ func (a *announceProcessor) parseExtract(pattern string, vars []string, tmpVars
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *announceProcessor) parseMatchRegexp(pattern string, tmpVars map[string]string, line string) (bool, error) {
|
func (a *announceProcessor) parseMatchRegexp(pattern string, tmpVars map[string]string, line string, ignore bool) (bool, error) {
|
||||||
var re = regexp.MustCompile(`(?mi)` + pattern)
|
var re = regexp.MustCompile(`(?mi)` + pattern)
|
||||||
|
|
||||||
groupNames := re.SubexpNames()
|
groupNames := re.SubexpNames()
|
||||||
for _, match := range re.FindAllStringSubmatch(line, -1) {
|
for _, match := range re.FindAllStringSubmatch(line, -1) {
|
||||||
for groupIdx, group := range match {
|
for groupIdx, group := range match {
|
||||||
|
// if line should be ignored then lets return
|
||||||
|
if ignore {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
name := groupNames[groupIdx]
|
name := groupNames[groupIdx]
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = "raw"
|
name = "raw"
|
||||||
|
|
|
@ -172,6 +172,7 @@ type IndexerIRCParseLine struct {
|
||||||
Test []string `json:"test"`
|
Test []string `json:"test"`
|
||||||
Pattern string `json:"pattern"`
|
Pattern string `json:"pattern"`
|
||||||
Vars []string `json:"vars"`
|
Vars []string `json:"vars"`
|
||||||
|
Ignore bool `json:"ignore"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IndexerIRCParseMatch struct {
|
type IndexerIRCParseMatch struct {
|
||||||
|
|
|
@ -63,6 +63,11 @@ irc:
|
||||||
parse:
|
parse:
|
||||||
type: multi
|
type: multi
|
||||||
lines:
|
lines:
|
||||||
|
- test:
|
||||||
|
- "New torrent uploaded!"
|
||||||
|
pattern: '^New torrent uploaded!$'
|
||||||
|
ignore: true
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
- "Title: Dragons Forever | Year: 1988 | URL: https://pixelhd.me/torrents.php?torrentid=23001"
|
- "Title: Dragons Forever | Year: 1988 | URL: https://pixelhd.me/torrents.php?torrentid=23001"
|
||||||
pattern: 'Title: (.*) \| Year: (.*) \| URL: (https?:\/\/.*\/).+id=(.+)'
|
pattern: 'Title: (.*) \| Year: (.*) \| URL: (https?:\/\/.*\/).+id=(.+)'
|
||||||
|
@ -71,6 +76,7 @@ irc:
|
||||||
- year
|
- year
|
||||||
- baseUrl
|
- baseUrl
|
||||||
- torrentId
|
- torrentId
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
- "Uploader: Anon | Release Group: Px4K | Format: MP4 | Genre(s): action,comedy,romance"
|
- "Uploader: Anon | Release Group: Px4K | Format: MP4 | Genre(s): action,comedy,romance"
|
||||||
pattern: 'Uploader: (.*) \| Release Group: (.*) \| Format: (.*) \| Genre\(s\): (.*)'
|
pattern: 'Uploader: (.*) \| Release Group: (.*) \| Format: (.*) \| Genre\(s\): (.*)'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue