Return an error for 503

This commit is contained in:
Ben Adrian Sarmiento
2024-06-23 22:08:54 +02:00
parent 8bf39d58de
commit 3abf48514d
10 changed files with 87 additions and 65 deletions

View File

@@ -138,7 +138,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
}
// proxy function
func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool) *realdebrid.Download {
func (t *TorrentManager) UnrestrictLink(link string, verifyURL bool) *realdebrid.Download {
isRealDebrid := strings.HasPrefix(link, "https://real-debrid.com/d/")
if isRealDebrid && t.UnrestrictMap.Has(link[0:39]) {
ret, _ := t.UnrestrictMap.Get(link[0:39])
@@ -147,7 +147,7 @@ func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool)
ret, _ := t.UnrestrictMap.Get(link)
return ret
}
ret, err := t.api.UnrestrictLink(link, checkFirstByte)
ret, err := t.api.UnrestrictLink(link, verifyURL)
if err != nil {
t.log.Warnf("Cannot unrestrict link %s: %v", link, err)
return nil
@@ -160,11 +160,11 @@ func (t *TorrentManager) UnrestrictLinkUntilOk(link string, checkFirstByte bool)
return ret
}
func (t *TorrentManager) UnrestrictFileUntilOk(file *File, checkFirstByte bool) *realdebrid.Download {
func (t *TorrentManager) UnrestrictFile(file *File, checkFirstByte bool) *realdebrid.Download {
if !file.State.Is("ok_file") {
return nil
}
return t.UnrestrictLinkUntilOk(file.Link, checkFirstByte)
return t.UnrestrictLink(file.Link, checkFirstByte)
}
func (t *TorrentManager) GetKey(torrent *Torrent) string {
@@ -235,7 +235,7 @@ func (t *TorrentManager) applyMediaInfoDetails(torrent *Torrent) {
if file.MediaInfo != nil || !file.State.Is("ok_file") || !isPlayable {
return
}
unrestrict := t.UnrestrictFileUntilOk(file, true)
unrestrict := t.UnrestrictFile(file, true)
if unrestrict == nil {
file.State.Event(context.Background(), "break_file")
t.EnqueueForRepair(torrent)