Documentation
¶
Index ¶
- Variables
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func FormatTime(t time.Time, layout string) string
- func GetCurrentTime() time.Time
- func GetCurrentTimeRFC3339() string
- func GetCurrentTimeString() string
- func GetErrorSummary(err error) string
- func GetFullVersionInfo() string
- func GetVersionComponents(version string) (major, minor, patch int, err error)
- func GetVersionString() string
- func Info(format string, args ...interface{})
- func InitLogger(config *LogConfig) error
- func InitTimezone()
- func IsResourceError(err error) bool
- func IsRetryableError(err error) bool
- func IsVersionNewer(version1, version2 string) bool
- func ParseTime(timeStr string) (time.Time, error)
- func SaveVersionToFile(filename string, info *VersionInfo) error
- func Warn(format string, args ...interface{})
- type DoubanCategory
- type DoubanItem
- type DoubanResponse
- type DoubanResult
- type DoubanService
- type ErrorType
- type GlobalScheduler
- func (gs *GlobalScheduler) GetHotDramaNames() ([]string, error)
- func (gs *GlobalScheduler) IsAutoTransferRunning() bool
- func (gs *GlobalScheduler) IsHotDramaSchedulerRunning() bool
- func (gs *GlobalScheduler) IsReadyResourceRunning() bool
- func (gs *GlobalScheduler) ProcessAutoTransfer()
- func (gs *GlobalScheduler) ProcessReadyResources()
- func (gs *GlobalScheduler) StartAutoTransferScheduler()
- func (gs *GlobalScheduler) StartHotDramaScheduler()
- func (gs *GlobalScheduler) StartReadyResourceScheduler()
- func (gs *GlobalScheduler) StopAutoTransferScheduler()
- func (gs *GlobalScheduler) StopHotDramaScheduler()
- func (gs *GlobalScheduler) StopReadyResourceScheduler()
- func (gs *GlobalScheduler) UpdateSchedulerStatus(autoFetchHotDramaEnabled bool, autoProcessReadyResources bool)
- func (gs *GlobalScheduler) UpdateSchedulerStatusWithAutoTransfer(autoFetchHotDramaEnabled bool, autoProcessReadyResources bool, ...)
- type LogConfig
- type LogEntry
- type LogLevel
- type LogViewer
- func (lv *LogViewer) CleanOldLogs(days int) error
- func (lv *LogViewer) GetLogFiles() ([]string, error)
- func (lv *LogViewer) GetLogStats(files []string) (map[string]int, error)
- func (lv *LogViewer) ReadLogFile(filename string, lines int) ([]string, error)
- func (lv *LogViewer) SearchLogs(pattern string, files []string) ([]LogEntry, error)
- func (lv *LogViewer) TailLog(filename string, callback func(string)) error
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) Fatal(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) Warn(format string, args ...interface{})
- type PicInfo
- type Rating
- type ResourceError
- func GetResourceError(err error) *ResourceError
- func NewCategoryProcessingError(details string) *ResourceError
- func NewInvalidLinkError(url string, details string) *ResourceError
- func NewLinkCheckError(url string, details string) *ResourceError
- func NewNoAccountError(platform string) *ResourceError
- func NewNoValidAccountError(platform string) *ResourceError
- func NewPlatformNotFoundError(platform string) *ResourceError
- func NewResourceError(errorType ErrorType, message string, url string, details string) *ResourceError
- func NewResourceSaveError(url string, details string) *ResourceError
- func NewServiceCreationError(url string, details string) *ResourceError
- func NewTagProcessingError(details string) *ResourceError
- func NewTransferFailedError(url string, details string) *ResourceError
- func NewUnsupportedLinkError(url string) *ResourceError
- type Scheduler
- func (s *Scheduler) GetHotDramaNames() ([]string, error)
- func (s *Scheduler) IsAutoTransferRunning() bool
- func (s *Scheduler) IsReadyResourceRunning() bool
- func (s *Scheduler) IsRunning() bool
- func (s *Scheduler) StartAutoTransferScheduler()
- func (s *Scheduler) StartHotDramaScheduler()
- func (s *Scheduler) StartReadyResourceScheduler()
- func (s *Scheduler) StopAutoTransferScheduler()
- func (s *Scheduler) StopHotDramaScheduler()
- func (s *Scheduler) StopReadyResourceScheduler()
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
var ( Version = getVersionFromFile() BuildTime = GetCurrentTimeString() GitCommit = "unknown" GitBranch = "unknown" )
编译时注入的版本信息
Functions ¶
func FormatTime ¶ added in v1.0.10
FormatTime 格式化时间(使用配置的时区)
func GetCurrentTime ¶ added in v1.0.10
GetCurrentTime 获取当前时间(使用配置的时区)
func GetCurrentTimeRFC3339 ¶ added in v1.0.10
func GetCurrentTimeRFC3339() string
GetCurrentTimeRFC3339 获取当前时间RFC3339格式(使用配置的时区)
func GetCurrentTimeString ¶ added in v1.0.10
func GetCurrentTimeString() string
GetCurrentTimeString 获取当前时间字符串(使用配置的时区)
func GetErrorSummary ¶ added in v1.0.10
GetErrorSummary 获取错误摘要
func GetVersionComponents ¶
GetVersionComponents 获取版本号组件
func IsResourceError ¶ added in v1.0.10
IsResourceError 检查是否为资源错误
func IsRetryableError ¶ added in v1.0.10
IsRetryableError 检查是否为可重试的错误
func SaveVersionToFile ¶
func SaveVersionToFile(filename string, info *VersionInfo) error
SaveVersionToFile 保存版本信息到文件
Types ¶
type DoubanCategory ¶
type DoubanCategory struct {
Category string `json:"category"`
Selected bool `json:"selected"`
Type string `json:"type"`
Title string `json:"title"`
}
DoubanCategory 豆瓣分类
type DoubanItem ¶
type DoubanItem struct {
ID string `json:"id"`
Title string `json:"title"`
CardSubtitle string `json:"card_subtitle"`
EpisodesInfo string `json:"episodes_info"`
IsNew bool `json:"is_new"`
Pic PicInfo `json:"pic"`
Rating Rating `json:"rating"`
Type string `json:"type"`
URI string `json:"uri"`
Year string `json:"year"`
Directors []string `json:"directors"`
Actors []string `json:"actors"`
Region string `json:"region"`
Genres []string `json:"genres"`
}
DoubanItem 豆瓣项目
type DoubanResponse ¶
type DoubanResponse struct {
Items []DoubanItem `json:"items"`
Categories []DoubanCategory `json:"categories"`
Total int `json:"total"`
IsMockData bool `json:"is_mock_data,omitempty"`
MockReason string `json:"mock_reason,omitempty"`
Notice string `json:"notice,omitempty"`
}
DoubanResponse 豆瓣响应
type DoubanResult ¶
type DoubanResult struct {
Success bool `json:"success"`
Data *DoubanResponse `json:"data,omitempty"`
Message string `json:"message,omitempty"`
}
DoubanResult 豆瓣结果
type DoubanService ¶
type DoubanService struct {
// 电影榜单配置 - 4个大类,每个大类下有5个小类
MovieCategories map[string]map[string]map[string]string
// 剧集榜单配置 - 2个大类
TvCategories map[string]map[string]map[string]string
// contains filtered or unexported fields
}
DoubanService 豆瓣服务
func (*DoubanService) GetAllTvTypes ¶
func (ds *DoubanService) GetAllTvTypes() []string
GetAllTvTypes 获取所有tv类型(type列表)
func (*DoubanService) GetTvByType ¶
func (ds *DoubanService) GetTvByType(tvType string) ([]map[string]interface{}, error)
GetTvByType 获取指定type的全部剧集数据
func (*DoubanService) GetTypePage ¶
func (ds *DoubanService) GetTypePage(category, rankingType string) (*DoubanResult, error)
GetTypePage 获取指定类型的数据
type ErrorType ¶ added in v1.0.10
type ErrorType string
ErrorType 错误类型枚举
const ( // ErrorTypeUnsupportedLink 不支持的链接 ErrorTypeUnsupportedLink ErrorType = "UNSUPPORTED_LINK" // ErrorTypeInvalidLink 无效链接 ErrorTypeInvalidLink ErrorType = "INVALID_LINK" // ErrorTypeNoAccount 没有可用账号 ErrorTypeNoAccount ErrorType = "NO_ACCOUNT" // ErrorTypeNoValidAccount 没有有效账号 ErrorTypeNoValidAccount ErrorType = "NO_VALID_ACCOUNT" // ErrorTypeServiceCreation 服务创建失败 ErrorTypeServiceCreation ErrorType = "SERVICE_CREATION_FAILED" // ErrorTypeTransferFailed 转存失败 ErrorTypeTransferFailed ErrorType = "TRANSFER_FAILED" // ErrorTypeTagProcessing 标签处理失败 ErrorTypeTagProcessing ErrorType = "TAG_PROCESSING_FAILED" // ErrorTypeCategoryProcessing 分类处理失败 ErrorTypeCategoryProcessing ErrorType = "CATEGORY_PROCESSING_FAILED" // ErrorTypeResourceSave 资源保存失败 ErrorTypeResourceSave ErrorType = "RESOURCE_SAVE_FAILED" // ErrorTypePlatformNotFound 平台未找到 ErrorTypePlatformNotFound ErrorType = "PLATFORM_NOT_FOUND" // ErrorTypeLinkCheckFailed 链接检查失败 ErrorTypeLinkCheckFailed ErrorType = "LINK_CHECK_FAILED" )
type GlobalScheduler ¶
type GlobalScheduler struct {
// contains filtered or unexported fields
}
GlobalScheduler 全局调度器管理器
func GetGlobalScheduler ¶
func GetGlobalScheduler(hotDramaRepo repo.HotDramaRepository, readyResourceRepo repo.ReadyResourceRepository, resourceRepo repo.ResourceRepository, systemConfigRepo repo.SystemConfigRepository, panRepo repo.PanRepository, cksRepo repo.CksRepository, tagRepo repo.TagRepository, categoryRepo repo.CategoryRepository) *GlobalScheduler
GetGlobalScheduler 获取全局调度器实例(单例模式)
func (*GlobalScheduler) GetHotDramaNames ¶
func (gs *GlobalScheduler) GetHotDramaNames() ([]string, error)
GetHotDramaNames 手动获取热播剧名字
func (*GlobalScheduler) IsAutoTransferRunning ¶
func (gs *GlobalScheduler) IsAutoTransferRunning() bool
IsAutoTransferRunning 检查自动转存定时任务是否在运行
func (*GlobalScheduler) IsHotDramaSchedulerRunning ¶
func (gs *GlobalScheduler) IsHotDramaSchedulerRunning() bool
IsHotDramaSchedulerRunning 检查热播剧定时任务是否在运行
func (*GlobalScheduler) IsReadyResourceRunning ¶
func (gs *GlobalScheduler) IsReadyResourceRunning() bool
IsReadyResourceRunning 检查待处理资源自动处理任务是否在运行
func (*GlobalScheduler) ProcessAutoTransfer ¶
func (gs *GlobalScheduler) ProcessAutoTransfer()
ProcessAutoTransfer 手动触发自动转存处理
func (*GlobalScheduler) ProcessReadyResources ¶
func (gs *GlobalScheduler) ProcessReadyResources()
ProcessReadyResources 手动触发待处理资源处理
func (*GlobalScheduler) StartAutoTransferScheduler ¶
func (gs *GlobalScheduler) StartAutoTransferScheduler()
StartAutoTransferScheduler 启动自动转存定时任务
func (*GlobalScheduler) StartHotDramaScheduler ¶
func (gs *GlobalScheduler) StartHotDramaScheduler()
StartHotDramaScheduler 启动热播剧定时任务
func (*GlobalScheduler) StartReadyResourceScheduler ¶
func (gs *GlobalScheduler) StartReadyResourceScheduler()
StartReadyResourceScheduler 启动待处理资源自动处理任务
func (*GlobalScheduler) StopAutoTransferScheduler ¶
func (gs *GlobalScheduler) StopAutoTransferScheduler()
StopAutoTransferScheduler 停止自动转存定时任务
func (*GlobalScheduler) StopHotDramaScheduler ¶
func (gs *GlobalScheduler) StopHotDramaScheduler()
StopHotDramaScheduler 停止热播剧定时任务
func (*GlobalScheduler) StopReadyResourceScheduler ¶
func (gs *GlobalScheduler) StopReadyResourceScheduler()
StopReadyResourceScheduler 停止待处理资源自动处理任务
func (*GlobalScheduler) UpdateSchedulerStatus ¶
func (gs *GlobalScheduler) UpdateSchedulerStatus(autoFetchHotDramaEnabled bool, autoProcessReadyResources bool)
UpdateSchedulerStatus 根据系统配置更新调度器状态
func (*GlobalScheduler) UpdateSchedulerStatusWithAutoTransfer ¶
func (gs *GlobalScheduler) UpdateSchedulerStatusWithAutoTransfer(autoFetchHotDramaEnabled bool, autoProcessReadyResources bool, autoTransferEnabled bool)
UpdateSchedulerStatusWithAutoTransfer 根据系统配置更新调度器状态(包含自动转存)
type LogConfig ¶
type LogConfig struct {
LogDir string // 日志目录
LogLevel LogLevel // 日志级别
MaxFileSize int64 // 单个日志文件最大大小(MB)
MaxBackups int // 最大备份文件数
MaxAge int // 日志文件最大保留天数
EnableConsole bool // 是否启用控制台输出
EnableFile bool // 是否启用文件输出
EnableRotation bool // 是否启用日志轮转
}
LogConfig 日志配置
type LogViewer ¶
type LogViewer struct {
// contains filtered or unexported fields
}
LogViewer 日志查看器
func (*LogViewer) CleanOldLogs ¶
CleanOldLogs 清理旧日志文件
func (*LogViewer) GetLogFiles ¶
GetLogFiles 获取所有日志文件
func (*LogViewer) GetLogStats ¶
GetLogStats 获取日志统计信息
func (*LogViewer) ReadLogFile ¶
ReadLogFile 读取日志文件
func (*LogViewer) SearchLogs ¶
SearchLogs 搜索日志
type Rating ¶
type Rating struct {
Value float64 `json:"value"`
Count int `json:"count"`
Max int `json:"max"`
StarCount float64 `json:"star_count"`
}
Rating 评分
type ResourceError ¶ added in v1.0.10
type ResourceError struct {
Type ErrorType `json:"type"`
Message string `json:"message"`
URL string `json:"url,omitempty"`
Details string `json:"details,omitempty"`
}
ResourceError 资源处理错误
func GetResourceError ¶ added in v1.0.10
func GetResourceError(err error) *ResourceError
GetResourceError 获取资源错误
func NewCategoryProcessingError ¶ added in v1.0.10
func NewCategoryProcessingError(details string) *ResourceError
NewCategoryProcessingError 创建分类处理失败错误
func NewInvalidLinkError ¶ added in v1.0.10
func NewInvalidLinkError(url string, details string) *ResourceError
NewInvalidLinkError 创建无效链接错误
func NewLinkCheckError ¶ added in v1.0.10
func NewLinkCheckError(url string, details string) *ResourceError
NewLinkCheckError 创建链接检查失败错误
func NewNoAccountError ¶ added in v1.0.10
func NewNoAccountError(platform string) *ResourceError
NewNoAccountError 创建没有账号错误
func NewNoValidAccountError ¶ added in v1.0.10
func NewNoValidAccountError(platform string) *ResourceError
NewNoValidAccountError 创建没有有效账号错误
func NewPlatformNotFoundError ¶ added in v1.0.10
func NewPlatformNotFoundError(platform string) *ResourceError
NewPlatformNotFoundError 创建平台未找到错误
func NewResourceError ¶ added in v1.0.10
func NewResourceError(errorType ErrorType, message string, url string, details string) *ResourceError
NewResourceError 创建新的资源错误
func NewResourceSaveError ¶ added in v1.0.10
func NewResourceSaveError(url string, details string) *ResourceError
NewResourceSaveError 创建资源保存失败错误
func NewServiceCreationError ¶ added in v1.0.10
func NewServiceCreationError(url string, details string) *ResourceError
NewServiceCreationError 创建服务创建失败错误
func NewTagProcessingError ¶ added in v1.0.10
func NewTagProcessingError(details string) *ResourceError
NewTagProcessingError 创建标签处理失败错误
func NewTransferFailedError ¶ added in v1.0.10
func NewTransferFailedError(url string, details string) *ResourceError
NewTransferFailedError 创建转存失败错误
func NewUnsupportedLinkError ¶ added in v1.0.10
func NewUnsupportedLinkError(url string) *ResourceError
NewUnsupportedLinkError 创建不支持的链接错误
func (*ResourceError) Error ¶ added in v1.0.10
func (e *ResourceError) Error() string
Error 实现error接口
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler 定时任务管理器
func NewScheduler ¶
func NewScheduler(hotDramaRepo repo.HotDramaRepository, readyResourceRepo repo.ReadyResourceRepository, resourceRepo repo.ResourceRepository, systemConfigRepo repo.SystemConfigRepository, panRepo repo.PanRepository, cksRepo repo.CksRepository, tagRepo repo.TagRepository, categoryRepo repo.CategoryRepository) *Scheduler
NewScheduler 创建新的定时任务管理器
func (*Scheduler) GetHotDramaNames ¶
GetHotDramaNames 手动获取热播剧名字(用于测试或手动调用)
func (*Scheduler) IsAutoTransferRunning ¶
IsAutoTransferRunning 检查自动转存定时任务是否在运行
func (*Scheduler) IsReadyResourceRunning ¶
IsReadyResourceRunning 检查待处理资源自动处理任务是否在运行
func (*Scheduler) StartAutoTransferScheduler ¶
func (s *Scheduler) StartAutoTransferScheduler()
StartAutoTransferScheduler 启动自动转存定时任务
func (*Scheduler) StartHotDramaScheduler ¶
func (s *Scheduler) StartHotDramaScheduler()
StartHotDramaScheduler 启动热播剧定时任务
func (*Scheduler) StartReadyResourceScheduler ¶
func (s *Scheduler) StartReadyResourceScheduler()
StartReadyResourceScheduler 启动待处理资源自动处理任务
func (*Scheduler) StopAutoTransferScheduler ¶
func (s *Scheduler) StopAutoTransferScheduler()
StopAutoTransferScheduler 停止自动转存定时任务
func (*Scheduler) StopHotDramaScheduler ¶
func (s *Scheduler) StopHotDramaScheduler()
StopHotDramaScheduler 停止热播剧定时任务
func (*Scheduler) StopReadyResourceScheduler ¶
func (s *Scheduler) StopReadyResourceScheduler()
StopReadyResourceScheduler 停止待处理资源自动处理任务
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
BuildTime time.Time `json:"build_time"`
GitCommit string `json:"git_commit"`
GitBranch string `json:"git_branch"`
GoVersion string `json:"go_version"`
NodeVersion string `json:"node_version"`
Platform string `json:"platform"`
Arch string `json:"arch"`
}
VersionInfo 版本信息结构
func LoadVersionFromFile ¶
func LoadVersionFromFile(filename string) (*VersionInfo, error)
LoadVersionFromFile 从文件加载版本信息