trakt

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 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 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

Constants

This section is empty.

Variables

View Source
var ErrInvalidClientID = fmt.Errorf("Trakt rejected this client ID")

ErrInvalidClientID is returned when Trakt rejects the client ID.

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

func ParseListURL(rawURL string) (user, listID string, err error)

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

func New(clientID string) *Client

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

func NewWithBaseURL(clientID, base string) *Client

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 (c *Client) HasClientID() bool

func (*Client) ListMovies

func (c *Client) ListMovies(ctx context.Context, user, listID string) ([]ListItem, error)

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

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

Ping checks the client ID with a tiny public request (trending movies).

func (*Client) SetClientID

func (c *Client) SetClientID(id string)

func (*Client) WithClientID

func (c *Client) WithClientID(id string) *Client

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.

type ListItem

type ListItem struct {
	Title  string
	Year   int
	TMDBID int
}

ListItem is the subset of a Trakt list entry this app needs — just enough to look the movie up in TMDB (internal/metadata.Client.GetMovie), which is where poster/overview/etc. actually come from.

Jump to

Keyboard shortcuts

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