go-client/torrent.go
Deivid Soto f6f24c2c3f
Some checks failed
CI / Test (push) Failing after 1s
CI / Test-1 (push) Failing after 1s
CI / Test-2 (push) Failing after 1s
CI / Lint (push) Failing after 1s
CI / Vet (push) Failing after 1s
feat: implement TorrentClaw Go API client v0.1.0
2026-03-28 11:28:48 +01:00

19 lines
590 B
Go

package torrentclaw
import (
"context"
"fmt"
)
// TorrentDownloadURL returns the URL for downloading a .torrent file by its
// info hash. This method does not make an HTTP request.
func (c *Client) TorrentDownloadURL(infoHash string) string {
return fmt.Sprintf("%s/api/v1/torrent/%s", c.baseURL, infoHash)
}
// GetTorrentFile downloads the .torrent file for the given info hash and
// returns the raw bytes.
func (c *Client) GetTorrentFile(ctx context.Context, infoHash string) ([]byte, error) {
path := fmt.Sprintf("/api/v1/torrent/%s", infoHash)
return c.doRaw(ctx, path, nil)
}