Add retain_folder_name_extension option
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/davextra"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
)
|
||||
@@ -53,8 +52,7 @@ func HandleHeadRequest(w http.ResponseWriter, r *http.Request, t *torrent.Torren
|
||||
return
|
||||
}
|
||||
|
||||
filenameV2, linkFragment := davextra.ExtractLinkFragment(filename)
|
||||
_, file := getFile(torrents, filenameV2, linkFragment)
|
||||
_, file := getFile(torrents, filename)
|
||||
if file == nil {
|
||||
log.Errorf("Cannot find file from path %s", requestPath)
|
||||
http.Error(w, "Cannot find file", http.StatusNotFound)
|
||||
|
||||
@@ -2,17 +2,16 @@ package universal
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
)
|
||||
|
||||
// getFile finds a link by a fragment, it might be wrong
|
||||
func getFile(torrents []torrent.Torrent, filename, fragment string) (*torrent.Torrent, *torrent.File) {
|
||||
func getFile(torrents []torrent.Torrent, filename string) (*torrent.Torrent, *torrent.File) {
|
||||
for t := range torrents {
|
||||
for f, file := range torrents[t].SelectedFiles {
|
||||
fname := filepath.Base(file.Path)
|
||||
if filename == fname && strings.Contains(file.Link, fragment) {
|
||||
if filename == fname {
|
||||
return &torrents[t], &torrents[t].SelectedFiles[f]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user