Add attr to differentiate trackers for future
This commit is contained in:
Generated
+9
-9
@@ -21,11 +21,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775087534,
|
||||
"narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=",
|
||||
"lastModified": 1777988971,
|
||||
"narHash": "sha256-qIoWPDs+0/8JecyYgE3gpKQxW/4bLW/gp45vow9ioCQ=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b",
|
||||
"rev": "0678d8986be1661af6bb555f3489f2fdfc31f6ff",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -93,11 +93,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1774748309,
|
||||
"narHash": "sha256-+U7gF3qxzwD5TZuANzZPeJTZRHS29OFQgkQ2kiTJBIQ=",
|
||||
"lastModified": 1777168982,
|
||||
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "333c4e0545a6da976206c74db8773a1645b5870a",
|
||||
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -108,11 +108,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1777386324,
|
||||
"narHash": "sha256-ItxAnpJ3qffijuQzMv72I9v/yi1nWHr67hqQaVuQV6c=",
|
||||
"lastModified": 1778095059,
|
||||
"narHash": "sha256-LW2nru9+O0oyR3lfzgzFLwTibhINoIL/dx2/1dBMKWU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a6c2d4f65f850a9fa8977da543f8f9949d4a1527",
|
||||
"rev": "94a37dc9da62b41f0c70a91da739bc318d049c11",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
+17
-16
@@ -12,16 +12,21 @@ type SearchResult struct {
|
||||
Items []Item `xml:"channel>item"`
|
||||
}
|
||||
|
||||
type JackettIndexer struct {
|
||||
ID string `xml:"id,attr"`
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
Title string `xml:"title"`
|
||||
Link string `xml:"link"`
|
||||
Guid string `xml:"guid"`
|
||||
PubDate string `xml:"pubDate"`
|
||||
Size int64 `xml:"size"`
|
||||
Description string `xml:"description"`
|
||||
Categories []string `xml:"category"`
|
||||
Enclosure Enclosure `xml:"enclosure"`
|
||||
TorznabAttrs []TorznabAttr `xml:"attr"`
|
||||
Title string `xml:"title"`
|
||||
Link string `xml:"link"`
|
||||
Guid string `xml:"guid"`
|
||||
PubDate string `xml:"pubDate"`
|
||||
Size int64 `xml:"size"`
|
||||
Description string `xml:"description"`
|
||||
Categories []string `xml:"category"`
|
||||
Enclosure Enclosure `xml:"enclosure"`
|
||||
TorznabAttrs []TorznabAttr `xml:"attr"`
|
||||
JackettIndexer JackettIndexer `xml:"jackettindexer"`
|
||||
}
|
||||
|
||||
type Enclosure struct {
|
||||
@@ -36,18 +41,13 @@ type TorznabAttr struct {
|
||||
}
|
||||
|
||||
var (
|
||||
parserFactory = rutracker.NewParserFactory()
|
||||
filter = rutracker.NewFilter()
|
||||
rutrackerParserFactory = rutracker.NewRuTrackerParserFactory()
|
||||
)
|
||||
|
||||
func (sr *SearchResult) ToProto() *pb.SearchResponse {
|
||||
var pbItems []*pb.SearchItem
|
||||
|
||||
for _, item := range sr.Items {
|
||||
if !filter.IsKnownCategory(item.Categories) {
|
||||
continue
|
||||
}
|
||||
|
||||
pbAttrs := make([]*pb.TorznabAttr, len(item.TorznabAttrs))
|
||||
for j, attr := range item.TorznabAttrs {
|
||||
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{
|
||||
Title: item.Title,
|
||||
|
||||
@@ -72,7 +72,7 @@ type ParserFactory struct {
|
||||
parsers map[parserType]tracker.Parser
|
||||
}
|
||||
|
||||
func NewParserFactory() *ParserFactory {
|
||||
func NewRuTrackerParserFactory() *ParserFactory {
|
||||
return &ParserFactory{
|
||||
parsers: map[parserType]tracker.Parser{
|
||||
parserGeneral: parser.NewGeneralParser(),
|
||||
|
||||
Reference in New Issue
Block a user