Documentation
¶
Overview ¶
Package haul implements the plugin.DownloadClient interface for Beacon Haul, the native Beacon torrent download client.
Index ¶
- Constants
- type Client
- func (c *Client) Add(ctx context.Context, r plugin.Release) (string, error)
- func (c *Client) GetQueue(ctx context.Context) ([]plugin.QueueItem, error)
- func (c *Client) ListStalled(ctx context.Context) ([]StalledTorrent, error)
- func (c *Client) LookupHistory(ctx context.Context, f HistoryFilter) ([]HistoryRecord, error)
- func (c *Client) LookupHistoryByHash(ctx context.Context, infoHash string) (*HistoryRecord, error)
- func (c *Client) Name() string
- func (c *Client) Protocol() plugin.Protocol
- func (c *Client) Remove(ctx context.Context, clientItemID string, deleteFiles bool) error
- func (c *Client) SetSeedLimits(ctx context.Context, clientItemID string, ratioLimit float64, seedTimeSecs int) error
- func (c *Client) Status(ctx context.Context, clientItemID string) (plugin.QueueItem, error)
- func (c *Client) Test(ctx context.Context) error
- type Config
- type HistoryFilter
- type HistoryRecord
- type StalledTorrent
Constants ¶
const DefaultCategory = "tv"
DefaultCategory is used when no category is configured. Haul saves a category without its own save path in <download dir>/<category>, so on a fresh install Pilot's downloads land in /data/torrents/tv.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements plugin.DownloadClient against the Haul REST API.
func (*Client) Add ¶
Add submits a torrent to Haul via its REST API. For magnet links, sends the URI directly. For HTTP URLs (torznab proxy), downloads the .torrent file first and sends as a magnet or resolves the redirect — this avoids Haul needing network access to Pulse.
func (*Client) ListStalled ¶
func (c *Client) ListStalled(ctx context.Context) ([]StalledTorrent, error)
ListStalled fetches the current stall list from Haul. Returns an empty slice (never nil) if Haul is reachable and nothing is stalled. Returns an error if Haul is unreachable or returns a non-200 — the caller decides whether to swallow or propagate.
func (*Client) LookupHistory ¶
func (c *Client) LookupHistory(ctx context.Context, f HistoryFilter) ([]HistoryRecord, error)
LookupHistory queries Haul's history index. Returns an empty slice when nothing matches — callers treat "no record" as "Haul has never seen this", which is the right default for library-badge rendering.
func (*Client) LookupHistoryByHash ¶
LookupHistoryByHash is a fast point-lookup variant for the manual-search guardrail. Returns nil + no error when Haul has never seen the hash (the API returns 404 in that case).
func (*Client) Remove ¶
Remove deletes a torrent from Haul. A 404 maps to ErrItemNotFound — the item is already gone, which removal callers (download_cleanup, queue removal) treat as success; returning a plain error left such grabs permanently stuck as cleanup candidates.
func (*Client) SetSeedLimits ¶
func (c *Client) SetSeedLimits(ctx context.Context, clientItemID string, ratioLimit float64, seedTimeSecs int) error
SetSeedLimits implements plugin.SeedLimiter.
type Config ¶
type Config struct {
URL string `json:"url"` // e.g. "http://localhost:8484"
APIKey string `json:"api_key,omitempty"` // Haul API key
Category string `json:"category,omitempty"` // category assigned to added torrents
SavePath string `json:"save_path,omitempty"` // override default save path
}
Config holds the connection settings for a Haul instance.
type HistoryFilter ¶
type HistoryFilter struct {
Service string // typically "pilot"
InfoHash string
MovieID string
SeriesID string
EpisodeID string
TMDBID int
Season int
Episode int
IncludeRemoved bool
Limit int
}
HistoryFilter narrows a LookupHistory call. All fields optional; zero values are omitted from the query string. See haul's HistoryFilter for full semantics.
type HistoryRecord ¶
type HistoryRecord struct {
InfoHash string `json:"info_hash"`
Name string `json:"name"`
SavePath string `json:"save_path"`
Category string `json:"category"`
AddedAt string `json:"added_at"`
CompletedAt string `json:"completed_at,omitempty"`
RemovedAt string `json:"removed_at,omitempty"`
Requester string `json:"requester,omitempty"`
MovieID string `json:"movie_id,omitempty"`
SeriesID string `json:"series_id,omitempty"`
EpisodeID string `json:"episode_id,omitempty"`
TMDBID int `json:"tmdb_id,omitempty"`
Season int `json:"season,omitempty"`
Episode int `json:"episode,omitempty"`
}
HistoryRecord mirrors haul/internal/core/torrent/history.go's HistoryRecord — the response shape from Haul's /api/v1/history endpoints. Used by Pilot's library-badge / manual-search guardrail / "downloaded but not in library" rail to detect already-downloaded content without polling Haul's live torrent state.
type StalledTorrent ¶
type StalledTorrent struct {
InfoHash string `json:"info_hash"`
Name string `json:"name"`
Level int `json:"level"`
Reason string `json:"reason"`
InactiveSecs int64 `json:"inactive_secs"`
AddedAt time.Time `json:"added_at"`
}
StalledTorrent is the shape Haul returns from GET /api/v1/stalls. Fields mirror haul/internal/core/torrent/stall.go's StalledTorrent — we keep them in sync informally. If Haul changes the shape this decode step fails loudly and the stall watcher returns an error.