Documentation
¶
Index ¶
- func CheckAllProviders(ctx context.Context)
- func Clear()
- func ConfigureAll(cfg *config.Config, logger *slog.Logger)
- func Count() int
- func List() []string
- func Register(provider Provider) error
- func Unregister(name string) error
- type AudioTrack
- type Configurable
- type Episode
- func GetChaptersAsEpisodesFromAPIInfo(ir api.InfoResponse) []Episode
- func GetEpisodesFromAPIInfo(ir api.InfoResponse, seasonNumber int) []Episode
- func GetEpisodesFromAPIInfoWithMediaID(ir api.InfoResponse, seasonNumber int, mediaID string) []Episode
- func ParseEpisodeRange(allEpisodes []Episode, rangeStr string) ([]Episode, error)
- type ErrInvalidQuality
- type HealthCheckResult
- type MangaProvider
- type Media
- type MediaDetails
- type MediaType
- type Provider
- type ProviderStatus
- type Quality
- type Registry
- func (r *Registry) CheckAllProviders(ctx context.Context)
- func (r *Registry) Clear()
- func (r *Registry) Count() int
- func (r *Registry) Get(name string) (Provider, error)
- func (r *Registry) GetAll() []Provider
- func (r *Registry) GetByType(mediaType MediaType) []Provider
- func (r *Registry) GetProviderStatuses() []*ProviderStatus
- func (r *Registry) List() []string
- func (r *Registry) Reconfigure(cfg *config.Config, logger *slog.Logger)
- func (r *Registry) Register(provider Provider) error
- func (r *Registry) Unregister(name string) error
- type RemoteProvider
- func (p *RemoteProvider) GetAvailableQualities(ctx context.Context, episodeID string) ([]Quality, error)
- func (p *RemoteProvider) GetEpisodes(ctx context.Context, seasonID string) ([]Episode, error)
- func (p *RemoteProvider) GetMediaDetails(ctx context.Context, id string) (*MediaDetails, error)
- func (p *RemoteProvider) GetRecent(ctx context.Context) ([]Media, error)
- func (p *RemoteProvider) GetSeasons(ctx context.Context, mediaID string) ([]Season, error)
- func (p *RemoteProvider) GetStreamURL(ctx context.Context, episodeID string, quality Quality) (*StreamURL, error)
- func (p *RemoteProvider) GetTrending(ctx context.Context) ([]Media, error)
- func (p *RemoteProvider) HealthCheck(ctx context.Context) error
- func (p *RemoteProvider) Name() string
- func (p *RemoteProvider) Search(ctx context.Context, query string) ([]Media, error)
- func (p *RemoteProvider) Type() MediaType
- type Season
- type StreamType
- type StreamURL
- type Subtitle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAllProviders ¶
CheckAllProviders runs health checks on all providers in the global registry.
func ConfigureAll ¶
ConfigureAll configures all registered providers that implement the Configurable interface
func Count ¶
func Count() int
Count returns the number of registered providers in the global registry
func List ¶
func List() []string
List returns the names of all registered providers from the global registry
func Unregister ¶
Unregister removes a provider from the global registry
Types ¶
type AudioTrack ¶
type AudioTrack struct {
Index int `json:"index"` // mpv track index (1-based)
Language string `json:"language"` // "en", "ja", etc.
Label string `json:"label"` // Provider's original label: "English (Dub)", "Japanese (Original)"
Type string `json:"type"` // "dub", "sub", "original", "unknown"
}
AudioTrack represents an audio track option
type Configurable ¶
Configurable is an interface for providers that can be configured at runtime
type Episode ¶
type Episode struct {
ID string `json:"id"`
Number int `json:"number"`
Season int `json:"season"`
Title string `json:"title"`
Synopsis string `json:"synopsis"`
ThumbnailURL string `json:"thumbnail_url"`
Duration time.Duration `json:"duration"`
ReleaseDate time.Time `json:"release_date"`
}
Episode represents a single episode or movie
func GetChaptersAsEpisodesFromAPIInfo ¶
func GetChaptersAsEpisodesFromAPIInfo(ir api.InfoResponse) []Episode
GetChaptersAsEpisodesFromAPIInfo converts manga chapters to episodes
func GetEpisodesFromAPIInfo ¶
func GetEpisodesFromAPIInfo(ir api.InfoResponse, seasonNumber int) []Episode
GetEpisodesFromAPIInfo extracts episodes for a specific season from InfoResponse
func GetEpisodesFromAPIInfoWithMediaID ¶
func GetEpisodesFromAPIInfoWithMediaID(ir api.InfoResponse, seasonNumber int, mediaID string) []Episode
GetEpisodesFromAPIInfoWithMediaID extracts episodes with full media ID prefix for providers like HiAnime Format: {mediaID}$episode${episodeID}
func ParseEpisodeRange ¶
ParseEpisodeRange parses an episode range string (e.g., "1-5,7,9-12") and returns the matching episodes from the provided list.
Supported formats:
- Single episode: "5"
- Range: "1-5"
- Multiple: "1-5,7,9-12"
type ErrInvalidQuality ¶
type ErrInvalidQuality struct {
Quality string
}
ErrInvalidQuality is returned when an invalid quality string is provided
func (*ErrInvalidQuality) Error ¶
func (e *ErrInvalidQuality) Error() string
type HealthCheckResult ¶
type HealthCheckResult struct {
URL string
CurlCommand string
StatusCode int
Duration time.Duration
Error string
CheckedAt time.Time
}
HealthCheckResult holds detailed health check information
type MangaProvider ¶
type MangaProvider interface {
Provider
GetMangaPages(ctx context.Context, chapterID string) ([]string, error)
}
MangaProvider defines the interface for manga providers
type Media ¶
type Media struct {
ID string `json:"id"`
Title string `json:"title"`
Type MediaType `json:"type"`
Year int `json:"year"`
Synopsis string `json:"synopsis"`
PosterURL string `json:"poster_url"`
Rating float64 `json:"rating"`
Genres []string `json:"genres"`
TotalEpisodes int `json:"total_episodes"`
Status string `json:"status"` // "Ongoing", "Completed", etc.
}
Media represents a single media item
func APIResultToMedia ¶
func APIResultToMedia(sr api.SearchResult, mediaType MediaType) Media
APIResultToMedia converts a SearchResult to Media
type MediaDetails ¶
type MediaDetails struct {
Media
Seasons []Season `json:"seasons"`
Cast []string `json:"cast"`
Studio string `json:"studio"` // For anime
Director string `json:"director"` // For movies
AniListID int `json:"anilist_id,omitempty"`
IMDBID string `json:"imdb_id,omitempty"`
}
MediaDetails provides extended information about a media item
func APIInfoToMediaDetails ¶
func APIInfoToMediaDetails(ir api.InfoResponse, mediaType MediaType) *MediaDetails
APIInfoToMediaDetails converts InfoResponse to MediaDetails
type MediaType ¶
type MediaType string
MediaType represents the type of media content
const ( MediaTypeAnime MediaType = "anime" MediaTypeMovie MediaType = "movie" MediaTypeTV MediaType = "tv" MediaTypeMovieTV MediaType = "movie_tv" // Supports both movies and TV MediaTypeAnimeMovieTV MediaType = "anime_movie_tv" // Supports anime, movies, and TV MediaTypeManga MediaType = "manga" // Supports manga MediaTypeAll MediaType = "all" // Supports all types )
type Provider ¶
type Provider interface {
// Metadata
Name() string
Type() MediaType
// Search and discovery
Search(ctx context.Context, query string) ([]Media, error)
GetTrending(ctx context.Context) ([]Media, error)
GetRecent(ctx context.Context) ([]Media, error)
// Media details
GetMediaDetails(ctx context.Context, id string) (*MediaDetails, error)
GetSeasons(ctx context.Context, mediaID string) ([]Season, error)
GetEpisodes(ctx context.Context, seasonID string) ([]Episode, error)
// Stream URLs
GetStreamURL(ctx context.Context, episodeID string, quality Quality) (*StreamURL, error)
GetAvailableQualities(ctx context.Context, episodeID string) ([]Quality, error)
// Health check
HealthCheck(ctx context.Context) error
}
Provider defines the interface for streaming providers
type ProviderStatus ¶
type ProviderStatus struct {
ProviderName string
Healthy bool
Status string // e.g., "Online", "Offline", "Error: ...", "Checking..."
LastCheck time.Time
LastResult *HealthCheckResult
}
ProviderStatus holds the health status of a provider
func GetProviderStatuses ¶
func GetProviderStatuses() []*ProviderStatus
GetProviderStatuses returns the health statuses from the global registry.
type Quality ¶
type Quality string
Quality represents video quality levels
func ParseQuality ¶
ParseQuality parses a quality string into a Quality type
func (Quality) ResolutionHeight ¶
ResolutionHeight returns the vertical resolution in pixels
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages registered providers and their health statuses
func (*Registry) CheckAllProviders ¶
CheckAllProviders runs a health check on all registered providers concurrently.
func (*Registry) GetProviderStatuses ¶
func (r *Registry) GetProviderStatuses() []*ProviderStatus
GetProviderStatuses returns the health status of all registered providers.
func (*Registry) Reconfigure ¶
Reconfigure updates providers based on configuration
func (*Registry) Unregister ¶
Unregister removes a provider from the registry
type RemoteProvider ¶
type RemoteProvider struct {
// contains filtered or unexported fields
}
RemoteProvider adapts the local Provider interface to a remote API
func NewRemoteProvider ¶
func NewRemoteProvider(name string, pType MediaType, cfg *config.Config, logger *slog.Logger) *RemoteProvider
NewRemoteProvider creates a new remote provider adapter
func (*RemoteProvider) GetAvailableQualities ¶
func (*RemoteProvider) GetEpisodes ¶
func (*RemoteProvider) GetMediaDetails ¶
func (p *RemoteProvider) GetMediaDetails(ctx context.Context, id string) (*MediaDetails, error)
func (*RemoteProvider) GetRecent ¶
func (p *RemoteProvider) GetRecent(ctx context.Context) ([]Media, error)
func (*RemoteProvider) GetSeasons ¶
func (*RemoteProvider) GetStreamURL ¶
func (*RemoteProvider) GetTrending ¶
func (p *RemoteProvider) GetTrending(ctx context.Context) ([]Media, error)
func (*RemoteProvider) HealthCheck ¶
func (p *RemoteProvider) HealthCheck(ctx context.Context) error
func (*RemoteProvider) Name ¶
func (p *RemoteProvider) Name() string
func (*RemoteProvider) Type ¶
func (p *RemoteProvider) Type() MediaType
type StreamType ¶
type StreamType string
StreamType represents the type of stream
const ( StreamTypeHLS StreamType = "hls" // HTTP Live Streaming (.m3u8) StreamTypeDASH StreamType = "dash" // MPEG-DASH (.mpd) StreamTypeMP4 StreamType = "mp4" // Direct MP4 StreamTypeMKV StreamType = "mkv" // Direct MKV )
type StreamURL ¶
type StreamURL struct {
URL string `json:"url"`
Quality Quality `json:"quality"`
Type StreamType `json:"type"`
Headers map[string]string `json:"headers,omitempty"`
Subtitles []Subtitle `json:"subtitles,omitempty"`
AudioTracks []AudioTrack `json:"audio_tracks,omitempty"`
Referer string `json:"referer,omitempty"`
}
StreamURL contains streaming information