Add attr to differentiate trackers for future

This commit is contained in:
Alexander
2026-05-06 21:42:05 +02:00
parent b8fcbacb07
commit 5fa46b2890
3 changed files with 27 additions and 26 deletions
Generated
+9 -9
View File
@@ -21,11 +21,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1775087534, "lastModified": 1777988971,
"narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", "narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", "rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -93,11 +93,11 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1774748309, "lastModified": 1777168982,
"narHash": "sha256-+U7gF3qxzwD5TZuANzZPeJTZRHS29OFQgkQ2kiTJBIQ=", "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs.lib", "repo": "nixpkgs.lib",
"rev": "333c4e0545a6da976206c74db8773a1645b5870a", "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -108,11 +108,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1777386324, "lastModified": 1778095059,
"narHash": "sha256-ItxAnpJ3qffijuQzMv72I9v/yi1nWHr67hqQaVuQV6c=", "narHash": "sha256-LW2nru9+O0oyR3lfzgzFLwTibhINoIL/dx2/1dBMKWU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a6c2d4f65f850a9fa8977da543f8f9949d4a1527", "rev": "94a37dc9da62b41f0c70a91da739bc318d049c11",
"type": "github" "type": "github"
}, },
"original": { "original": {
+8 -7
View File
@@ -12,6 +12,10 @@ type SearchResult struct {
Items []Item `xml:"channel>item"` Items []Item `xml:"channel>item"`
} }
type JackettIndexer struct {
ID string `xml:"id,attr"`
}
type Item struct { type Item struct {
Title string `xml:"title"` Title string `xml:"title"`
Link string `xml:"link"` Link string `xml:"link"`
@@ -22,6 +26,7 @@ type Item struct {
Categories []string `xml:"category"` Categories []string `xml:"category"`
Enclosure Enclosure `xml:"enclosure"` Enclosure Enclosure `xml:"enclosure"`
TorznabAttrs []TorznabAttr `xml:"attr"` TorznabAttrs []TorznabAttr `xml:"attr"`
JackettIndexer JackettIndexer `xml:"jackettindexer"`
} }
type Enclosure struct { type Enclosure struct {
@@ -36,18 +41,13 @@ type TorznabAttr struct {
} }
var ( var (
parserFactory = rutracker.NewParserFactory() rutrackerParserFactory = rutracker.NewRuTrackerParserFactory()
filter = rutracker.NewFilter()
) )
func (sr *SearchResult) ToProto() *pb.SearchResponse { func (sr *SearchResult) ToProto() *pb.SearchResponse {
var pbItems []*pb.SearchItem var pbItems []*pb.SearchItem
for _, item := range sr.Items { for _, item := range sr.Items {
if !filter.IsKnownCategory(item.Categories) {
continue
}
pbAttrs := make([]*pb.TorznabAttr, len(item.TorznabAttrs)) pbAttrs := make([]*pb.TorznabAttr, len(item.TorznabAttrs))
for j, attr := range item.TorznabAttrs { for j, attr := range item.TorznabAttrs {
pbAttrs[j] = &pb.TorznabAttr{ pbAttrs[j] = &pb.TorznabAttr{
@@ -56,7 +56,8 @@ func (sr *SearchResult) ToProto() *pb.SearchResponse {
} }
} }
release := parserFactory.GetParser(item.Categories).Parse(item.Title) // TODO add the check from what tracker the result is to properly get the parser and thus parse it
release := rutrackerParserFactory.GetParser(item.Categories).Parse(item.Title)
pbItems = append(pbItems, &pb.SearchItem{ pbItems = append(pbItems, &pb.SearchItem{
Title: item.Title, Title: item.Title,
+1 -1
View File
@@ -72,7 +72,7 @@ type ParserFactory struct {
parsers map[parserType]tracker.Parser parsers map[parserType]tracker.Parser
} }
func NewParserFactory() *ParserFactory { func NewRuTrackerParserFactory() *ParserFactory {
return &ParserFactory{ return &ParserFactory{
parsers: map[parserType]tracker.Parser{ parsers: map[parserType]tracker.Parser{
parserGeneral: parser.NewGeneralParser(), parserGeneral: parser.NewGeneralParser(),