mediahandlers

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: GPL-2.0, GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mediahandlers provides HTTP handlers for the /api/media/* endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	StateFunc func() *LiveState
	// ServerCtx returns the server-level context (outlives individual requests).
	// Used for singleflight closures so that a cancelled request doesn't
	// abort a shared fetch that other callers are waiting on.
	ServerCtx func() context.Context
}

Deps holds the dependencies for media handlers.

type EpisodeItem added in v0.1.148

type EpisodeItem struct {
	Title                 string `json:"title"`
	SceneName             string `json:"scene_name,omitempty"`
	ID                    int    `json:"id"`
	SeasonNumber          int    `json:"season"`
	EpisodeNumber         int    `json:"episode"`
	SceneSeasonNumber     int    `json:"scene_season,omitempty"`
	SceneEpisodeNumber    int    `json:"scene_episode,omitempty"`
	AbsoluteEpisodeNumber int    `json:"absolute_episode,omitempty"`
	HasFile               bool   `json:"has_file"`
}

EpisodeItem is the JSON shape for a single episode. It carries no file path (S7): clients address the video by MediaRef (series arr ID + season + episode) and the server resolves paths.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides HTTP handlers for the /api/media/* endpoints.

func NewHandler

func NewHandler(deps Deps) *Handler

NewHandler creates a media Handler with the given dependencies.

func (*Handler) HandleMediaEpisodes

func (h *Handler) HandleMediaEpisodes(w http.ResponseWriter, r *http.Request)

HandleMediaEpisodes returns episodes for a series, grouped by season. GET /api/media/series/{id}/episodes

func (*Handler) HandleMediaMovies

func (h *Handler) HandleMediaMovies(w http.ResponseWriter, r *http.Request)

HandleMediaMovies returns all movies from Radarr for the media browser. GET /api/media/movies

func (*Handler) HandleMediaSeries

func (h *Handler) HandleMediaSeries(w http.ResponseWriter, r *http.Request)

HandleMediaSeries returns all series from Sonarr for the media browser. GET /api/media/series

type LiveState

type LiveState struct {
	Cfg    api.ConfigProvider
	Sonarr MediaSonarrClient // nil when sonarr not configured
	Radarr MediaRadarrClient // nil when radarr not configured
}

LiveState holds the runtime state needed by media handlers.

type MediaRadarrClient added in v0.1.106

type MediaRadarrClient interface {
	GetMovies(ctx context.Context) ([]arrapi.Movie, error)
}

MediaRadarrClient is the Radarr surface the media browser uses.

type MediaSonarrClient added in v0.1.106

type MediaSonarrClient interface {
	GetSeries(ctx context.Context) ([]arrapi.Series, error)
	GetEpisodes(ctx context.Context, seriesID int) ([]arrapi.Episode, error)
}

MediaSonarrClient is the Sonarr surface the media browser uses.

type MovieItem

type MovieItem struct {
	Title     string `json:"title"`
	ImdbID    string `json:"imdb_id,omitempty"`
	SceneName string `json:"scene_name,omitempty"`
	ID        int    `json:"id"`
	Year      int    `json:"year"`
	TmdbID    int    `json:"tmdb_id"`
	HasFile   bool   `json:"has_file"`
}

MovieItem is the JSON shape returned by GET /api/media/movies. It carries no file path (S7): clients address the video by MediaRef (id = arr ID) and the server resolves paths.

type SeasonGroup

type SeasonGroup struct {
	Episodes []EpisodeItem `json:"episodes"`
	Season   int           `json:"season"`
}

SeasonGroup groups episodes by season number.

type SeriesItem

type SeriesItem struct {
	Title    string `json:"title"`
	ImdbID   string `json:"imdb_id,omitempty"`
	ID       int    `json:"id"`
	Year     int    `json:"year"`
	TvdbID   int    `json:"tvdb_id"`
	Seasons  int    `json:"seasons"`
	Episodes int    `json:"episodes"`
}

SeriesItem is the JSON shape returned by GET /api/media/series.

Jump to

Keyboard shortcuts

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