Refinements

This commit is contained in:
Ben Sarmiento
2023-10-19 23:00:35 +02:00
parent fda45b99ff
commit a65019e202
7 changed files with 149 additions and 126 deletions

View File

@@ -22,7 +22,8 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
// If there are less than 3 segments, return an error or adjust as needed
if len(segments) < 3 {
log.Println("Invalid url", requestPath)
http.Error(w, "Cannot find file", http.StatusNotFound)
// http.Error(w, "Cannot find file", http.StatusNotFound)
handleSingleTorrent(requestPath, w, r, t)
return
}
@@ -52,7 +53,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
resp := realdebrid.RetryUntilOk(unrestrictFn)
if resp == nil {
// TODO: Readd the file
// when unrestricting fails, it means the file is not available anymore
// when unrestricting fails, it means the file is not available anymore, but still in their database
// if it's the only file, tough luck
log.Println("Cannot unrestrict link")
http.Error(w, "Cannot find file", http.StatusNotFound)
@@ -63,6 +64,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
// [SRS] Pokemon S22E01-35 1080p WEBRip AAC 2.0 x264 CC.rar
// Pokemon.S22E24.The.Secret.Princess.DUBBED.1080p.WEBRip.AAC.2.0.x264-SRS.mkv
// Action: schedule a "cleanup" job for the parent torrent
// If the file extension changed, that means it's a different file
log.Println("Filename mismatch", resp.Filename, filenameV2)
}
http.Redirect(w, r, resp.Download, http.StatusFound)