Changelog: 0.1.3

This commit is contained in:
Mukhtar Akere
2024-09-01 13:17:15 +01:00
parent 74791d6e62
commit d405e0d8e0
11 changed files with 398 additions and 111 deletions
+33 -3
View File
@@ -18,14 +18,16 @@ type Debrid struct {
Host string `json:"host"`
APIKey string
DownloadUncached bool
client *common.RLHTTPClient
cache *common.Cache
}
func NewDebrid(dc common.DebridConfig) Service {
func NewDebrid(dc common.DebridConfig, cache *common.Cache) Service {
switch dc.Name {
case "realdebrid":
return NewRealDebrid(dc)
return NewRealDebrid(dc, cache)
default:
return NewRealDebrid(dc)
return NewRealDebrid(dc, cache)
}
}
@@ -81,3 +83,31 @@ func getTorrentInfo(filePath string) (*Torrent, error) {
}
return torrent, nil
}
func GetLocalCache(infohashes []string, cache *common.Cache) (string, map[string]bool) {
result := make(map[string]bool)
if len(infohashes) == 0 {
return "", result
}
if len(infohashes) == 1 {
if cache.Exists(infohashes[0]) {
return "", map[string]bool{infohashes[0]: true}
}
return infohashes[0], result
}
cachedHashes := cache.GetMultiple(infohashes)
hashes := ""
for _, h := range infohashes {
_, exists := cachedHashes[h]
if !exists {
hashes += h + "/"
} else {
result[h] = true
}
}
return hashes, result
}