Fix for invalid_download_code

This commit is contained in:
Ben Adrian Sarmiento
2024-06-30 23:29:29 +02:00
parent bf193a2656
commit f3d6230935
5 changed files with 46 additions and 20 deletions

View File

@@ -354,9 +354,6 @@ func (t *TorrentManager) assignLinks(torrent *Torrent) bool {
if !assigned && file.State.Is("broken_file") && file.Bytes == unrestrict.Filesize && strings.HasSuffix(strings.ToLower(file.Path), strings.ToLower(unrestrict.Filename)) {
file.Link = link
assignedLinks = append(assignedLinks, link)
if strings.HasPrefix(file.Link, "https://real-debrid.com/d/") {
file.Link = file.Link[0:39]
}
file.State.Event(context.Background(), "repair_file")
assigned = true
assignedCount++
@@ -531,6 +528,12 @@ func (t *TorrentManager) redownloadTorrent(torrent *Torrent, selection []string)
t.DeleteByID(newTorrentID)
return nil, fmt.Errorf("cannot get info on redownloaded : %v", err)
}
for i := range info.Links {
if strings.HasPrefix(info.Links[i], "https://real-debrid.com/d/") {
// set link to max 39 chars (26 + 13)
info.Links[i] = info.Links[i][0:39]
}
}
if info.Status == "magnet_conversion" {
time.Sleep(60 * time.Second)
@@ -658,9 +661,6 @@ func (t *TorrentManager) checkIfBroken(info *realdebrid.TorrentInfo, brokenFiles
for i, file := range selectedFiles {
file.Link = info.Links[i]
if strings.HasPrefix(file.Link, "https://real-debrid.com/d/") {
file.Link = file.Link[0:39]
}
file.State.Event(context.Background(), "repair_file")
}