Hotfix issues with 1.0.3

This commit is contained in:
Mukhtar Akere
2025-06-26 03:51:28 +01:00
parent 817051589e
commit e123a2fd5e
10 changed files with 76 additions and 334 deletions

View File

@@ -621,7 +621,7 @@ func (r *RealDebrid) CheckLink(link string) error {
func (r *RealDebrid) _getDownloadLink(file *types.File) (*types.DownloadLink, error) {
url := fmt.Sprintf("%s/unrestrict/link/", r.Host)
_link := file.Link
if strings.HasPrefix(_link, "https://real-debrid.com/d/") {
if strings.HasPrefix(file.Link, "https://real-debrid.com/d/") && len(file.Link) > 39 {
_link = file.Link[0:39]
}
payload := gourl.Values{

View File

@@ -137,10 +137,10 @@ func (c *Cache) refreshRclone() error {
}
client := &http.Client{
Timeout: 30 * time.Second,
Timeout: 60 * time.Second,
Transport: &http.Transport{
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
IdleConnTimeout: 60 * time.Second,
DisableCompression: false,
MaxIdleConnsPerHost: 5,
},

View File

@@ -18,7 +18,7 @@ func NewAccounts(debridConf config.Debrid) *Accounts {
if token == "" {
continue
}
account := newAccount(token, idx)
account := newAccount(debridConf.Name, token, idx)
accounts = append(accounts, account)
}
@@ -33,6 +33,7 @@ func NewAccounts(debridConf config.Debrid) *Accounts {
}
type Account struct {
Debrid string // e.g., "realdebrid", "torbox", etc.
Order int
Disabled bool
Token string
@@ -176,30 +177,31 @@ func (a *Accounts) SetDownloadLinks(links map[string]*DownloadLink) {
a.Current().setLinks(links)
}
func newAccount(token string, index int) *Account {
func newAccount(debridName, token string, index int) *Account {
return &Account{
Token: token,
Order: index,
links: make(map[string]*DownloadLink),
Debrid: debridName,
Token: token,
Order: index,
links: make(map[string]*DownloadLink),
}
}
func (a *Account) getLink(fileLink string) (*DownloadLink, bool) {
a.mu.RLock()
defer a.mu.RUnlock()
dl, ok := a.links[fileLink[0:39]]
dl, ok := a.links[a.sliceFileLink(fileLink)]
return dl, ok
}
func (a *Account) setLink(fileLink string, dl *DownloadLink) {
a.mu.Lock()
defer a.mu.Unlock()
a.links[fileLink[0:39]] = dl
a.links[a.sliceFileLink(fileLink)] = dl
}
func (a *Account) deleteLink(fileLink string) {
a.mu.Lock()
defer a.mu.Unlock()
delete(a.links, fileLink[0:39])
delete(a.links, a.sliceFileLink(fileLink))
}
func (a *Account) resetDownloadLinks() {
a.mu.Lock()
@@ -225,6 +227,17 @@ func (a *Account) setLinks(links map[string]*DownloadLink) {
// Expired, continue
continue
}
a.links[dl.Link[0:39]] = dl
a.links[a.sliceFileLink(dl.Link)] = dl
}
}
// slice download link
func (a *Account) sliceFileLink(fileLink string) string {
if a.Debrid != "realdebrid" {
return fileLink
}
if len(fileLink) < 39 {
return fileLink
}
return fileLink[0:39]
}