@@ -3,12 +3,13 @@ package adapter
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "strconv"
7
+ "strings"
8
+
6
9
"github.com/bitmagnet-io/bitmagnet/internal/database/query"
7
10
"github.com/bitmagnet-io/bitmagnet/internal/database/search"
8
11
"github.com/bitmagnet-io/bitmagnet/internal/model"
9
12
"github.com/bitmagnet-io/bitmagnet/internal/torznab"
10
- "strconv"
11
- "strings"
12
13
)
13
14
14
15
func (a adapter ) Search (ctx context.Context , req torznab.SearchRequest ) (torznab.SearchResult , error ) {
@@ -220,18 +221,26 @@ func (a adapter) transformSearchResult(req torznab.SearchRequest, res search.Tor
220
221
AttrValue : item .PublishedAt .Format (torznab .RssDateDefaultFormat ),
221
222
},
222
223
}
223
- if seeders := item .Torrent .Seeders (); seeders .Valid {
224
+ seeders := item .Torrent .Seeders ()
225
+ leechers := item .Torrent .Leechers ()
226
+ if seeders .Valid {
224
227
attrs = append (attrs , torznab.SearchResultItemTorznabAttr {
225
228
AttrName : torznab .AttrSeeders ,
226
229
AttrValue : strconv .Itoa (int (seeders .Uint )),
227
230
})
228
231
}
229
- if leechers := item . Torrent . Leechers (); leechers .Valid {
232
+ if leechers .Valid {
230
233
attrs = append (attrs , torznab.SearchResultItemTorznabAttr {
231
- AttrName : torznab .AttrPeers ,
234
+ AttrName : torznab .AttrLeechers ,
232
235
AttrValue : strconv .Itoa (int (leechers .Uint )),
233
236
})
234
237
}
238
+ if leechers .Valid && seeders .Valid {
239
+ attrs = append (attrs , torznab.SearchResultItemTorznabAttr {
240
+ AttrName : torznab .AttrPeers ,
241
+ AttrValue : strconv .Itoa (int (leechers .Uint ) + int (seeders .Uint )),
242
+ })
243
+ }
235
244
if len (item .Torrent .Files ) > 0 {
236
245
attrs = append (attrs , torznab.SearchResultItemTorznabAttr {
237
246
AttrName : torznab .AttrFiles ,
0 commit comments