config

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchData added in v1.1.0

func FetchData(uri string) ([]byte, error)

func GetDefaultHttpClient added in v1.1.0

func GetDefaultHttpClient() *http.Client

func LoadTvBoxData added in v1.1.0

func LoadTvBoxData(uri string) ([]byte, error)

func ParseEPGConfig added in v1.1.0

func ParseEPGConfig(r io.Reader) (*epg.EPG, error)

func ParseM3U8Config added in v1.1.0

func ParseM3U8Config(r io.Reader) (m3u.Playlist, error)

Types

type ArrayMixOpt

type ArrayMixOpt struct {
	MixOpt   `mapstructure:",squash"`
	FilterBy string `mapstructure:"filter_by"` // 过滤依据 key
	Include  string `mapstructure:"include"`   // 包含, 正则
	Exclude  string `mapstructure:"exclude"`   // 排除, 正则
}

type Config

type Config struct {
	ServerPort         int                `mapstructure:"server_port"`           // 服务端口, 默认 8080
	ExternalURL        string             `mapstructure:"external_url"`          // 外部访问地址, eg. http://localhost:8080
	Log                LogOpt             `mapstructure:"log"`                   // 日志配置
	Sources            []Source           `mapstructure:"sources"`               // 源配置
	TvBoxSingleRepoOpt TvBoxSingleRepoOpt `mapstructure:"tvbox_single_repo_opt"` // TvBox单仓源配置
	TvBoxMultiRepoOpt  TvBoxMultiRepoOpt  `mapstructure:"tvbox_multi_repo_opt"`  // TvBox多仓源配置
	EPGOpt             EPGOpt             `mapstructure:"epg"`                   // EPG源配置
	M3UOpt             M3UOpt             `mapstructure:"m3u"`                   // M3U源配置
}

func DefaultConfig added in v1.2.0

func DefaultConfig() *Config

func LoadServerConfig

func LoadServerConfig(cfgFile string) (*Config, error)

func UnmarshalConfig added in v1.2.0

func UnmarshalConfig(v *viper.Viper) (*Config, error)

func (*Config) Fixture

func (c *Config) Fixture()

type EPGFilterType added in v1.1.0

type EPGFilterType string
const (
	EPGFilterTypeChannelID    EPGFilterType = "channel_id"
	EPGFilterTypeProgramTitle EPGFilterType = "program_title"
)

type EPGOpt added in v1.1.0

type EPGOpt struct {
	Disable bool `mapstructure:"disable"` // 是否禁用EPG源
	// 过滤频道配置
	// 可根据 channel_id 或者 program_title 过滤
	// 支持多个源
	Filters []ArrayMixOpt `mapstructure:"filters"`
}

type FlexInt

type FlexInt int

FlexInt 是一个灵活的整数类型,可以从 JSON 中的数字或字符串解析

func (FlexInt) MarshalJSON

func (fi FlexInt) MarshalJSON() ([]byte, error)

MarshalJSON 实现了 json.Marshaler 接口

func (*FlexInt) UnmarshalJSON

func (fi *FlexInt) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现了 json.Unmarshaler 接口

type LogOpt

type LogOpt struct {
	Output string `mapstructure:"output"` // 日志输出路径, stdout 表示输出到标准输出
	Level  int    `mapstructure:"level"`  // 日志级别, 0: Trace, 1: Debug, 2: Info, 3: Warn, 4: Error, 5: Fatal, 6: Panic
}

type M3UOpt added in v1.1.0

type M3UOpt struct {
	Disable               bool          `mapstructure:"disable"`                 // 是否禁用M3U源
	MediaPlaylistFallback MixOpt        `mapstructure:"media_playlist_fallback"` // 媒体播放列表降级配置
	MediaPlaylistFilters  []ArrayMixOpt `mapstructure:"media_playlist_filters"`  // 媒体播放列表过滤配置

}

type MixOpt

type MixOpt struct {
	SourceName string `mapstructure:"source_name"`
	Field      string `mapstructure:"field"`    // 内部使用,无需配置
	Disabled   bool   `mapstructure:"disabled"` // 是否禁用该字段
}

type Source

type Source struct {
	Name     string     `mapstructure:"name"`     // 源名称, 唯一标识, 用来标识用在配置中
	URL      string     `mapstructure:"url"`      // 源地址
	Type     SourceType `mapstructure:"type"`     // 源类型
	Interval int        `mapstructure:"interval"` // 源更新频率,单位为秒, 默认 60 秒
}

type SourceType

type SourceType string
const (
	SourceTypeTvBoxSingle SourceType = "tvbox_single" // tvbox单仓源
	SourceTypeTvBoxMulti  SourceType = "tvbox_multi"  // tvbox多仓源
	SourceTypeEPG         SourceType = "epg"          // epg源
	SourceTypeM3U         SourceType = "m3u"          // m3u源
)

type TvBoxDOH added in v1.1.0

type TvBoxDOH struct {
	Name string   `json:"name"`
	URL  string   `json:"url"`
	IPs  []string `json:"ips"`
}

type TvBoxLive added in v1.1.0

type TvBoxLive struct {
	Name       string  `json:"name"`
	Type       FlexInt `json:"type"`
	URL        string  `json:"url"`
	PlayerType FlexInt `json:"playerType"`
	UA         string  `json:"ua,omitempty"`
	EPG        string  `json:"epg,omitempty"`
	Timeout    FlexInt `json:"timeout,omitempty"`
}

type TvBoxMultiRepoConfig added in v1.1.0

type TvBoxMultiRepoConfig struct {
	Repos []TvBoxRepoURLConfig `json:"urls"`
}

func LoadTvBoxMultiRepoConfig added in v1.1.0

func LoadTvBoxMultiRepoConfig(uri string) (*TvBoxMultiRepoConfig, error)

func ParseTvBoxMultiRepoConfig added in v1.1.0

func ParseTvBoxMultiRepoConfig(r io.Reader) (*TvBoxMultiRepoConfig, error)

type TvBoxMultiRepoOpt added in v1.1.0

type TvBoxMultiRepoOpt struct {
	Disable           bool          `mapstructure:"disable"`             // 是否禁用多仓源
	IncludeSingleRepo bool          `mapstructure:"include_single_repo"` // 是否包含代理的单仓源
	Repos             []ArrayMixOpt `mapstructure:"repos"`               // 仓库配置
}

type TvBoxParse added in v1.1.0

type TvBoxParse struct {
	Name string  `json:"name"`
	Type FlexInt `json:"type"`
	URL  string  `json:"url"`
	Ext  any     `json:"ext,omitempty"`
}

type TvBoxRepoConfig added in v1.1.0

type TvBoxRepoConfig struct {
	Spider    string       `json:"spider,omitempty"`
	Lives     []TvBoxLive  `json:"lives,omitempty"`
	Wallpaper string       `json:"wallpaper,omitempty"`
	Sites     []TvBoxSite  `json:"sites,omitempty"`
	Parses    []TvBoxParse `json:"parses,omitempty"`
	Flags     []string     `json:"flags,omitempty"`
	DOH       []TvBoxDOH   `json:"doh,omitempty"`
	Rules     []TvBoxRule  `json:"rules,omitempty"`
	Ads       []string     `json:"ads,omitempty"`
}

func LoadTvBoxConfig

func LoadTvBoxConfig(uri string) (*TvBoxRepoConfig, error)

func ParseTvBoxConfig

func ParseTvBoxConfig(r io.Reader) (*TvBoxRepoConfig, error)

type TvBoxRepoURLConfig added in v1.1.0

type TvBoxRepoURLConfig struct {
	URL  string `json:"url"`
	Name string `json:"name"`
}

type TvBoxRule added in v1.1.0

type TvBoxRule struct {
	Name   string   `json:"name"`
	Hosts  []string `json:"hosts"`
	Regex  []string `json:"regex,omitempty"`
	Script []string `json:"script,omitempty"`
}

type TvBoxSingleRepoOpt added in v1.1.0

type TvBoxSingleRepoOpt struct {
	Disable   bool          `mapstructure:"disable"` // 是否禁用单仓源
	Spider    MixOpt        `mapstructure:"spider"`
	Wallpaper MixOpt        `mapstructure:"wallpaper"`
	Sites     []ArrayMixOpt `mapstructure:"sites"`
	DOH       []ArrayMixOpt `mapstructure:"doh"`
	Lives     []ArrayMixOpt `mapstructure:"lives"`
	Parses    []ArrayMixOpt `mapstructure:"parses"`
	Flags     []ArrayMixOpt `mapstructure:"flags"`
	Rules     []ArrayMixOpt `mapstructure:"rules"`
	Ads       []ArrayMixOpt `mapstructure:"ads"`
	Fallback  MixOpt        `mapstructure:"fallback"` // 降级配置
}

type TvBoxSite added in v1.1.0

type TvBoxSite struct {
	Key         string  `json:"key"`
	Name        string  `json:"name"`
	Type        FlexInt `json:"type"`
	API         string  `json:"api,omitempty"`
	Searchable  FlexInt `json:"searchable,omitempty"`
	QuickSearch FlexInt `json:"quickSearch,omitempty"`
	Filterable  FlexInt `json:"filterable,omitempty"`
	Ext         any     `json:"ext,omitempty"`
	Jar         string  `json:"jar,omitempty"`
	PlayerType  FlexInt `json:"playerType,omitempty"`
	Changeable  FlexInt `json:"changeable,omitempty"`
	Timeout     FlexInt `json:"timeout,omitempty"`
}

type TvBoxStyle added in v1.1.0

type TvBoxStyle struct {
	Type  string  `json:"type"`
	Ratio float64 `json:"ratio,omitempty"`
}

Jump to

Keyboard shortcuts

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