haul

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package haul implements the plugin.DownloadClient interface for Beacon Haul, the native Beacon torrent download client.

Index

Constants

View Source
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 New

func New(cfg Config) *Client

New creates a new Haul client.

func (*Client) Add

func (c *Client) Add(ctx context.Context, r plugin.Release) (string, error)

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) GetQueue

func (c *Client) GetQueue(ctx context.Context) ([]plugin.QueueItem, error)

GetQueue returns all torrents tracked by Haul.

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

func (c *Client) LookupHistoryByHash(ctx context.Context, infoHash string) (*HistoryRecord, error)

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) Name

func (c *Client) Name() string

func (*Client) Protocol

func (c *Client) Protocol() plugin.Protocol

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, clientItemID string, deleteFiles bool) error

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.

func (*Client) Status

func (c *Client) Status(ctx context.Context, clientItemID string) (plugin.QueueItem, error)

Status returns the current state of a torrent by its info hash.

func (*Client) Test

func (c *Client) Test(ctx context.Context) error

Test validates connectivity to the Haul instance.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL