tunarr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 8 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 tunarr provides a client for interacting with the Tunarr API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID         string       `json:"id" validate:"required"`
	Number     int          `json:"number"`
	Name       string       `json:"name" validate:"required"`
	Icon       *ChannelIcon `json:"icon,omitempty"`
	GroupTitle string       `json:"groupTitle"`
	Duration   int64        `json:"duration"`
	Stealth    bool         `json:"stealth"`
}

Channel represents a Tunarr TV channel.

type ChannelIcon

type ChannelIcon struct {
	Path     string `json:"path"`
	Width    int    `json:"width"`
	Duration int    `json:"duration"`
	Position string `json:"position"` // top-left, top-right, bottom-left, bottom-right
}

ChannelIcon represents a channel icon configuration.

type ChannelProgram

type ChannelProgram struct {
	// Program data
	Title         string  `json:"title"`
	Duration      float64 `json:"duration"` // milliseconds
	Type          string  `json:"type"`     // movie, episode, flex, redirect, custom
	Year          *int    `json:"year,omitempty"`
	Rating        string  `json:"rating,omitempty"`
	SeasonNumber  int     `json:"seasonNumber,omitempty"`
	EpisodeNumber int     `json:"episodeNumber,omitempty"`
	ShowTitle     string  `json:"showTitle,omitempty"`

	// Scheduling info
	StartTimeMs int64 `json:"startTime"` // Unix timestamp in milliseconds
}

ChannelProgram represents a scheduled program in a channel's programming.

type ChannelProgrammingResponse

type ChannelProgrammingResponse struct {
	Programs []ChannelProgram `json:"programs"`
}

ChannelProgrammingResponse represents the response from GET /api/channels/{id}/programming.

type Client

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

Client is a Tunarr API client.

func NewClient

func NewClient(cfg Config) *Client

NewClient creates a new Tunarr API client with the given configuration.

func (*Client) GetChannelProgramming

func (c *Client) GetChannelProgramming(ctx context.Context, channelID string) ([]ChannelProgram, error)

GetChannelProgramming retrieves the current programming for a channel. GET /api/channels/{id}/programming

func (*Client) GetChannels

func (c *Client) GetChannels(ctx context.Context) ([]Channel, error)

GetChannels retrieves all channels from the Tunarr instance. GET /api/channels

func (*Client) GetFillerPrograms

func (c *Client) GetFillerPrograms(ctx context.Context, fillerListID string) ([]Program, error)

GetFillerPrograms retrieves programs from a specific filler list. GET /api/filler-lists/{id}/programs

func (*Client) GetLibraries

func (c *Client) GetLibraries(ctx context.Context, mediaSourceID string) ([]Library, error)

GetLibraries retrieves all libraries for a specific media source. GET /api/media-sources/{id}/libraries

func (*Client) GetMediaSources

func (c *Client) GetMediaSources(ctx context.Context) ([]MediaSource, error)

GetMediaSources retrieves all connected media sources (Plex/Jellyfin/Emby). GET /api/media-sources

func (*Client) SearchPrograms

func (c *Client) SearchPrograms(ctx context.Context, req ProgramSearchRequest) (*ProgramSearchResponse, error)

SearchPrograms searches for programs using the Tunarr search API. POST /api/programs/search

func (*Client) UpdateSchedule

func (c *Client) UpdateSchedule(ctx context.Context, channelID string, programs []Program) error

UpdateSchedule applies a schedule of programs to a channel. PUT /api/channels/{id}/programming

type Config

type Config struct {
	URL    string `mapstructure:"url" yaml:"url" json:"url"`
	APIKey string `mapstructure:"api_key" yaml:"api_key" json:"api_key"`
}

Config holds the configuration for connecting to a Tunarr instance.

type FillerList

type FillerList struct {
	ID           string    `json:"id" validate:"required"`
	Name         string    `json:"name" validate:"required"`
	ContentCount int       `json:"contentCount"` // number of items
	Programs     []Program `json:"programs,omitempty"`
}

FillerList represents a collection of filler content.

type Genre

type Genre struct {
	UUID string `json:"uuid,omitempty"`
	Name string `json:"name"`
}

Genre represents a genre with metadata.

type Library

type Library struct {
	ID            string `json:"id" validate:"required"`
	Name          string `json:"name" validate:"required"`
	MediaType     string `json:"mediaType"` // movies, shows, music_videos, other_videos, tracks
	Type          string `json:"type"`      // plex, jellyfin, emby, local
	Enabled       bool   `json:"enabled"`
	ExternalKey   string `json:"externalKey,omitempty"`
	LastScannedAt int64  `json:"lastScannedAt,omitempty"`
}

Library represents a media library from a media source. Retrieved from /api/media-sources/{id}/libraries

type MediaSource

type MediaSource struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"` // plex, jellyfin, emby, local
}

MediaSource represents a connected media server (Plex/Jellyfin/Emby).

type Program

type Program struct {
	// Core identifier - Tunarr uses "id" for legacy/filler content
	ID string `json:"id,omitempty"`
	// UUID is the primary identifier in newer API responses
	UUID string `json:"uuid,omitempty"`

	Title    string  `json:"title" validate:"required"`
	Year     *int    `json:"year,omitempty"`
	Summary  string  `json:"summary,omitempty"`
	Duration float64 `json:"duration" validate:"gte=0"` // in milliseconds (float from Tunarr API, 0 for placeholders)
	Rating   string  `json:"rating,omitempty"`
	Icon     string  `json:"icon,omitempty"`

	// Genres can be simple strings or objects depending on the endpoint
	Genres []Genre `json:"genres,omitempty"`

	// Type: movie, episode, track, music_video, other_video, redirect, custom, flex, show (Tunarr may return others)
	Type string `json:"type" validate:"omitempty,oneof=movie episode track music_video other_video redirect custom flex content show"`
	// Subtype is used in filler content: movie, episode, track, music_video, other_video
	Subtype string `json:"subtype,omitempty"`

	// Episode-specific fields (Tunarr uses seasonNumber/episodeNumber)
	ShowID        string `json:"showId,omitempty"`
	SeasonID      string `json:"seasonId,omitempty"`
	SeasonNumber  int    `json:"seasonNumber,omitempty"`
	EpisodeNumber int    `json:"episodeNumber,omitempty"`

	// ShowTitle is populated internally for series scheduling.
	// Not part of Tunarr API - must be set from Show.Title when needed.
	ShowTitle string `json:"-"`

	// Source information
	SourceType    string `json:"sourceType,omitempty"` // plex, jellyfin, emby, local
	MediaSourceID string `json:"mediaSourceId,omitempty"`
	LibraryID     string `json:"libraryId,omitempty"`
	ExternalID    string `json:"externalId,omitempty"`
	ExternalKey   string `json:"externalKey,omitempty"`
}

Program represents a media program (movie, episode, or track) in Tunarr. Field names match the Tunarr API schema.

func (*Program) GetDurationMs

func (p *Program) GetDurationMs() int64

GetDurationMs returns the duration in milliseconds as int64. Tunarr API returns duration as float64 for precision.

func (*Program) GetGenreNames

func (p *Program) GetGenreNames() []string

GetGenreNames returns a slice of genre names for filtering.

func (*Program) GetID

func (p *Program) GetID() string

GetID returns the program ID, preferring UUID over ID.

func (*Program) GetYear

func (p *Program) GetYear() int

GetYear returns the year value or 0 if nil.

type ProgramSearchQuery

type ProgramSearchQuery struct {
	Query            string        `json:"query,omitempty"`
	RestrictSearchTo []string      `json:"restrictSearchTo,omitempty"`
	Filter           *SearchFilter `json:"filter,omitempty"`
	Sort             *SearchSort   `json:"sort,omitempty"`
}

ProgramSearchQuery represents a search query for programs.

type ProgramSearchRequest

type ProgramSearchRequest struct {
	Query         *ProgramSearchQuery `json:"query,omitempty"`
	MediaSourceID string              `json:"mediaSourceId,omitempty"`
	LibraryID     string              `json:"libraryId,omitempty"`
	Page          int                 `json:"page,omitempty"`
	Limit         int                 `json:"limit,omitempty"`
}

ProgramSearchRequest represents the request body for POST /api/programs/search.

type ProgramSearchResponse

type ProgramSearchResponse struct {
	Results []Program `json:"results"`
	Total   int       `json:"total"`
	Page    int       `json:"page"`
	Limit   int       `json:"limit"`
}

ProgramSearchResponse represents the response from POST /api/programs/search.

type ScheduleRequest

type ScheduleRequest struct {
	Schedule *TimeBasedSchedule `json:"schedule"`
}

ScheduleRequest represents the request body for POST /api/channels/{id}/schedule-time-slots.

type ScheduleSlot

type ScheduleSlot struct {
	StartTime int64  `json:"startTime"` // milliseconds from start of period
	Type      string `json:"type"`      // movie, show, flex, redirect
	Order     string `json:"order"`     // next, shuffle, ordered_shuffle, alphanumeric, chronological
	Direction string `json:"direction"` // asc, desc
}

ScheduleSlot represents a time slot in a channel schedule.

type SearchFilter

type SearchFilter struct {
	Type []string `json:"type,omitempty"` // movie, episode, track, etc.
}

SearchFilter represents search filter options.

type SearchSort

type SearchSort struct {
	Field     string `json:"field,omitempty"`     // title, year, duration, etc.
	Direction string `json:"direction,omitempty"` // asc, desc
}

SearchSort represents search sort options.

type Season

type Season struct {
	UUID         string `json:"uuid"`
	Title        string `json:"title,omitempty"`
	SeasonNumber int    `json:"seasonNumber"`
	ChildCount   int    `json:"childCount"` // Episode count
}

Season represents a TV show season.

type Show

type Show struct {
	UUID    string `json:"uuid" validate:"required"`
	Title   string `json:"title" validate:"required"`
	Year    *int   `json:"year,omitempty"`
	Summary string `json:"summary,omitempty"`
	Rating  string `json:"rating,omitempty"`

	// Genres is an array of Genre objects
	Genres []Genre `json:"genres,omitempty"`

	// Season/episode counts
	ChildCount      int `json:"childCount"`      // Number of seasons
	GrandchildCount int `json:"grandchildCount"` // Number of episodes

	// Seasons contains the actual season data
	Seasons []Season `json:"seasons,omitempty"`

	// Source information
	SourceType    string `json:"sourceType,omitempty"` // plex, jellyfin, emby, local
	MediaSourceID string `json:"mediaSourceId,omitempty"`
	LibraryID     string `json:"libraryId,omitempty"`
	ExternalID    string `json:"externalId,omitempty"`
}

Show represents a TV show with metadata.

type TimeBasedSchedule

type TimeBasedSchedule struct {
	Type           string         `json:"type"` // "time"
	FlexPreference string         `json:"flexPreference,omitempty"`
	LatenessMs     int64          `json:"latenessMs,omitempty"`
	MaxDays        int            `json:"maxDays,omitempty"`
	PadMs          int64          `json:"padMs,omitempty"`
	Period         string         `json:"period,omitempty"` // day, week
	Slots          []ScheduleSlot `json:"slots,omitempty"`
}

TimeBasedSchedule represents a time-based channel schedule.

Jump to

Keyboard shortcuts

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