settings

package
v0.45.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetConfigRootPath added in v0.42.0

func SetConfigRootPath(configRootPath string)

SetConfigRootPath 需要先设置这个信息再调用 Get

func SetFullNewSettings

func SetFullNewSettings(inSettings *Settings) error

SetFullNewSettings 从 Web 端传入新的 Settings 完整设置

Types

type AdvancedSettings

type AdvancedSettings struct {
	ProxySettings              *ProxySettings     `json:"proxy_settings"`
	TmdbApiSettings            TmdbApiSettings    `json:"tmdb_api_settings"`
	DebugMode                  bool               `json:"debug_mode"`                     // 是否开启调试模式,这个是写入一个特殊的文件来开启日志的 Debug 输出
	SaveFullSeasonTmpSubtitles bool               `json:"save_full_season_tmp_subtitles"` // 保存整季的缓存字幕
	SubTypePriority            int                `json:"sub_type_priority"`              // 字幕下载的优先级,0 是自动,1 是 srt 优先,2 是 ass/ssa 优先
	SubNameFormatter           int                `json:"sub_name_formatter"`             // 字幕命名格式(默认不填写或者超出范围,则为 emby 格式),0,emby 支持的的格式(AAA.chinese(简英,subhd).ass or AAA.chinese(简英,xunlei).default.ass),1常规格式(兼容性更好,AAA.zh.ass or AAA.zh.default.ass)
	SaveMultiSub               bool               `json:"save_multi_sub"`                 // 保存多个网站的 Top 1 字幕
	CustomVideoExts            []string           `json:"custom_video_exts""`             // 自定义视频扩展名,是在原有基础上新增。
	FixTimeLine                bool               `json:"fix_time_line"`                  // 开启校正字幕时间轴,默认 false
	Topic                      int                `json:"topic"`                          // 搜索结果的时候,返回 Topic N 以内的
	SuppliersSettings          *SuppliersSettings `json:"suppliers_settings"`             // 每个字幕源的设置
	ScanLogic                  *ScanLogic         `json:"scan_logic"`                     // 扫描的逻辑
	TaskQueue                  *TaskQueue         `json:"task_queue"`                     // 任务队列的设置
	DownloadFileCache          *DownloadFileCache `json:"download_file_cache"`            // 下载文件的缓存
}

func NewAdvancedSettings

func NewAdvancedSettings() *AdvancedSettings

type ApiKeySettings

type ApiKeySettings struct {
	Enabled bool   `json:"enabled"`
	Key     string `json:"key"`
}

func NewApiKeySettings

func NewApiKeySettings(enabled bool, key string) *ApiKeySettings

type AssrtSettings

type AssrtSettings struct {
	Enabled bool   `json:"enabled"`
	Token   string `json:"token"`
}

type AutoChangeSubEncode

type AutoChangeSubEncode struct {
	Enable        bool `json:"enable"`
	DesEncodeType int  `json:"des_encode_type"` // 默认 0 是 UTF-8,1 是 GBK
}

func (AutoChangeSubEncode) GetDesEncodeType

func (a AutoChangeSubEncode) GetDesEncodeType() string

type ChsChtChanger

type ChsChtChanger struct {
	Enable                 bool `json:"enable"`
	DesChineseLanguageType int  `json:"des_chinese_language_type"` // 默认 0 是 简体 ,1 是 繁体
}

func (ChsChtChanger) GetDesChineseLanguageTypeString

func (c ChsChtChanger) GetDesChineseLanguageTypeString() string

type CommonSettings

type CommonSettings struct {
	IntervalOrAssignOrCustom int      `json:"interval_or_assign_or_custom"` // 扫描时间是,使用间隔还是指定时间
	ScanInterval             string   `json:"scan_interval"`                // 一轮字幕扫描的间隔
	Threads                  int      `json:"threads"`                      // 同时扫描的并发数
	RunScanAtStartUp         bool     `json:"run_scan_at_start_up"`         // 完成引导设置后,下次运行程序就开始扫描
	MoviePaths               []string `json:"movie_paths"`                  // 电影的目录
	SeriesPaths              []string `json:"series_paths"`                 // 连续剧的目录
	LocalStaticFilePort      string   `json:"local_static_file_port"`       // 本地静态文件的端口,取消
}

func NewCommonSettings

func NewCommonSettings() *CommonSettings

type DeveloperSettings

type DeveloperSettings struct {
	Enable            bool   `json:"enable"`              // 是否启用
	BarkServerAddress string `json:"bark_server_address"` // Bark 服务器的地址
}

func NewDeveloperSettings

func NewDeveloperSettings() *DeveloperSettings

type DownloadFileCache

type DownloadFileCache struct {
	TTL  int    `json:"ttl" default:"4320"`  // 单位需要根据下面的单位转换,默认是小时的单位,然后是半年的过期时间
	Unit string `json:"unit" default:"hour"` // second, hour, 目前仅仅支持 秒和小时
}

func NewDownloadFileCache

func NewDownloadFileCache() *DownloadFileCache

type EmbySettings

type EmbySettings struct {
	Enable                bool              `json:"enable"`                   // 是否启用
	AddressUrl            string            `json:"address_url"`              // 内网服务器的 url
	APIKey                string            `json:"api_key"`                  // API key
	MaxRequestVideoNumber int               `json:"max_request_video_number"` // 最大请求获取视频的数量
	SkipWatched           bool              `json:"skip_watched"`             // 是否跳过已经观看的
	MoviePathsMapping     map[string]string `json:"movie_paths_mapping"`      // 电影目录的映射,一旦 common setting 的目录修改,需要提示用户确认映射
	SeriesPathsMapping    map[string]string `json:"series_paths_mapping"`     // 连续剧目录的映射,一旦 common setting 的目录修改,需要提示用户确认映射
	AutoOrManual          bool              `json:"auto_or_manual"`           // 自动或手动模式,自动 IMDB ID 匹配,还是使用手动目录
	Threads               int               `json:"threads"`                  // 同时扫描的并发数
}

func NewEmbySettings

func NewEmbySettings() *EmbySettings

func (*EmbySettings) Check

func (e *EmbySettings) Check()

type ExperimentalFunction

type ExperimentalFunction struct {
	AutoChangeSubEncode  AutoChangeSubEncode  `json:"auto_change_sub_encode"`
	ChsChtChanger        ChsChtChanger        `json:"chs_cht_changer"`
	RemoteChromeSettings RemoteChromeSettings `json:"remote_chrome_settings"`
	ApiKeySettings       ApiKeySettings       `json:"api_key_settings"`
	LocalChromeSettings  LocalChromeSettings  `json:"local_chrome_settings"`
	ShareSubSettings     ShareSubSettings     `json:"share_sub_settings"`
	ExtendLog            ExtendLog            `json:"extend_log"`
}

ExperimentalFunction 实验性功能

func NewExperimentalFunction

func NewExperimentalFunction() *ExperimentalFunction

type ExtendLog added in v0.38.3

type ExtendLog struct {
	SysLog SysLog
}

type LocalChromeSettings

type LocalChromeSettings struct {
	Enabled             bool   `json:"enabled"`
	LocalChromeExeFPath string `json:"local_chrome_exe_f_path"`
}

type OneSupplierSettings

type OneSupplierSettings struct {
	Name               string `json:"name"`
	RootUrl            string `json:"root_url"`
	SearchUrl          string `json:"search_url"`
	DailyDownloadLimit int    `json:"daily_download_limit" default:"-1"` // -1 是无限制
}

func NewOneSupplierSettings

func NewOneSupplierSettings(name string, rootUrl, searchUrl string, dailyDownloadLimit int) *OneSupplierSettings

func (*OneSupplierSettings) GetSearchUrl added in v0.42.1

func (s *OneSupplierSettings) GetSearchUrl() string

type ProxySettings

type ProxySettings struct {
	UseProxy                 bool   `json:"use_proxy"`                                    // 是否使用代理
	UseWhichProxyProtocol    string `json:"use_which_proxy_protocol"`                     // 是使用 socks5 还是 http 代理
	LocalHttpProxyServerPort string `json:"local_http_proxy_server_port" default:"19036"` // 本地代理服务器端口
	InputProxyAddress        string `json:"input_proxy_address"`                          // 输入的代理地址
	InputProxyPort           string `json:"input_proxy_port"`                             // 输入的代理端口
	NeedPWD                  bool   `json:"need_pwd"`                                     // 是否使用用户名密码
	InputProxyUsername       string `json:"input_proxy_username"`                         // 输入的代理用户名
	InputProxyPassword       string `json:"input_proxy_password"`                         // 输入的代理密码
	Referer                  string `json:"-"`                                            // 可能下载文件的时候需要设置
}

func NewProxySettings

func NewProxySettings(useProxy bool, useWhichProxyProtocol string,
	localHttpProxyServerPort string,
	inputProxyAddress string, inputProxyPort string,
	inputProxyUsername string, inputProxyPassword string) *ProxySettings

func (*ProxySettings) CopyOne

func (p *ProxySettings) CopyOne() *ProxySettings

func (*ProxySettings) GetInfos added in v0.42.0

func (p *ProxySettings) GetInfos() (bool, []string, string)

type RemoteChromeSettings

type RemoteChromeSettings struct {
	Enable            bool   `json:"enable"`
	RemoteDockerURL   string `json:"remote_docker_url"`    // 整个是 go-rod 的远程镜像容器地址 ws://192.168.50.135:9222
	RemoteAdblockPath string `json:"remote_adblock_path"`  // 注意这个 go-rod 的远程镜像容器对应的目录, ADBlock 需要展开成文件夹 /mnt/share/adblock1_2_3
	ReMoteUserDataDir string `json:"remote_user_data_dir"` // 注意这个 go-rod 的远程镜像容器对应的目录,用户缓存文件地址

}

type ScanLogic

type ScanLogic struct {
	SkipChineseMovie  bool `json:"skip_chinese_movie" default:"false"`  // 跳过中文的电影
	SkipChineseSeries bool `json:"skip_chinese_series" default:"false"` // 跳过中文的连续剧
}

func NewScanLogic

func NewScanLogic(skipChineseMovie bool, skipChineseSeries bool) *ScanLogic

type Settings

type Settings struct {
	SpeedDevMode bool // 是否为开发模式,代码开启这个会跳过某些流程,加快测试速度

	UserInfo              *UserInfo              `json:"user_info"`
	CommonSettings        *CommonSettings        `json:"common_settings"`
	SubtitleSources       *SubtitleSources       `json:"subtitle_sources"`
	AdvancedSettings      *AdvancedSettings      `json:"advanced_settings"`
	EmbySettings          *EmbySettings          `json:"emby_settings"`
	DeveloperSettings     *DeveloperSettings     `json:"developer_settings"`
	TimelineFixerSettings *TimelineFixerSettings `json:"timeline_fixer_settings"`
	ExperimentalFunction  *ExperimentalFunction  `json:"experimental_function"`
	// contains filtered or unexported fields
}

func Get added in v0.42.0

func Get(reloadSettings ...bool) *Settings

Get 获取 Settings 的实例

func NewSettings

func NewSettings(configRootDirFPath string) *Settings

func (*Settings) Check

func (s *Settings) Check()

Check 检测,某些参数有范围限制

func (*Settings) GetNoPasswordSettings

func (s *Settings) GetNoPasswordSettings() *Settings

func (*Settings) Save

func (s *Settings) Save() error

type ShareSubSettings

type ShareSubSettings struct {
	ShareSubEnabled bool `json:"share_sub_enabled"`
}

type SubShareCenter

type SubShareCenter struct {
	SenderSMTPAddress       string `json:"sender_smtp_address"`        // 发件人的 SMTP 服务地址和端口 outlook.office365.com:993
	SenderSMTPPort          int    `json:"sender_smtp_port"`           // SMTP 的端口号
	InsecureSkipVerify      bool   `json:"insecure_skip_verify"`       // 是否允许不安全连接
	SenderEmailAddress      string `json:"sender_email_address"`       // 发件人的邮件地址
	SenderEmailPwd          string `json:"sender_email_pwd"`           // 发件人的邮件地址对应的密码
	ShareCenterEmailAddress string `json:"share_center_email_address"` // 收取邮件的目标邮件地址
}

func NewSubShareCenter

func NewSubShareCenter(SenderSMTPAddress string, SenderSMTPPort int, InsecureSkipVerify bool, SenderEmailAddress, SenderEmailPwd, ShareCenterEmailAddress string) *SubShareCenter

type SubtitleSources

type SubtitleSources struct {
	AssrtSettings AssrtSettings `json:"assrt_settings"`
}

func NewSubtitleSources

func NewSubtitleSources() *SubtitleSources

type SuppliersSettings

type SuppliersSettings struct {
	ChineseSubFinder *OneSupplierSettings `json:"csf"`
	Xunlei           *OneSupplierSettings `json:"xunlei"`
	Shooter          *OneSupplierSettings `json:"shooter"`
	SubHD            *OneSupplierSettings `json:"subhd"`
	Zimuku           *OneSupplierSettings `json:"zimuku"`
	Assrt            *OneSupplierSettings `json:"assrt"`
	A4k              *OneSupplierSettings `json:"a4k"`
}

func NewSuppliersSettings

func NewSuppliersSettings() *SuppliersSettings

type SysLog added in v0.38.3

type SysLog struct {
	Enable   bool   `json:"enable"`
	Network  string `json:"network"`  // 留空就是本地 udp
	Address  string `json:"address"`  // 留空就是本地 localhost:514
	Priority int    `json:"priority"` // Debug 0, Info 1
	Tag      string `json:"tag"`
}

type TaskQueue

type TaskQueue struct {
	MaxRetryTimes           int    `json:"max_retry_times" default:"3"`            // 单个任务失败后,最大重试次数,超过后会降一级
	OneJobTimeOut           int    `json:"one_job_time_out" default:"300"`         // 单个任务的超时时间 5 * 60 s
	Interval                int    `json:"interval" default:"10"`                  // 任务的间隔,单位 s,这里会有一个限制,不允许太快,然后会做一定的随机时间范围,当前值 x ~ 2*x 之内随机
	ExpirationTime          int    `json:"expiration_time"  default:"90"`          // 单位天。1. 一个视频的 CreatedTime 在这个时间范围内,都会被下载字幕(除非已经观看跳过启用了)。2. 如果下载失败的任务,AddTime 超过了这个时间,那么就标记为 Failed
	DownloadSubDuringXDays  int    `json:"download_sub_during_x_days" default:"7"` // 如果创建了 x 天,且有内置的中文字幕,那么也不进行下载了
	OneSubDownloadInterval  int    `json:"one_sub_download_interval" default:"12"` // 一个字幕下载的间隔(单位 h),不然老是一个循环。对比的基准是 OneJob 的 UpdateTime
	CheckPublicIPTargetSite string `json:"check_pulic_ip_target_site" default:""`  // 检测本机外网 IP 的目标地址,必须是返回直接的 IP 字符串,不需要解析。; 分割
}

func NewTaskQueue

func NewTaskQueue() *TaskQueue

type TimelineFixerSettings

type TimelineFixerSettings struct {
	MaxOffsetTime int     `json:"max_offset_time"` // 最大支持校正时间偏移的范围,单位秒
	MinOffset     float64 `json:"min_offset"`      // 最小的时间片校正偏移,低于这个(正负)就跳过不校正,单位秒
}

func NewTimelineFixerSettings

func NewTimelineFixerSettings() *TimelineFixerSettings

func (*TimelineFixerSettings) Check

func (t *TimelineFixerSettings) Check()

type TmdbApiSettings added in v0.42.0

type TmdbApiSettings struct {
	Enable bool   `json:"enable"`
	ApiKey string `json:"api_key"`
}

func NewTmdbApiSettings added in v0.42.0

func NewTmdbApiSettings(enable bool, apiKey string) *TmdbApiSettings

type UserInfo

type UserInfo struct {
	Username string `json:"username" binding:"required,alphanum"`     // 用户名
	Password string `json:"password" binding:"required,min=6,max=30"` // 密码
}

func NewUserInfo

func NewUserInfo(userName, password string) *UserInfo

Jump to

Keyboard shortcuts

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