Random Fixes:

- Fix uncached error
- Fix naming and race conditions
This commit is contained in:
Mukhtar Akere
2024-09-14 01:42:52 +01:00
parent 9511f3e99e
commit f622cbfe63
12 changed files with 108 additions and 75 deletions

View File

@@ -217,6 +217,13 @@ func (item Item) getHash() string {
//if err == nil && magnet != nil && magnet.InfoHash != "" {
// log.Printf("Magnet: %s", magnet.InfoHash)
//}
if strings.Contains(magnetLink, "http") {
h, _ := common.GetInfohashFromURL(magnetLink)
if h != "" {
infohash = h
}
}
}
return infohash
@@ -249,7 +256,6 @@ func (p *Proxy) ProcessXMLResponse(resp *http.Response) *http.Response {
if len(rss.Channel.Items) > 0 {
indexer = rss.Channel.Items[0].ProwlarrIndexer.Text
} else {
p.logger.Println("No items found in RSS feed")
resp.Body = io.NopCloser(bytes.NewReader(body))
return resp
}
@@ -283,6 +289,8 @@ func (p *Proxy) ProcessXMLResponse(resp *http.Response) *http.Response {
p.logger.Printf("[%s Report]: %d/%d items are cached || Found %d infohash", indexer, len(newItems), len(rss.Channel.Items), len(hashes))
} else {
// This will prevent the indexer from being disabled by the arr
//filename := common.RandomString(10) + ".xml"
//_ = os.WriteFile(filename, body, 0644)
p.logger.Printf("[%s Report]: No Items are cached; Return only first item with [UnCached]", indexer)
item := rss.Channel.Items[0]
item.Title = fmt.Sprintf("%s [UnCached]", item.Title)