34 lines
850 B
Go
34 lines
850 B
Go
package dav
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
|
)
|
|
|
|
// convertDate converts a date from RFC3339 to RFC1123
|
|
func convertDate(input string) string {
|
|
t, err := time.Parse(time.RFC3339, input)
|
|
if err != nil {
|
|
log.Println("Error:", err)
|
|
return ""
|
|
}
|
|
return t.Format("Mon, 02 Jan 2006 15:04:05 GMT")
|
|
}
|
|
|
|
// findAllTorrentsWithName finds all torrents in a given directory with a given name
|
|
func findAllTorrentsWithName(t *torrent.TorrentManager, directory, torrentName string) []torrent.Torrent {
|
|
var matchingTorrents []torrent.Torrent
|
|
|
|
torrents := t.GetByDirectory(directory)
|
|
for i := range torrents {
|
|
if torrents[i].Name == torrentName || strings.HasPrefix(torrents[i].Name, torrentName) {
|
|
matchingTorrents = append(matchingTorrents, torrents[i])
|
|
}
|
|
}
|
|
|
|
return matchingTorrents
|
|
}
|