Documentation
¶
Overview ¶
Package tunarr provides a client for interacting with the Tunarr API.
Index ¶
- type Channel
- type ChannelIcon
- type ChannelProgram
- type ChannelProgrammingResponse
- type Client
- func (c *Client) GetChannelProgramming(ctx context.Context, channelID string) ([]ChannelProgram, error)
- func (c *Client) GetChannels(ctx context.Context) ([]Channel, error)
- func (c *Client) GetFillerPrograms(ctx context.Context, fillerListID string) ([]Program, error)
- func (c *Client) GetLibraries(ctx context.Context, mediaSourceID string) ([]Library, error)
- func (c *Client) GetMediaSources(ctx context.Context) ([]MediaSource, error)
- func (c *Client) SearchPrograms(ctx context.Context, req ProgramSearchRequest) (*ProgramSearchResponse, error)
- func (c *Client) UpdateSchedule(ctx context.Context, channelID string, programs []Program) error
- type Config
- type FillerList
- type Genre
- type Library
- type MediaSource
- type Program
- type ProgramSearchQuery
- type ProgramSearchRequest
- type ProgramSearchResponse
- type ScheduleRequest
- type ScheduleSlot
- type SearchFilter
- type SearchSort
- type Season
- type Show
- type TimeBasedSchedule
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 (*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 ¶
GetChannels retrieves all channels from the Tunarr instance. GET /api/channels
func (*Client) GetFillerPrograms ¶
GetFillerPrograms retrieves programs from a specific filler list. GET /api/filler-lists/{id}/programs
func (*Client) GetLibraries ¶
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
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 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 ¶
GetDurationMs returns the duration in milliseconds as int64. Tunarr API returns duration as float64 for precision.
func (*Program) GetGenreNames ¶
GetGenreNames returns a slice of genre names for filtering.
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.