Documentation
¶
Index ¶
- Constants
- Variables
- func ProviderBaseURL(instance InstanceConfig, provider ProviderType) string
- func ProviderBaseURLConfigured(raw string) bool
- type ChannelMapping
- type ChannelMappingUpdate
- type ChannelsProvider
- func (p *ChannelsProvider) GetCustomMapping(ctx context.Context, lineupID string) (map[string]string, error)
- func (p *ChannelsProvider) ListDeviceChannels(ctx context.Context) (map[string]DVRDeviceChannel, error)
- func (p *ChannelsProvider) ListLineupStations(ctx context.Context, lineupID string) ([]DVRStation, error)
- func (p *ChannelsProvider) ListLineups(ctx context.Context) ([]DVRLineup, error)
- func (p *ChannelsProvider) PutCustomMapping(ctx context.Context, lineupID string, patch map[string]string) error
- func (p *ChannelsProvider) RedownloadGuideLineup(ctx context.Context, lineupID string) error
- func (p *ChannelsProvider) RefreshDevices(ctx context.Context) error
- func (p *ChannelsProvider) RefreshGuideStations(ctx context.Context) error
- func (p *ChannelsProvider) ReloadDeviceLineup(ctx context.Context, deviceID string) error
- func (p *ChannelsProvider) Type() ProviderType
- type ConfigState
- type DVRDeviceChannel
- type DVRLineup
- type DVRStation
- type InstanceConfig
- type JellyfinProvider
- func (p *JellyfinProvider) ListLineups(context.Context) ([]DVRLineup, error)
- func (p *JellyfinProvider) RedownloadGuideLineup(context.Context, string) error
- func (p *JellyfinProvider) RefreshGuideStations(context.Context) error
- func (p *JellyfinProvider) ReloadDeviceLineup(ctx context.Context, deviceID string) error
- func (p *JellyfinProvider) Type() ProviderType
- type LineupReloadProvider
- type LineupSyncResult
- type MappingProvider
- type ProviderBase
- type ProviderType
- type ReloadOutcome
- type ReverseSyncRequest
- type ReverseSyncResult
- type Service
- func (s *Service) GetChannelMapping(ctx context.Context, channelID int64) (ChannelMapping, error)
- func (s *Service) GetState(ctx context.Context) (ConfigState, error)
- func (s *Service) ListChannelMappings(ctx context.Context, enabledOnly bool, includeDynamic bool) ([]ChannelMapping, error)
- func (s *Service) ListChannelMappingsPaged(ctx context.Context, enabledOnly bool, includeDynamic bool, limit int, ...) ([]ChannelMapping, int, error)
- func (s *Service) ListLineups(ctx context.Context, refresh bool) ([]DVRLineup, error)
- func (s *Service) ReloadLineup(ctx context.Context) error
- func (s *Service) ReloadLineupForPlaylistSyncOutcome(ctx context.Context) (ReloadOutcome, error)
- func (s *Service) ReverseSync(ctx context.Context, req ReverseSyncRequest) (ReverseSyncResult, error)
- func (s *Service) ReverseSyncChannel(ctx context.Context, channelID int64, req ReverseSyncRequest) (ReverseSyncResult, error)
- func (s *Service) Sync(ctx context.Context, req SyncRequest) (SyncResult, error)
- func (s *Service) TestConnection(ctx context.Context) (TestResult, error)
- func (s *Service) UpdateChannelMapping(ctx context.Context, channelID int64, update ChannelMappingUpdate) (ChannelMapping, error)
- func (s *Service) UpdateConfig(ctx context.Context, instance InstanceConfig) (ConfigState, error)
- type Store
- type SyncMode
- type SyncRequest
- type SyncResult
- type TestResult
Constants ¶
const ( ReloadStatusDisabled = "disabled" ReloadStatusReloaded = "reloaded" ReloadStatusPartial = "partial" ReloadStatusSkipped = "skipped" ReloadStatusUnknown = "unknown" )
Variables ¶
var ( ErrDVRSyncConfig = errors.New("dvr sync configuration error") ErrSyncAlreadyRunning = errors.New("dvr sync already running") )
var (
ErrUnsupportedProvider = errors.New("unsupported dvr provider")
)
Functions ¶
func ProviderBaseURL ¶ added in v1.0.3
func ProviderBaseURL(instance InstanceConfig, provider ProviderType) string
ProviderBaseURL resolves the provider-scoped base URL from the merged BaseURL/ChannelsBaseURL/JellyfinBaseURL fields.
func ProviderBaseURLConfigured ¶ added in v1.0.3
ProviderBaseURLConfigured returns true when the value is a non-empty absolute URL with scheme and host.
Types ¶
type ChannelMapping ¶
type ChannelMapping struct {
ChannelID int64 `json:"channel_id"`
GuideNumber string `json:"guide_number"`
GuideName string `json:"guide_name"`
Enabled bool `json:"enabled"`
DVRInstanceID int64 `json:"dvr_instance_id"`
DVRLineupID string `json:"dvr_lineup_id,omitempty"`
DVRLineupChannel string `json:"dvr_lineup_channel,omitempty"`
DVRStationRef string `json:"dvr_station_ref,omitempty"`
DVRCallsignHint string `json:"dvr_callsign_hint,omitempty"`
}
ChannelMapping stores per-channel DVR lineup association metadata.
type ChannelMappingUpdate ¶
type ChannelMappingUpdate struct {
DVRLineupID string `json:"dvr_lineup_id"`
DVRLineupChannel string `json:"dvr_lineup_channel"`
DVRStationRef string `json:"dvr_station_ref"`
DVRCallsignHint string `json:"dvr_callsign_hint"`
}
ChannelMappingUpdate is a write payload for one published channel mapping.
type ChannelsProvider ¶
type ChannelsProvider struct {
// contains filtered or unexported fields
}
ChannelsProvider implements LineupReloadProvider and MappingProvider against Channels DVR server APIs.
func NewChannelsProvider ¶
func NewChannelsProvider(baseURL string, client *http.Client) *ChannelsProvider
func (*ChannelsProvider) GetCustomMapping ¶
func (*ChannelsProvider) ListDeviceChannels ¶
func (p *ChannelsProvider) ListDeviceChannels(ctx context.Context) (map[string]DVRDeviceChannel, error)
func (*ChannelsProvider) ListLineupStations ¶
func (p *ChannelsProvider) ListLineupStations(ctx context.Context, lineupID string) ([]DVRStation, error)
func (*ChannelsProvider) ListLineups ¶
func (p *ChannelsProvider) ListLineups(ctx context.Context) ([]DVRLineup, error)
func (*ChannelsProvider) PutCustomMapping ¶
func (*ChannelsProvider) RedownloadGuideLineup ¶
func (p *ChannelsProvider) RedownloadGuideLineup(ctx context.Context, lineupID string) error
func (*ChannelsProvider) RefreshDevices ¶
func (p *ChannelsProvider) RefreshDevices(ctx context.Context) error
func (*ChannelsProvider) RefreshGuideStations ¶
func (p *ChannelsProvider) RefreshGuideStations(ctx context.Context) error
func (*ChannelsProvider) ReloadDeviceLineup ¶
func (p *ChannelsProvider) ReloadDeviceLineup(ctx context.Context, deviceID string) error
func (*ChannelsProvider) Type ¶
func (p *ChannelsProvider) Type() ProviderType
type ConfigState ¶
type ConfigState struct {
Instance InstanceConfig `json:"instance"`
CachedLineups []DVRLineup `json:"cached_lineups,omitempty"`
CachedLineupsAt int64 `json:"cached_lineups_at,omitempty"`
LastSync *SyncResult `json:"last_sync,omitempty"`
}
ConfigState is the API view of DVR integration state.
type DVRDeviceChannel ¶
type DVRDeviceChannel struct {
Key string `json:"key"`
DeviceID string `json:"device_id,omitempty"`
Number string `json:"number,omitempty"`
Name string `json:"name,omitempty"`
CallSign string `json:"call_sign,omitempty"`
StationRef string `json:"station_ref,omitempty"`
}
DVRDeviceChannel represents one provider device channel entry.
type DVRStation ¶
type DVRStation struct {
StationRef string `json:"station_ref"`
LineupChannel string `json:"lineup_channel,omitempty"`
CallSign string `json:"call_sign,omitempty"`
Name string `json:"name,omitempty"`
}
DVRStation represents one station entry inside a lineup.
type InstanceConfig ¶
type InstanceConfig struct {
ID int64 `json:"id"`
Provider ProviderType `json:"provider"`
ActiveProviders []ProviderType `json:"active_providers,omitempty"`
BaseURL string `json:"base_url"`
ChannelsBaseURL string `json:"channels_base_url,omitempty"`
JellyfinBaseURL string `json:"jellyfin_base_url,omitempty"`
DefaultLineupID string `json:"default_lineup_id,omitempty"`
SyncEnabled bool `json:"sync_enabled"`
SyncCron string `json:"sync_cron,omitempty"`
SyncMode SyncMode `json:"sync_mode"`
PreSyncRefreshDevices bool `json:"pre_sync_refresh_devices"`
JellyfinAPIToken string `json:"jellyfin_api_token,omitempty"`
JellyfinAPITokenConfigured bool `json:"jellyfin_api_token_configured,omitempty"`
JellyfinTunerHostID string `json:"jellyfin_tuner_host_id,omitempty"`
UpdatedAt int64 `json:"updated_at"`
}
InstanceConfig stores one DVR integration endpoint configuration.
func NormalizeForProvider ¶ added in v1.0.3
func NormalizeForProvider(instance InstanceConfig, provider ProviderType) InstanceConfig
NormalizeForProvider returns a canonical provider-scoped view of the instance.
func NormalizeInstanceConfig ¶ added in v1.0.3
func NormalizeInstanceConfig(instance InstanceConfig, current InstanceConfig) InstanceConfig
NormalizeInstanceConfig canonicalizes API update payloads against the current stored instance while preserving existing provider-specific URLs when omitted.
func NormalizeStoredInstance ¶ added in v1.0.3
func NormalizeStoredInstance(instance InstanceConfig) InstanceConfig
NormalizeStoredInstance canonicalizes persisted/read-back config shape.
type JellyfinProvider ¶
type JellyfinProvider struct {
// contains filtered or unexported fields
}
JellyfinProvider implements LineupReloadProvider against Jellyfin Live TV APIs.
func NewJellyfinProvider ¶
func NewJellyfinProvider(instance InstanceConfig, client *http.Client) *JellyfinProvider
func (*JellyfinProvider) ListLineups ¶
func (p *JellyfinProvider) ListLineups(context.Context) ([]DVRLineup, error)
func (*JellyfinProvider) RedownloadGuideLineup ¶
func (p *JellyfinProvider) RedownloadGuideLineup(context.Context, string) error
func (*JellyfinProvider) RefreshGuideStations ¶
func (p *JellyfinProvider) RefreshGuideStations(context.Context) error
func (*JellyfinProvider) ReloadDeviceLineup ¶
func (p *JellyfinProvider) ReloadDeviceLineup(ctx context.Context, deviceID string) error
func (*JellyfinProvider) Type ¶
func (p *JellyfinProvider) Type() ProviderType
type LineupReloadProvider ¶ added in v1.0.3
type LineupReloadProvider interface {
ProviderBase
ListLineups(ctx context.Context) ([]DVRLineup, error)
ReloadDeviceLineup(ctx context.Context, deviceID string) error
RefreshGuideStations(ctx context.Context) error
RedownloadGuideLineup(ctx context.Context, lineupID string) error
}
LineupReloadProvider supports lineup reload + guide refresh flows.
type LineupSyncResult ¶
type LineupSyncResult struct {
LineupID string `json:"lineup_id"`
ConfiguredChannels int `json:"configured_channels"`
ResolvedChannels int `json:"resolved_channels"`
UpdatedCount int `json:"updated_count"`
ClearedCount int `json:"cleared_count"`
UnchangedCount int `json:"unchanged_count"`
AppliedCount int `json:"applied_count"`
}
LineupSyncResult captures one lineup's sync work.
type MappingProvider ¶ added in v1.0.3
type MappingProvider interface {
ProviderBase
ListDeviceChannels(ctx context.Context) (map[string]DVRDeviceChannel, error)
ListLineupStations(ctx context.Context, lineupID string) ([]DVRStation, error)
GetCustomMapping(ctx context.Context, lineupID string) (map[string]string, error)
PutCustomMapping(ctx context.Context, lineupID string, patch map[string]string) error
RefreshDevices(ctx context.Context) error
}
MappingProvider supports forward/reverse mapping sync behavior.
type ProviderBase ¶ added in v1.0.3
type ProviderBase interface {
Type() ProviderType
}
ProviderBase exposes common provider identity behavior.
type ProviderType ¶
type ProviderType string
ProviderType identifies one DVR provider implementation.
const ( ProviderChannels ProviderType = "channels" ProviderJellyfin ProviderType = "jellyfin" )
func NormalizeProviderType ¶ added in v1.0.3
func NormalizeProviderType(provider ProviderType) ProviderType
NormalizeProviderType canonicalizes provider values while preserving unknown inputs for upstream validation.
type ReloadOutcome ¶ added in v1.0.3
type ReloadOutcome struct {
Reloaded bool `json:"reloaded"`
Skipped bool `json:"skipped"`
Status string `json:"status"`
SkipReasons []string `json:"skip_reasons,omitempty"`
ReloadedProviders []ProviderType `json:"reloaded_providers,omitempty"`
SkippedProviders map[ProviderType]string `json:"skipped_providers,omitempty"`
}
ReloadOutcome captures provider-aware DVR lineup reload state.
type ReverseSyncRequest ¶
type ReverseSyncRequest struct {
DryRun bool `json:"dry_run"`
LineupID string `json:"lineup_id,omitempty"`
IncludeDynamic bool `json:"include_dynamic,omitempty"`
}
ReverseSyncRequest controls pull direction sync (DVR -> hdhriptv mappings).
type ReverseSyncResult ¶
type ReverseSyncResult struct {
StartedAt int64 `json:"started_at"`
FinishedAt int64 `json:"finished_at"`
DurationMS int64 `json:"duration_ms"`
DryRun bool `json:"dry_run"`
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
HDHRDeviceID string `json:"hdhr_device_id,omitempty"`
LineupID string `json:"lineup_id"`
DeviceChannelCount int `json:"device_channel_count"`
FilteredChannelCount int `json:"filtered_channel_count"`
CandidateCount int `json:"candidate_count"`
ImportedCount int `json:"imported_count"`
UnchangedCount int `json:"unchanged_count"`
MissingTunerCount int `json:"missing_tuner_count"`
MissingMappingCount int `json:"missing_mapping_count"`
MissingStationRefCount int `json:"missing_station_ref_count"`
Warnings []string `json:"warnings,omitempty"`
}
ReverseSyncResult summarizes a reverse sync run.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service coordinates provider access, sync operations, and mapping persistence.
func NewService ¶
func (*Service) GetChannelMapping ¶
func (*Service) ListChannelMappings ¶
func (*Service) ListChannelMappingsPaged ¶
func (*Service) ListLineups ¶
func (*Service) ReloadLineupForPlaylistSyncOutcome ¶ added in v1.0.3
func (s *Service) ReloadLineupForPlaylistSyncOutcome(ctx context.Context) (ReloadOutcome, error)
ReloadLineupForPlaylistSyncOutcome is the typed variant used by playlist-sync orchestration paths and summary rendering.
func (*Service) ReverseSync ¶
func (s *Service) ReverseSync(ctx context.Context, req ReverseSyncRequest) (ReverseSyncResult, error)
func (*Service) ReverseSyncChannel ¶
func (s *Service) ReverseSyncChannel( ctx context.Context, channelID int64, req ReverseSyncRequest, ) (ReverseSyncResult, error)
func (*Service) Sync ¶
func (s *Service) Sync(ctx context.Context, req SyncRequest) (SyncResult, error)
func (*Service) TestConnection ¶
func (s *Service) TestConnection(ctx context.Context) (TestResult, error)
func (*Service) UpdateChannelMapping ¶
func (s *Service) UpdateChannelMapping( ctx context.Context, channelID int64, update ChannelMappingUpdate, ) (ChannelMapping, error)
func (*Service) UpdateConfig ¶
func (s *Service) UpdateConfig(ctx context.Context, instance InstanceConfig) (ConfigState, error)
type Store ¶
type Store interface {
GetDVRInstance(ctx context.Context) (InstanceConfig, error)
UpsertDVRInstance(ctx context.Context, instance InstanceConfig) (InstanceConfig, error)
ListChannelsForDVRSync(ctx context.Context, dvrInstanceID int64, enabledOnly bool, includeDynamic bool) ([]ChannelMapping, error)
ListChannelsForDVRSyncPaged(ctx context.Context, dvrInstanceID int64, enabledOnly bool, includeDynamic bool, limit, offset int) ([]ChannelMapping, int, error)
GetChannelDVRMapping(ctx context.Context, dvrInstanceID, channelID int64) (ChannelMapping, error)
UpsertChannelDVRMapping(ctx context.Context, mapping ChannelMapping) (ChannelMapping, error)
DeleteChannelDVRMapping(ctx context.Context, dvrInstanceID, channelID int64) error
}
Store describes persistence operations required by DVR integration.
type SyncMode ¶
type SyncMode string
SyncMode controls how sync applies and clears mappings.
func NormalizeSyncMode ¶ added in v1.0.3
NormalizeSyncMode canonicalizes sync mode values and falls back to the configured-only mode for unknown or empty inputs.
type SyncRequest ¶
type SyncRequest struct {
DryRun bool `json:"dry_run"`
IncludeDynamic bool `json:"include_dynamic,omitempty"`
}
SyncRequest controls sync execution behavior.
type SyncResult ¶
type SyncResult struct {
StartedAt int64 `json:"started_at"`
FinishedAt int64 `json:"finished_at"`
DurationMS int64 `json:"duration_ms"`
DryRun bool `json:"dry_run"`
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
HDHRDeviceID string `json:"hdhr_device_id,omitempty"`
SyncMode SyncMode `json:"sync_mode"`
DeviceChannelCount int `json:"device_channel_count"`
FilteredChannelCount int `json:"filtered_channel_count"`
UpdatedCount int `json:"updated_count"`
ClearedCount int `json:"cleared_count"`
UnchangedCount int `json:"unchanged_count"`
MissingTunerCount int `json:"missing_tuner_count"`
UnresolvedCount int `json:"unresolved_count"`
Lineups []LineupSyncResult `json:"lineups"`
Warnings []string `json:"warnings,omitempty"`
PatchPreview map[string]map[string]string `json:"patch_preview,omitempty"`
}
SyncResult summarizes one sync run.
type TestResult ¶
type TestResult struct {
Reachable bool `json:"reachable"`
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
DeviceChannelCount int `json:"device_channel_count"`
FilteredChannelCount int `json:"filtered_channel_count"`
HDHRDeviceID string `json:"hdhr_device_id,omitempty"`
HDHRDeviceFilterActive bool `json:"hdhr_device_filter_active"`
}
TestResult summarizes provider connectivity.