Exclusive for dav endpoint
This commit is contained in:
@@ -13,10 +13,10 @@ import (
|
||||
"github.com/debridmediamanager/zurg/pkg/dav"
|
||||
)
|
||||
|
||||
func ServeRootDirectory(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
func ServeRootDirectoryForDav(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
buf.WriteString(dav.BaseDirectory("", ""))
|
||||
buf.WriteString(dav.BaseDirectory(addSlash(""), ""))
|
||||
directories := torMgr.DirectoryMap.Keys()
|
||||
sort.Strings(directories)
|
||||
for _, directory := range directories {
|
||||
@@ -32,7 +32,7 @@ func ServeRootDirectory(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
func ServeTorrentsListForDav(directory string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -40,7 +40,7 @@ func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte
|
||||
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
buf.WriteString(dav.BaseDirectory(directory, ""))
|
||||
buf.WriteString(dav.BaseDirectory(addSlash(directory), ""))
|
||||
torrentNames := torrents.Keys()
|
||||
sort.Strings(torrentNames)
|
||||
for _, torrentName := range torrentNames {
|
||||
@@ -54,7 +54,7 @@ func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
|
||||
func ServeFilesListForDav(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -72,7 +72,7 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
||||
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, torMgr.GetKey(tor)), tor.Added))
|
||||
buf.WriteString(dav.BaseDirectory(addSlash(filepath.Join(directory, torMgr.GetKey(tor))), tor.Added))
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
@@ -114,13 +114,13 @@ func HandleSingleFile(directory, torrentName, fileName string, torMgr *torrent.T
|
||||
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
buf.WriteString(dav.BaseDirectory(filepath.Join(directory, torMgr.GetKey(tor)), tor.Added))
|
||||
buf.WriteString(dav.BaseDirectory(addSlash(filepath.Join(directory, torMgr.GetKey(tor))), tor.Added))
|
||||
buf.WriteString(dav.File(fileName, file.Bytes, file.Ended))
|
||||
buf.WriteString("</d:multistatus>")
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
func ServeDownloadsListForDav(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
|
||||
buf.WriteString(dav.BaseDirectory(config.DOWNLOADS, ""))
|
||||
Reference in New Issue
Block a user