mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(filters): implement min and max seeders/leechers filtering for Torznab feeds (#1342)
* feat(filter):implement min and max seeders/leechers filtering * chore: go fmt and reorder fields --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
256fbb49ba
commit
a86258aaa7
10 changed files with 192 additions and 3 deletions
|
@ -114,6 +114,18 @@ func (j *TorznabJob) process(ctx context.Context) error {
|
|||
|
||||
rls.ParseString(item.Title)
|
||||
|
||||
rls.Seeders, err = parseIntAttribute(item, "seeders")
|
||||
if err != nil {
|
||||
rls.Seeders = 0
|
||||
}
|
||||
|
||||
var peers, err = parseIntAttribute(item, "peers")
|
||||
|
||||
rls.Leechers = peers - rls.Seeders
|
||||
if err != nil {
|
||||
rls.Leechers = 0
|
||||
}
|
||||
|
||||
if j.Feed.Settings != nil && j.Feed.Settings.DownloadType == domain.FeedDownloadTypeMagnet {
|
||||
rls.MagnetURI = item.Link
|
||||
rls.DownloadURL = ""
|
||||
|
@ -152,6 +164,20 @@ func (j *TorznabJob) process(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func parseIntAttribute(item torznab.FeedItem, attrName string) (int, error) {
|
||||
for _, attr := range item.Attributes {
|
||||
if attr.Name == attrName {
|
||||
// Parse the value as decimal number
|
||||
intValue, err := strconv.Atoi(attr.Value)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return intValue, err
|
||||
}
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Parse the downloadvolumefactor attribute. The returned value is the percentage
|
||||
// of downloaded data that does NOT count towards a user's total download amount.
|
||||
func parseFreeleechTorznab(item torznab.FeedItem) (int, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue