Files
zurg/internal/universal/util.go
Ben Sarmiento 54ab801796 Finalize repair
2023-10-26 03:29:13 +02:00

22 lines
548 B
Go

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) {
for t := range torrents {
for f, file := range torrents[t].SelectedFiles {
fname := filepath.Base(file.Path)
if filename == fname && strings.Contains(file.Link, fragment) {
return &torrents[t], &torrents[t].SelectedFiles[f]
}
}
}
return nil, nil
}