kodi

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: GPL-3.0 Imports: 15 Imported by: 1 module, 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

Index

Constants

View Source
const (
	SchemeKodiMovie   = "kodi-movie"
	SchemeKodiEpisode = "kodi-episode"
	SchemeKodiSong    = "kodi-song"
	SchemeKodiAlbum   = "kodi-album"
	SchemeKodiArtist  = "kodi-artist"
	SchemeKodiShow    = "kodi-show"
)

URL scheme constants for Kodi media

Variables

This section is empty.

Functions

func NewKodiAlbumLauncher

func NewKodiAlbumLauncher() platforms.Launcher

NewKodiAlbumLauncher creates a KodiAlbum launcher for album collection playback

func NewKodiArtistLauncher

func NewKodiArtistLauncher() platforms.Launcher

NewKodiArtistLauncher creates a KodiArtist launcher for artist collection playback

func NewKodiLocalLauncher

func NewKodiLocalLauncher() platforms.Launcher

NewKodiLocalLauncher creates a standard KodiLocal launcher for direct video file playback

func NewKodiMovieLauncher

func NewKodiMovieLauncher() platforms.Launcher

NewKodiMovieLauncher creates a standard KodiMovie launcher for library movie playback

func NewKodiMusicLauncher

func NewKodiMusicLauncher() platforms.Launcher

NewKodiMusicLauncher creates a KodiMusic launcher for local music files

func NewKodiSongLauncher

func NewKodiSongLauncher() platforms.Launcher

NewKodiSongLauncher creates a KodiSong launcher for individual song playback

func NewKodiTVLauncher

func NewKodiTVLauncher() platforms.Launcher

NewKodiTVLauncher creates a standard KodiTV launcher for library TV episode playback

func NewKodiTVShowLauncher

func NewKodiTVShowLauncher() platforms.Launcher

NewKodiTVShowLauncher creates a KodiTVShow launcher for TV show collection playback

func ScanAlbums

func ScanAlbums(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanAlbums scans albums from Kodi library using the provided client

func ScanArtists

func ScanArtists(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanArtists scans artists from Kodi library using the provided client

func ScanMovies

func ScanMovies(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanMovies scans movies from Kodi library using the provided client

func ScanSongs

func ScanSongs(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanSongs scans songs from Kodi library using the provided client

func ScanTV

func ScanTV(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanTV scans TV shows and episodes from Kodi library using the provided client

func ScanTVShows

func ScanTVShows(
	client KodiClient,
	_ *config.Instance,
	_ string,
	results []platforms.ScanResult,
) ([]platforms.ScanResult, error)

ScanTVShows scans TV shows from Kodi library using the provided client

Types

type APIError

type APIError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

APIError represents a Kodi JSON-RPC error

type APIMethod

type APIMethod string

APIMethod represents Kodi JSON-RPC API methods

const (
	APIMethodPlayerOpen              APIMethod = "Player.Open"
	APIMethodPlayerGetActivePlayers  APIMethod = "Player.GetActivePlayers"
	APIMethodPlayerStop              APIMethod = "Player.Stop"
	APIMethodVideoLibraryGetMovies   APIMethod = "VideoLibrary.GetMovies"
	APIMethodVideoLibraryGetTVShows  APIMethod = "VideoLibrary.GetTVShows"
	APIMethodVideoLibraryGetEpisodes APIMethod = "VideoLibrary.GetEpisodes"

	// Audio Library
	APIMethodAudioLibraryGetSongs   APIMethod = "AudioLibrary.GetSongs"
	APIMethodAudioLibraryGetAlbums  APIMethod = "AudioLibrary.GetAlbums"
	APIMethodAudioLibraryGetArtists APIMethod = "AudioLibrary.GetArtists"

	// Playlist Management (for collections)
	APIMethodPlaylistClear APIMethod = "Playlist.Clear"
	APIMethodPlaylistAdd   APIMethod = "Playlist.Add"
)

Kodi API methods

type APIPayload

type APIPayload struct {
	Params  any       `json:"params,omitempty"`
	JSONRPC string    `json:"jsonrpc"`
	ID      string    `json:"id"`
	Method  APIMethod `json:"method"`
}

APIPayload represents a Kodi JSON-RPC request

type APIResponse

type APIResponse struct {
	Error   *APIError       `json:"error,omitempty"`
	ID      string          `json:"id"`
	JSONRPC string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result"`
}

APIResponse represents a Kodi JSON-RPC response

type Album

type Album struct {
	Label  string `json:"label"`
	Artist string `json:"artist"`
	ID     int    `json:"albumid"`
	Year   int    `json:"year"`
}

Album represents an album in Kodi's library

type Artist

type Artist struct {
	Label string `json:"label"`
	ID    int    `json:"artistid"`
}

Artist represents an artist in Kodi's library

type AudioLibraryGetAlbumsResponse

type AudioLibraryGetAlbumsResponse struct {
	Albums []Album `json:"albums"`
}

AudioLibraryGetAlbumsResponse represents the response from AudioLibrary.GetAlbums

type AudioLibraryGetArtistsResponse

type AudioLibraryGetArtistsResponse struct {
	Artists []Artist `json:"artists"`
}

AudioLibraryGetArtistsResponse represents the response from AudioLibrary.GetArtists

type AudioLibraryGetSongsParams

type AudioLibraryGetSongsParams struct {
	Filter *FilterRule `json:"filter,omitempty"`
}

AudioLibraryGetSongsParams represents parameters for AudioLibrary.GetSongs API method

type AudioLibraryGetSongsResponse

type AudioLibraryGetSongsResponse struct {
	Songs []Song `json:"songs"`
}

AudioLibraryGetSongsResponse represents the response from AudioLibrary.GetSongs

type Client

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

Client implements the KodiClient interface

func (*Client) APIRequest

func (c *Client) APIRequest(method APIMethod, params any) (json.RawMessage, error)

APIRequest makes a raw JSON-RPC request to Kodi API

func (*Client) GetActivePlayers

func (c *Client) GetActivePlayers() ([]Player, error)

GetActivePlayers retrieves all active players in Kodi

func (*Client) GetAlbums

func (c *Client) GetAlbums() ([]Album, error)

GetAlbums retrieves all albums from Kodi's library

func (*Client) GetArtists

func (c *Client) GetArtists() ([]Artist, error)

GetArtists retrieves all artists from Kodi's library

func (*Client) GetEpisodes

func (c *Client) GetEpisodes(tvShowID int) ([]Episode, error)

GetEpisodes retrieves all episodes for a specific TV show from Kodi's library

func (*Client) GetMovies

func (c *Client) GetMovies() ([]Movie, error)

GetMovies retrieves all movies from Kodi's library

func (*Client) GetSongs

func (c *Client) GetSongs() ([]Song, error)

GetSongs retrieves all songs from Kodi's library

func (*Client) GetTVShows

func (c *Client) GetTVShows() ([]TVShow, error)

GetTVShows retrieves all TV shows from Kodi's library

func (*Client) GetURL

func (c *Client) GetURL() string

GetURL returns the current Kodi API URL

func (*Client) LaunchAlbum

func (c *Client) LaunchAlbum(path string) error

LaunchAlbum launches an album by ID using playlist generation

func (*Client) LaunchArtist

func (c *Client) LaunchArtist(path string) error

LaunchArtist launches an artist by ID using playlist generation

func (*Client) LaunchFile

func (c *Client) LaunchFile(path string) error

LaunchFile launches a local file or URL in Kodi

func (*Client) LaunchMovie

func (c *Client) LaunchMovie(path string) error

LaunchMovie launches a movie by ID from Kodi's library

func (*Client) LaunchSong

func (c *Client) LaunchSong(path string) error

LaunchSong launches a song by ID from Kodi's library

func (*Client) LaunchTVEpisode

func (c *Client) LaunchTVEpisode(path string) error

LaunchTVEpisode launches a TV episode by ID from Kodi's library

func (*Client) LaunchTVShow

func (c *Client) LaunchTVShow(path string) error

LaunchTVShow launches a TV show by ID using playlist generation

func (*Client) SetURL

func (c *Client) SetURL(url string)

SetURL sets the Kodi API URL

func (*Client) Stop

func (c *Client) Stop() error

Stop stops all active players in Kodi

type Episode

type Episode struct {
	Label    string `json:"label"`
	File     string `json:"file,omitempty"`
	ID       int    `json:"episodeid"`
	TVShowID int    `json:"tvshowid"`
	Season   int    `json:"season"`
	Episode  int    `json:"episode"`
}

Episode represents a TV episode in Kodi's library

type FilterRule

type FilterRule struct {
	Value    any    `json:"value"`
	Field    string `json:"field"`
	Operator string `json:"operator"`
}

FilterRule represents a Kodi API filter rule

type Item

type Item struct {
	Label      string `json:"label,omitempty"`
	File       string `json:"file,omitempty"`
	MovieID    int    `json:"movieid,omitempty"`
	TVShowID   int    `json:"tvshowid,omitempty"`
	EpisodeID  int    `json:"episodeid,omitempty"`
	SongID     int    `json:"songid,omitempty"`
	PlaylistID int    `json:"playlistid,omitempty"`
}

Item represents a media item that can be played

type ItemOptions

type ItemOptions struct {
	Resume bool `json:"resume"`
}

ItemOptions represents options for playing a media item

type KodiClient

type KodiClient interface {
	// LaunchFile launches a local file or URL in Kodi
	LaunchFile(path string) error

	// LaunchMovie launches a movie by ID from Kodi's library
	// Path format: "kodi-movie://[id]/[name]"
	LaunchMovie(path string) error

	// LaunchTVEpisode launches a TV episode by ID from Kodi's library
	// Path format: "kodi-episode://[id]/[name]"
	LaunchTVEpisode(path string) error

	// Stop stops all active players in Kodi
	Stop() error

	// GetActivePlayers retrieves all active players in Kodi
	GetActivePlayers() ([]Player, error)

	// GetMovies retrieves all movies from Kodi's library
	GetMovies() ([]Movie, error)

	// GetTVShows retrieves all TV shows from Kodi's library
	GetTVShows() ([]TVShow, error)

	// GetEpisodes retrieves all episodes for a specific TV show from Kodi's library
	GetEpisodes(tvShowID int) ([]Episode, error)

	// GetSongs retrieves all songs from Kodi's library
	GetSongs() ([]Song, error)

	// GetAlbums retrieves all albums from Kodi's library
	GetAlbums() ([]Album, error)

	// GetArtists retrieves all artists from Kodi's library
	GetArtists() ([]Artist, error)

	// LaunchSong launches a song by ID from Kodi's library
	// Path format: "kodi-song://[id]/[name]"
	LaunchSong(path string) error

	// LaunchAlbum launches an album by ID using playlist generation
	// Path format: "kodi-album://[id]/[name]"
	LaunchAlbum(path string) error

	// LaunchArtist launches an artist by ID using playlist generation
	// Path format: "kodi-artist://[id]/[name]"
	LaunchArtist(path string) error

	// LaunchTVShow launches a TV show by ID using playlist generation
	// Path format: "kodi-show://[id]/[name]"
	LaunchTVShow(path string) error

	// GetURL returns the current Kodi API URL
	GetURL() string

	// SetURL sets the Kodi API URL
	SetURL(url string)

	// APIRequest makes a raw JSON-RPC request to Kodi API
	APIRequest(method APIMethod, params any) (json.RawMessage, error)
}

KodiClient defines the interface for Kodi API operations. This interface enables proper mocking and TDD for Kodi integration.

func NewClient

func NewClient(cfg *config.Instance) KodiClient

NewClient creates a new Kodi client with configuration-based URL

func NewClientWithLauncherID

func NewClientWithLauncherID(cfg *config.Instance, launcherID string) KodiClient

NewClientWithLauncherID creates a new Kodi client with hierarchical configuration lookup

type Movie

type Movie struct {
	Label string `json:"label"`
	File  string `json:"file,omitempty"`
	ID    int    `json:"movieid"`
}

Movie represents a movie in Kodi's library

type Player

type Player struct {
	Type string `json:"type"`
	ID   int    `json:"playerid"`
}

Player represents an active Kodi player

type PlayerOpenParams

type PlayerOpenParams struct {
	Item    Item        `json:"item"`
	Options ItemOptions `json:"options,omitempty"`
}

PlayerOpenParams represents parameters for Player.Open API method

type PlayerStopParams

type PlayerStopParams struct {
	PlayerID int `json:"playerid"`
}

PlayerStopParams represents parameters for Player.Stop API method

type PlaylistAddEpisodesParams

type PlaylistAddEpisodesParams struct {
	Item       []PlaylistItemEpisodeID `json:"item"`
	PlaylistID int                     `json:"playlistid"`
}

PlaylistAddEpisodesParams represents parameters for Playlist.Add API method with episodes

type PlaylistAddParams

type PlaylistAddParams struct {
	Item       []PlaylistItemSongID `json:"item"`
	PlaylistID int                  `json:"playlistid"`
}

PlaylistAddParams represents parameters for Playlist.Add API method

type PlaylistClearParams

type PlaylistClearParams struct {
	PlaylistID int `json:"playlistid"`
}

PlaylistClearParams represents parameters for Playlist.Clear API method

type PlaylistItemEpisodeID

type PlaylistItemEpisodeID struct {
	EpisodeID int `json:"episodeid"`
}

PlaylistItemEpisodeID represents an episode item for playlist operations

type PlaylistItemSongID

type PlaylistItemSongID struct {
	SongID int `json:"songid"`
}

PlaylistItemSongID represents a song item for playlist operations

type Song

type Song struct {
	Label    string `json:"label"`
	File     string `json:"file,omitempty"`
	Artist   string `json:"artist"`
	ID       int    `json:"songid"`
	AlbumID  int    `json:"albumid"`
	Duration int    `json:"duration"`
}

Song represents a song in Kodi's library

type TVShow

type TVShow struct {
	Label string `json:"label"`
	ID    int    `json:"tvshowid"`
}

TVShow represents a TV show in Kodi's library

type VideoLibraryGetEpisodesParams

type VideoLibraryGetEpisodesParams struct {
	TVShowID int `json:"tvshowid"`
}

VideoLibraryGetEpisodesParams represents parameters for VideoLibrary.GetEpisodes API method

type VideoLibraryGetEpisodesResponse

type VideoLibraryGetEpisodesResponse struct {
	Episodes []Episode `json:"episodes"`
}

VideoLibraryGetEpisodesResponse represents the response from VideoLibrary.GetEpisodes

type VideoLibraryGetMoviesResponse

type VideoLibraryGetMoviesResponse struct {
	Movies []Movie `json:"movies"`
}

VideoLibraryGetMoviesResponse represents the response from VideoLibrary.GetMovies

type VideoLibraryGetTVShowsResponse

type VideoLibraryGetTVShowsResponse struct {
	TVShows []TVShow `json:"tvshows"`
}

VideoLibraryGetTVShowsResponse represents the response from VideoLibrary.GetTVShows

Jump to

Keyboard shortcuts

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