Add downloads dir to http, not sure if working
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/debridmediamanager/zurg/internal/config"
|
||||
"github.com/debridmediamanager/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager/zurg/pkg/logutil"
|
||||
)
|
||||
|
||||
func ServeRootDirectory(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
@@ -25,11 +24,14 @@ func ServeRootDirectory(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
directoryPath := url.PathEscape(directory)
|
||||
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s/\">%s</a></li>", directoryPath, directory))
|
||||
}
|
||||
if torMgr.Config.GetConfig().UseDownloadCache {
|
||||
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s/\">%s</a></li>", config.DOWNLOADS, config.DOWNLOADS))
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
|
||||
func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -49,7 +51,7 @@ func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager, log *lo
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
|
||||
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||
@@ -88,3 +90,16 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
if !torMgr.Config.GetConfig().UseDownloadCache {
|
||||
buf.WriteString("Enable download cache in config to use this feature")
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
buf.WriteString("<ol>")
|
||||
for _, download := range torMgr.DownloadCache.Items() {
|
||||
buf.WriteString(fmt.Sprintf("<li><a href=\"%s\">%s</a></li>", download.Download, download.Filename))
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user