Documentation
¶
Overview ¶
Package trakt resolves a public Trakt list URL into TMDB movie IDs (curated/public list import, e.g. IMDb/Trakt lists). Only Trakt is implemented: IMDb has no public API for lists (its CSV export requires being logged in as the list owner, even for "public" lists, which isn't something this app can do without asking for IMDb credentials) — Trakt's list-items endpoint is public, documented, and stable, and every item it returns already carries a tmdb id, which is all this app actually needs (TMDB is the metadata source of truth everywhere else — see internal/metadata).
Index ¶
- Variables
- func ParseListURL(rawURL string) (user, listID string, err error)
- type Client
- func (c *Client) HasClientID() bool
- func (c *Client) ListMovies(ctx context.Context, user, listID string) ([]ListItem, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) SetClientID(id string)
- func (c *Client) WithClientID(id string) *Client
- func (c *Client) WrapTransport(wrap func(http.RoundTripper) http.RoundTripper)
- type ListItem
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidClientID = fmt.Errorf("Trakt rejected this client ID")
ErrInvalidClientID is returned when Trakt rejects the client ID.
var ErrNoClientID = fmt.Errorf("no Trakt API client ID has been added yet")
ErrNoClientID is returned by any call when no Trakt API client ID is configured yet — callers should surface this as a "set up Trakt in Settings" prompt, same convention as metadata.ErrNoAPIKey.
Functions ¶
func ParseListURL ¶
ParseListURL extracts the user slug and list slug/id from a Trakt list URL, e.g. "https://trakt.tv/users/garycrawfordgeorge/lists/imdb-top-250" (with or without a scheme, trailing slash, or query string) -> ("garycrawfordgeorge", "imdb-top-250").
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
New constructs a client. clientID may be empty; calls return ErrNoClientID until SetClientID is used or a new Client is built with one.
func NewWithBaseURL ¶
NewWithBaseURL is used by tests to point the client at a local fixture server instead of the real Trakt API (tests use local fixtures, not live network calls).
func (*Client) HasClientID ¶
func (*Client) ListMovies ¶
ListMovies fetches every movie item on a public Trakt list. Items without a TMDB id (Trakt couldn't match them to TMDB) are skipped — there's nothing this app can do with them since TMDB is the only metadata source it knows how to enrich from.
func (*Client) SetClientID ¶
func (*Client) WithClientID ¶
WithClientID returns a separate client using another client ID against the same server, to test an ID before saving it.
func (*Client) WrapTransport ¶
func (c *Client) WrapTransport(wrap func(http.RoundTripper) http.RoundTripper)
WrapTransport wraps the HTTP transport this client uses, e.g. to count requests. Call it before the client is shared between goroutines.