config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SslDir = "ssl"

SslDir ssl 证书存放目录名称

Variables

View Source
var BasePath string

BasePath 配置文件所在的基础路径

View Source
var DataRoot string

DataRoot 程序数据根目录

Functions

func ReadFromFile

func ReadFromFile(path string) error

ReadFromFile 从指定文件中读取配置

func ServerInternalRequestHost

func ServerInternalRequestHost() string

ServerInternalRequestHost 服务内部自请求 host

Types

type Cache

type Cache struct {
	Enable  bool   `yaml:"enable"`  // 是否启用缓存
	Expired string `yaml:"expired"` // 缓存过期时间
	// contains filtered or unexported fields
}

func (*Cache) ExpiredDuration

func (c *Cache) ExpiredDuration() time.Duration

func (*Cache) Init

func (c *Cache) Init() error

type Config

type Config struct {
	// Emby emby 相关配置
	Emby *Emby `yaml:"emby"`
	// Openlist openlist 相关配置
	Openlist *Openlist `yaml:"openlist"`
	// VideoPreview 网盘转码链接代理配置
	VideoPreview *VideoPreview `yaml:"video-preview"`
	// Path 路径相关配置
	Path *Path `yaml:"path"`
	// Cache 缓存相关配置
	Cache *Cache `yaml:"cache"`
	// Ssl ssl 相关配置
	Ssl *Ssl `yaml:"ssl"`
	// Log 日志相关配置
	Log *Log `yaml:"log"`
}
var C *Config

C 全局唯一配置对象

type DlStrategy

type DlStrategy string

DlStrategy 下载策略类型

const (
	DlStrategyOrigin DlStrategy = "origin" // 代理到源服务器
	DlStrategyDirect DlStrategy = "direct" // 获取并重定向到直链
	DlStrategy403    DlStrategy = "403"    // 拒绝响应
)

type Emby

type Emby struct {
	// Emby 源服务器地址
	Host string `yaml:"host"`
	// rclone 或者 cd 的挂载目录
	MountPath string `yaml:"mount-path"`
	// EpisodesUnplayPrior 在获取剧集列表时是否将未播资源优先展示
	EpisodesUnplayPrior bool `yaml:"episodes-unplay-prior"`
	// ResortRandomItems 是否对随机的 items 进行重排序
	ResortRandomItems bool `yaml:"resort-random-items"`
	// ProxyErrorStrategy 代理错误时的处理策略
	ProxyErrorStrategy PeStrategy `yaml:"proxy-error-strategy"`
	// ImagesQuality 图片质量
	ImagesQuality int `yaml:"images-quality"`
	// Strm strm 配置
	Strm *Strm `yaml:"strm"`
	// DownloadStrategy 下载接口响应策略
	DownloadStrategy DlStrategy `yaml:"download-strategy"`
	// LocalMediaRoot 本地媒体根路径
	LocalMediaRoot string `yaml:"local-media-root"`
	// DlCacheTime 直链缓存时间
	DlCacheTime string `yaml:"dl-cache-time"`
	// DlCacheIgnore 直链缓存忽略域名 (支持通配符或关键字)
	DlCacheIgnore []string `yaml:"dl-cache-ignore"`
}

Emby 相关配置

func (*Emby) Init

func (e *Emby) Init() error

type Initializer

type Initializer interface {
	// Init 配置初始化
	Init() error
}

type LocalTreeGen

type LocalTreeGen struct {

	// Enable 是否启用
	Enable bool `yaml:"enable"`

	// FFmpegEnable 是否启用 ffmpeg
	FFmpegEnable bool `yaml:"ffmpeg-enable"`

	// VirtualContainers 虚拟媒体容器, 原始串, 以英文逗号分割
	VirtualContainers string `yaml:"virtual-containers"`

	// StrmContainers strm 媒体容器, 原始串, 以英文逗号分割
	StrmContainers string `yaml:"strm-containers"`

	// MusicContainers 音乐媒体容器, 原始串, 以英文逗号分割
	MusicContainers string `yaml:"music-containers"`

	// AutoRemoveMaxCount 自动删除文件的最大数量
	AutoRemoveMaxCount int `yaml:"auto-remove-max-count"`

	// RefreshInterval 刷新间隔, 单位: 分钟
	RefreshInterval int `yaml:"refresh-interval"`

	// ScanPrefixes 指定扫描前缀
	ScanPrefixes []string `yaml:"scan-prefixes"`

	// IgnoreContainers 忽略指定的容器
	IgnoreContainers string `yaml:"ignore-containers"`

	// Threads 同步线程数
	Threads int `yaml:"threads"`
	// contains filtered or unexported fields
}

func (*LocalTreeGen) Init

func (ltg *LocalTreeGen) Init() error

Init 配置初始化

func (*LocalTreeGen) IsIgnore

func (ltg *LocalTreeGen) IsIgnore(container string) bool

IsIgnore 判断一个容器是否需要被忽略

func (*LocalTreeGen) IsMusic

func (ltg *LocalTreeGen) IsMusic(container string) bool

IsMusic 判断一个容器是否属于音乐容器

func (*LocalTreeGen) IsStrm

func (ltg *LocalTreeGen) IsStrm(container string) bool

IsStrm 判断一个容器是否属于 strm 容器

func (*LocalTreeGen) IsValidPrefix

func (ltg *LocalTreeGen) IsValidPrefix(path string) bool

IsValidPrefix 判断一个 openlist 路径是否在扫描前缀的范围中

func (*LocalTreeGen) IsVirtual

func (ltg *LocalTreeGen) IsVirtual(container string) bool

IsVirtual 判断一个容器是否属于虚拟容器

type Log

type Log struct {
	DisableColor bool `yaml:"disable-color"` // 是否禁用彩色日志输出
}

Log 日志配置

func (*Log) EnableColor

func (lc *Log) EnableColor() bool

EnableColor 标记是否启用颜色输出

func (*Log) Init

func (lc *Log) Init() error

Init 配置初始化

type Openlist

type Openlist struct {
	// Token 访问 openlist 接口的密钥, 在 openlist 管理后台获取
	Token string `yaml:"token"`
	// Host openlist 访问地址(如果 openlist 使用本地代理模式, 则这个地址必须配置公网可访问地址)
	Host string `yaml:"host"`

	// LocalTreeGen 本地目录树生成相关
	LocalTreeGen *LocalTreeGen `yaml:"local-tree-gen"`
}

func (*Openlist) Init

func (a *Openlist) Init() error

type Path

type Path struct {
	// Emby2Openlist Emby 的路径前缀映射到 Openlist 的路径前缀, 两个路径使用 : 符号隔开
	Emby2Openlist []string `yaml:"emby2openlist"`
	// contains filtered or unexported fields
}

func (*Path) Init

func (p *Path) Init() error

func (*Path) MapEmby2Openlist

func (p *Path) MapEmby2Openlist(embyPath string) (string, bool)

MapEmby2Openlist 将 emby 路径映射成 openlist 路径

type PeStrategy

type PeStrategy string

PeStrategy 代理异常策略类型

const (
	PeStrategyOrigin PeStrategy = "origin" // 回源
	PeStrategyReject PeStrategy = "reject" // 拒绝请求
)

type Ssl

type Ssl struct {
	Enable     bool   `yaml:"enable"`      // 是否启用
	SinglePort bool   `yaml:"single-port"` // 是否使用单一端口
	Key        string `yaml:"key"`         // 服务器私钥名称
	Crt        string `yaml:"crt"`         // 证书名称
}

func (*Ssl) CrtPath

func (s *Ssl) CrtPath() string

CrtPath 获取 cert 证书的绝对路径

func (*Ssl) Init

func (s *Ssl) Init() error

func (*Ssl) KeyPath

func (s *Ssl) KeyPath() string

KeyPath 获取密钥的绝对路径

type Strm

type Strm struct {
	// PathMap 远程路径映射
	PathMap []string `yaml:"path-map"`
	// InternalRedirectEnable 是否启用 strm 内部重定向
	InternalRedirectEnable bool `yaml:"internal-redirect-enable"`
	// contains filtered or unexported fields
}

Strm strm 配置

func (*Strm) Init

func (s *Strm) Init() error

Init 配置初始化

func (*Strm) MapPath

func (s *Strm) MapPath(path string) string

MapPath 将传入路径按照预配置的映射关系从上到下按顺序进行映射, 至多成功映射一次

type VideoPreview

type VideoPreview struct {
	// Enable 是否开启网盘转码链接代理
	Enable bool `yaml:"enable"`
	// Containers 对哪些容器使用网盘转码链接代理
	Containers []string `yaml:"containers"`
	// IgnoreTemplateIds 忽略的转码清晰度
	IgnoreTemplateIds []string `yaml:"ignore-template-ids"`
	// contains filtered or unexported fields
}

func (*VideoPreview) ContainerValid

func (vp *VideoPreview) ContainerValid(container string) bool

ContainerValid 判断某个视频容器是否启用代理

func (*VideoPreview) Init

func (vp *VideoPreview) Init() error

func (*VideoPreview) IsTemplateIgnore

func (vp *VideoPreview) IsTemplateIgnore(templateId string) bool

IsTemplateIgnore 返回一个转码清晰度是否需要被忽略

Jump to

Keyboard shortcuts

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