Add retain_folder_name_extension option

This commit is contained in:
Ben Sarmiento
2023-11-07 17:20:54 +01:00
parent d5746fcf5a
commit c2bf627413
10 changed files with 41 additions and 74 deletions

View File

@@ -11,7 +11,6 @@ import (
"github.com/debridmediamanager.com/zurg/internal/dav"
intHttp "github.com/debridmediamanager.com/zurg/internal/http"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/pkg/davextra"
"github.com/debridmediamanager.com/zurg/pkg/logutil"
"github.com/debridmediamanager.com/zurg/pkg/realdebrid"
"github.com/hashicorp/golang-lru/v2/expirable"
@@ -58,8 +57,7 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
return
}
filenameV2, linkFragment := davextra.ExtractLinkFragment(filename)
torrent, file := getFile(torrents, filenameV2, linkFragment)
torrent, file := getFile(torrents, filename)
if file == nil {
log.Errorf("Cannot find file from path %s", requestPath)
http.Error(w, "File not found", http.StatusNotFound)
@@ -79,20 +77,20 @@ func HandleGetRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torrent
resp := realdebrid.RetryUntilOk(unrestrictFn)
if resp == nil {
if !file.Unavailable {
log.Errorf("Cannot unrestrict file %s %s", filenameV2, link)
log.Errorf("Cannot unrestrict file %s %s", filename, link)
t.HideTheFile(torrent, file)
}
streamErrorVideo("https://www.youtube.com/watch?v=gea_FJrtFVA", w, r, c, log)
return
} else if resp.Filename != filenameV2 {
} else if resp.Filename != filename {
actualExt := filepath.Ext(resp.Filename)
expectedExt := filepath.Ext(filenameV2)
expectedExt := filepath.Ext(filename)
if actualExt != expectedExt && resp.Streamable != 1 {
log.Errorf("File extension mismatch: %s and %s", filenameV2, resp.Filename)
log.Errorf("File extension mismatch: %s and %s", filename, resp.Filename)
streamErrorVideo("https://www.youtube.com/watch?v=t9VgOriBHwE", w, r, c, log)
return
} else {
log.Errorf("Filename mismatch: %s and %s", filenameV2, resp.Filename)
log.Errorf("Filename mismatch: %s and %s", filename, resp.Filename)
}
}
cache.Add(requestPath, resp.Download)