Documentation
¶
Index ¶
- Constants
- func CalculateProgressPercent(positionSeconds, durationSeconds int) int
- func CoreWidgets() []sdk.Widget
- func FormatRemainingTime(positionSeconds, durationSeconds int) string
- type ContinueWatchingService
- type ContinueWatchingServiceImpl
- type FavoritesService
- type FavoritesServiceImpl
- func (s *FavoritesServiceImpl) GetFavorites(ctx context.Context, userID string, limit int) ([]*home.MediaItem, error)
- func (s *FavoritesServiceImpl) GetFavoritesFull(ctx context.Context, userID string, limit int) ([]MediaItemWithTime, error)
- func (s *FavoritesServiceImpl) HasFavorites(ctx context.Context, userID string) bool
- type GenresService
- type GenresServiceImpl
- type MediaItemWithTime
- type PluginLookup
- type PluginWidgetFetcher
- type RecentlyAddedService
- type RecentlyAddedServiceImpl
- func (s *RecentlyAddedServiceImpl) GetRecentlyAdded(ctx context.Context, limit int) ([]*home.MediaItem, error)
- func (s *RecentlyAddedServiceImpl) GetRecentlyAddedFull(ctx context.Context, limit int) ([]MediaItemWithTime, error)
- func (s *RecentlyAddedServiceImpl) GetRecentlyAddedMovies(ctx context.Context, limit int) ([]*home.MediaItem, error)
- func (s *RecentlyAddedServiceImpl) GetRecentlyAddedTVShows(ctx context.Context, limit int) ([]*home.MediaItem, error)
- type Service
- func (s *Service) GetHome(ctx context.Context, req *home.HomeRequest) (*home.HomeResponse, error)
- func (s *Service) GetPreferences(ctx context.Context, userID string) ([]*home.WidgetPreference, error)
- func (s *Service) GetSection(ctx context.Context, sectionID, userID, clientType string) (*home.Section, error)
- func (s *Service) ResetPreferences(ctx context.Context, userID string) error
- func (s *Service) UpdatePreferences(ctx context.Context, userID string, req *home.PreferencesUpdateRequest) error
- type TrendingService
- type WidgetDataFetcher
Constants ¶
const CorePluginID = "core"
CorePluginID is the plugin ID used for core (built-in) widgets.
Variables ¶
This section is empty.
Functions ¶
func CalculateProgressPercent ¶
CalculateProgressPercent calculates progress as a percentage (0-100).
func CoreWidgets ¶
CoreWidgets returns the built-in widgets provided by the core application. These widgets work without any plugins installed.
func FormatRemainingTime ¶
FormatRemainingTime formats the remaining time as a human-readable string. Returns "Xh Ym left" for durations >= 1 hour, "X min left" for shorter durations. Returns empty string if remaining time is <= 0.
Types ¶
type ContinueWatchingService ¶
type ContinueWatchingService interface {
// HasHistory returns true if the user has watch history.
HasHistory(ctx context.Context, userID string) bool
// GetContinueWatchingFull returns items the user is currently watching with full typed data.
GetContinueWatchingFull(ctx context.Context, userID string, limit int) ([]MediaItemWithTime, error)
}
ContinueWatchingService provides continue watching data.
type ContinueWatchingServiceImpl ¶
type ContinueWatchingServiceImpl struct {
// contains filtered or unexported fields
}
ContinueWatchingServiceImpl implements ContinueWatchingService.
func NewContinueWatchingService ¶
func NewContinueWatchingService( progressRepo progress.Repository, mediaRepo media.Repository, movieRepo media.MovieRepository, tvRepo media.TVRepository, ) *ContinueWatchingServiceImpl
NewContinueWatchingService creates a new continue watching service.
func (*ContinueWatchingServiceImpl) GetContinueWatchingFull ¶
func (s *ContinueWatchingServiceImpl) GetContinueWatchingFull(ctx context.Context, userID string, limit int) ([]MediaItemWithTime, error)
GetContinueWatchingFull returns items the user is currently watching with full typed data.
func (*ContinueWatchingServiceImpl) HasHistory ¶
func (s *ContinueWatchingServiceImpl) HasHistory(ctx context.Context, userID string) bool
HasHistory returns true if the user has watch history.
type FavoritesService ¶
type FavoritesService interface {
// HasFavorites returns true if the user has any favorites.
HasFavorites(ctx context.Context, userID string) bool
// GetFavorites returns the user's favorite media items.
GetFavorites(ctx context.Context, userID string, limit int) ([]*home.MediaItem, error)
// GetFavoritesFull returns favorite media with full typed data.
GetFavoritesFull(ctx context.Context, userID string, limit int) ([]MediaItemWithTime, error)
}
FavoritesService provides user favorites data.
type FavoritesServiceImpl ¶
type FavoritesServiceImpl struct {
// contains filtered or unexported fields
}
FavoritesServiceImpl implements FavoritesService.
func NewFavoritesService ¶
func NewFavoritesService( movieRepo media.MovieRepository, tvRepo media.TVRepository, ratingsRepo ratings.Repository, ) *FavoritesServiceImpl
NewFavoritesService creates a new favorites service.
func (*FavoritesServiceImpl) GetFavorites ¶
func (s *FavoritesServiceImpl) GetFavorites(ctx context.Context, userID string, limit int) ([]*home.MediaItem, error)
GetFavorites returns the user's favorite media items.
func (*FavoritesServiceImpl) GetFavoritesFull ¶
func (s *FavoritesServiceImpl) GetFavoritesFull(ctx context.Context, userID string, limit int) ([]MediaItemWithTime, error)
GetFavoritesFull returns favorite media with full typed data.
func (*FavoritesServiceImpl) HasFavorites ¶
func (s *FavoritesServiceImpl) HasFavorites(ctx context.Context, userID string) bool
HasFavorites returns true if the user has any favorites.
type GenresService ¶
type GenresService interface {
// GetDistinctGenres returns distinct genres from the library.
GetDistinctGenres(ctx context.Context, limit int) ([]string, error)
}
GenresService provides genre data for search suggestions.
type GenresServiceImpl ¶
type GenresServiceImpl struct {
// contains filtered or unexported fields
}
GenresServiceImpl implements GenresService using the movie repository.
func NewGenresService ¶
func NewGenresService(movieRepo media.MovieRepository) *GenresServiceImpl
NewGenresService creates a new genres service.
func (*GenresServiceImpl) GetDistinctGenres ¶
GetDistinctGenres returns distinct genres from the library.
type MediaItemWithTime ¶
type MediaItemWithTime struct {
Type string // "movie" or "tv_show"
Movie *movies.MovieResponse
TVShow *tv.TVShowSummary
CreatedAt time.Time
UpdatedAt time.Time
// Progress contains playback progress (for continue watching).
Progress *home.MediaProgress
// EpisodeContext contains episode details for TV shows (for continue watching).
EpisodeContext *home.EpisodeContext
}
MediaItemWithTime wraps a typed media item with its creation time for sorting.
type PluginLookup ¶
type PluginLookup interface {
// GetPlugin returns a plugin instance by ID.
GetPlugin(id string) (*types.Instance, bool)
}
PluginLookup provides access to plugin instances.
type PluginWidgetFetcher ¶
type PluginWidgetFetcher struct {
// contains filtered or unexported fields
}
PluginWidgetFetcher fetches widget data from plugins via gRPC.
func NewPluginWidgetFetcher ¶
func NewPluginWidgetFetcher(plugins PluginLookup, logger *slog.Logger) *PluginWidgetFetcher
NewPluginWidgetFetcher creates a new widget data fetcher.
func (*PluginWidgetFetcher) FetchWidgetData ¶
func (f *PluginWidgetFetcher) FetchWidgetData(ctx context.Context, pluginID, path, userID, clientType string, params map[string]string) (map[string]any, error)
FetchWidgetData fetches data for a widget from a plugin. The path is the widget's configured endpoint (e.g., "/recommendations/for-you"). The params map contains additional query parameters from endpoint_params config.
type RecentlyAddedService ¶
type RecentlyAddedService interface {
// GetRecentlyAdded returns recently added media items.
GetRecentlyAdded(ctx context.Context, limit int) ([]*home.MediaItem, error)
// GetRecentlyAddedFull returns recently added media with full typed data.
GetRecentlyAddedFull(ctx context.Context, limit int) ([]MediaItemWithTime, error)
}
RecentlyAddedService provides recently added media data.
type RecentlyAddedServiceImpl ¶
type RecentlyAddedServiceImpl struct {
// contains filtered or unexported fields
}
RecentlyAddedServiceImpl implements RecentlyAddedService.
func NewRecentlyAddedService ¶
func NewRecentlyAddedService(movieRepo media.MovieRepository, tvRepo media.TVRepository) *RecentlyAddedServiceImpl
NewRecentlyAddedService creates a new recently added service.
func (*RecentlyAddedServiceImpl) GetRecentlyAdded ¶
func (s *RecentlyAddedServiceImpl) GetRecentlyAdded(ctx context.Context, limit int) ([]*home.MediaItem, error)
GetRecentlyAdded returns recently added media items (movies and TV shows combined).
func (*RecentlyAddedServiceImpl) GetRecentlyAddedFull ¶
func (s *RecentlyAddedServiceImpl) GetRecentlyAddedFull(ctx context.Context, limit int) ([]MediaItemWithTime, error)
GetRecentlyAddedFull returns recently added media with full typed data for frontend components.
func (*RecentlyAddedServiceImpl) GetRecentlyAddedMovies ¶
func (s *RecentlyAddedServiceImpl) GetRecentlyAddedMovies(ctx context.Context, limit int) ([]*home.MediaItem, error)
GetRecentlyAddedMovies returns recently added movies only.
func (*RecentlyAddedServiceImpl) GetRecentlyAddedTVShows ¶
func (s *RecentlyAddedServiceImpl) GetRecentlyAddedTVShows(ctx context.Context, limit int) ([]*home.MediaItem, error)
GetRecentlyAddedTVShows returns recently added TV shows only.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service aggregates widgets from all plugins and builds the home response.
func NewService ¶
func NewService( widgetRegistry *registry.WidgetRegistry, searchProviders *registry.SearchProviderRegistry, trendingProviders *registry.TrendingProviderRegistry, capabilityRegistry *registry.CapabilityRegistry, preferencesRepo home.PreferencesRepository, widgetDataFetcher WidgetDataFetcher, continueWatching ContinueWatchingService, recentlyAdded RecentlyAddedService, favorites FavoritesService, genres GenresService, trending TrendingService, logger *slog.Logger, ) *Service
NewService creates a new home service.
func (*Service) GetHome ¶
func (s *Service) GetHome(ctx context.Context, req *home.HomeRequest) (*home.HomeResponse, error)
GetHome returns the home screen data.
func (*Service) GetPreferences ¶
func (s *Service) GetPreferences(ctx context.Context, userID string) ([]*home.WidgetPreference, error)
GetPreferences returns the user's widget preferences.
func (*Service) GetSection ¶
func (s *Service) GetSection(ctx context.Context, sectionID, userID, clientType string) (*home.Section, error)
GetSection returns a single section's data.
func (*Service) ResetPreferences ¶
ResetPreferences removes all user preferences, resetting to defaults.
func (*Service) UpdatePreferences ¶
func (s *Service) UpdatePreferences(ctx context.Context, userID string, req *home.PreferencesUpdateRequest) error
UpdatePreferences updates the user's widget preferences.
type TrendingService ¶
type TrendingService interface {
// GetTrending returns trending items matched to the local library.
GetTrending(ctx context.Context, mediaType string, limit int) (*apptrending.Result, error)
// HasProvider returns true if a trending provider is available.
HasProvider() bool
}
TrendingService provides trending media data.
type WidgetDataFetcher ¶
type WidgetDataFetcher interface {
// FetchWidgetData fetches data for a widget.
// The path is the widget's configured endpoint (e.g., "/recommendations").
// The params map contains additional query parameters from endpoint_params config.
FetchWidgetData(ctx context.Context, pluginID, path, userID, clientType string, params map[string]string) (map[string]any, error)
}
WidgetDataFetcher fetches data for a widget from a plugin.