Documentation
¶
Overview ¶
Package openwebif provides a client for interacting with Enigma2 OpenWebIF API.
Package openwebif provides OpenWebIF client functionality for Enigma2 receivers.
Package openwebif provides OpenWebIF client functionality for Enigma2 receivers.
Index ¶
- func IsEnabled() bool
- func PiconURL(owiBase, sref string) string
- func StreamURL(base, ref, name string) (string, error)
- type BouquetsResponse
- type Cacher
- type Client
- func (c *Client) Bouquets(ctx context.Context) (map[string]string, error)
- func (c *Client) GetBouquetEPG(ctx context.Context, bouquetRef string, days int) ([]EPGEvent, error)
- func (c *Client) GetEPG(ctx context.Context, sRef string, days int) ([]EPGEvent, error)
- func (c *Client) Services(ctx context.Context, bouquetRef string) ([][2]string, error)
- func (c *Client) StreamURL(ctx context.Context, ref, name string) (string, error)
- type ClientInterface
- type EPGEvent
- type EPGResponse
- type MockServer
- func (m *MockServer) AddBouquet(ref, name string)
- func (m *MockServer) AddEPGEvent(serviceRef string, event EPGEvent)
- func (m *MockServer) AddService(bouquetRef, serviceRef, serviceName string)
- func (m *MockServer) Reset()
- func (m *MockServer) SetDefaultData()
- func (m *MockServer) SetDelay(endpoint string, delayMS int)
- func (m *MockServer) SetFailures(endpoint string, count int)
- func (m *MockServer) URL() string
- type Options
- type ServicesResponse
- type StreamDetector
- type StreamInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEnabled ¶ added in v1.2.0
func IsEnabled() bool
IsEnabled checks if smart stream detection is enabled. Default: enabled for automatic OSCam Streamrelay detection Can be disabled with XG2G_SMART_STREAM_DETECTION=false
Types ¶
type BouquetsResponse ¶ added in v1.5.0
type BouquetsResponse struct {
Services [][]interface{} `json:"services"`
}
BouquetsResponse matches OpenWebIF API structure.
type Cacher ¶ added in v1.7.0
type Cacher interface {
Get(key string) (any, bool)
Set(key string, value any, ttl time.Duration)
Delete(key string)
Clear()
}
Cacher provides caching capabilities for OpenWebIF requests. This interface allows for different cache implementations (memory, Redis, etc.).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an OpenWebIF HTTP client for communicating with Enigma2 receivers.
func NewWithPort ¶
NewWithPort creates a new OpenWebIF client with a specific port.
func (*Client) GetBouquetEPG ¶
func (c *Client) GetBouquetEPG(ctx context.Context, bouquetRef string, days int) ([]EPGEvent, error)
GetBouquetEPG fetches EPG events for an entire bouquet
func (*Client) GetEPG ¶
GetEPG retrieves EPG data for a specific service reference over specified days
type ClientInterface ¶
type ClientInterface interface {
Bouquets(ctx context.Context) (map[string]string, error)
Services(ctx context.Context, bouquetRef string) ([][2]string, error)
StreamURL(ctx context.Context, ref, name string) (string, error)
}
ClientInterface defines the subset used by other packages and tests.
type EPGEvent ¶
type EPGEvent struct {
ID int `json:"id"` // Changed from string to int
Title string `json:"title"`
Description string `json:"shortdesc"`
LongDesc string `json:"longdesc"`
Begin int64 `json:"begin_timestamp"`
Duration int64 `json:"duration_sec"`
SRef string `json:"sref"`
}
EPGEvent represents a single programme entry from OpenWebIF EPG API
type EPGResponse ¶
EPGResponse represents the OpenWebIF EPG API response structure
type MockServer ¶ added in v1.5.0
MockServer provides a configurable OpenWebIF mock server for testing.
func NewMockServer ¶ added in v1.5.0
func NewMockServer() *MockServer
NewMockServer creates a new OpenWebIF mock server.
func (*MockServer) AddBouquet ¶ added in v1.5.0
func (m *MockServer) AddBouquet(ref, name string)
AddBouquet adds a bouquet to the mock server.
func (*MockServer) AddEPGEvent ¶ added in v1.5.0
func (m *MockServer) AddEPGEvent(serviceRef string, event EPGEvent)
AddEPGEvent adds an EPG event for a service.
func (*MockServer) AddService ¶ added in v1.5.0
func (m *MockServer) AddService(bouquetRef, serviceRef, serviceName string)
AddService adds a service to a bouquet.
func (*MockServer) Reset ¶ added in v1.5.0
func (m *MockServer) Reset()
Reset clears all mock data and resets to defaults.
func (*MockServer) SetDefaultData ¶ added in v1.5.0
func (m *MockServer) SetDefaultData()
SetDefaultData sets up realistic test data.
func (*MockServer) SetDelay ¶ added in v1.5.0
func (m *MockServer) SetDelay(endpoint string, delayMS int)
SetDelay sets an artificial delay (in milliseconds) for an endpoint.
func (*MockServer) SetFailures ¶ added in v1.5.0
func (m *MockServer) SetFailures(endpoint string, count int)
SetFailures sets the number of failures before success for an endpoint.
func (*MockServer) URL ¶ added in v1.5.0
func (m *MockServer) URL() string
URL returns the mock server's base URL.
type Options ¶
type Options struct {
Timeout time.Duration
ResponseHeaderTimeout time.Duration
MaxRetries int
Backoff time.Duration
MaxBackoff time.Duration
Username string
Password string
// Caching options (v1.3.0+)
Cache Cacher // Optional cache implementation
CacheTTL time.Duration // Cache TTL (default: 5 minutes)
}
Options configures the OpenWebIF client behavior.
type ServicesResponse ¶ added in v1.5.0
type ServicesResponse struct {
Services []map[string]interface{} `json:"services"`
}
ServicesResponse matches OpenWebIF API structure.
type StreamDetector ¶ added in v1.2.0
type StreamDetector struct {
// contains filtered or unexported fields
}
StreamDetector handles smart detection of optimal stream endpoints.
func NewStreamDetector ¶ added in v1.2.0
func NewStreamDetector(receiverHost string, logger zerolog.Logger) *StreamDetector
NewStreamDetector creates a new smart stream detector.
func (*StreamDetector) ClearCache ¶ added in v1.2.0
func (sd *StreamDetector) ClearCache()
ClearCache clears all cached stream detection results.
func (*StreamDetector) DetectBatch ¶ added in v1.2.0
func (sd *StreamDetector) DetectBatch(ctx context.Context, services [][2]string) (map[string]*StreamInfo, error)
DetectBatch detects optimal stream URLs for multiple services in parallel.
func (*StreamDetector) DetectStreamURL ¶ added in v1.2.0
func (sd *StreamDetector) DetectStreamURL(ctx context.Context, serviceRef, channelName string) (*StreamInfo, error)
DetectStreamURL determines the optimal stream URL for a given service reference. It tests multiple endpoints and returns the best working option.
type StreamInfo ¶ added in v1.2.0
type StreamInfo struct {
URL string // The working stream URL
Port int // Port used (8001, 17999, or proxy port)
SupportsHEAD bool // Whether the endpoint supports HEAD requests
UseProxy bool // Whether to use the integrated proxy
TestedAt time.Time // When this was last tested
TestError error // Last test error (if any)
}
StreamInfo contains information about a tested stream endpoint.