Documentation
¶
Index ¶
- Constants
- Variables
- func IsExampleURL(url string) bool
- func MigrateExampleRSS(db *gorm.DB) error
- func SyncSitesFromRegistry(db *gorm.DB, registeredSites []RegisteredSite) error
- type APIResponse
- type AdminUser
- type Config
- type DiscountType
- type DownloaderDirectory
- type DownloaderSetting
- type DynamicSiteSetting
- type FaviconCache
- type FilterRule
- type FilterRuleDB
- func (f *FilterRuleDB) Create(rule *FilterRule) error
- func (f *FilterRuleDB) Delete(id uint) error
- func (f *FilterRuleDB) Exists(name string) (bool, error)
- func (f *FilterRuleDB) ExistsExcluding(name string, excludeID uint) (bool, error)
- func (f *FilterRuleDB) GetAll() ([]FilterRule, error)
- func (f *FilterRuleDB) GetByID(id uint) (*FilterRule, error)
- func (f *FilterRuleDB) GetByRSSID(rssID uint) ([]FilterRule, error)
- func (f *FilterRuleDB) GetBySiteID(siteID uint) ([]FilterRule, error)
- func (f *FilterRuleDB) GetEnabled() ([]FilterRule, error)
- func (f *FilterRuleDB) Update(rule *FilterRule) error
- type FreeDownChecker
- type MTTorrentDetail
- func (t MTTorrentDetail) CanbeFinished(logger *zap.SugaredLogger, enabled bool, speedLimit, sizeLimitGB int) bool
- func (t MTTorrentDetail) GetFreeEndTime() *time.Time
- func (t MTTorrentDetail) GetFreeLevel() string
- func (t MTTorrentDetail) GetName() string
- func (t MTTorrentDetail) GetSubTitle() string
- func (t MTTorrentDetail) IsFree() bool
- type MatchField
- type Migration
- type MigrationFunc
- type PHPTorrentInfo
- func (p PHPTorrentInfo) CanbeFinished(logger *zap.SugaredLogger, enabled bool, speedLimit, sizeLimitGB int) bool
- func (p PHPTorrentInfo) GetFreeEndTime() *time.Time
- func (p PHPTorrentInfo) GetFreeLevel() string
- func (p PHPTorrentInfo) GetName() string
- func (p PHPTorrentInfo) GetSubTitle() string
- func (p PHPTorrentInfo) IsFree() bool
- type PatternType
- type PromotionRule
- type QbitSettings
- type RSSConfig
- func (r *RSSConfig) GetEffectiveConcurrency(globalSettings *SettingsGlobal) int32
- func (r *RSSConfig) GetEffectiveDownloadPath() string
- func (r *RSSConfig) GetEffectiveIntervalMinutes(globalSettings *SettingsGlobal) int32
- func (r *RSSConfig) HasCustomDownloadPath() bool
- func (r *RSSConfig) ShouldSkip() bool
- type RSSFilterAssociation
- type RSSFilterAssociationDB
- func (r *RSSFilterAssociationDB) Create(assoc *RSSFilterAssociation) error
- func (r *RSSFilterAssociationDB) DeleteByFilterRuleID(filterRuleID uint) error
- func (r *RSSFilterAssociationDB) DeleteByRSSID(rssID uint) error
- func (r *RSSFilterAssociationDB) Exists(rssID, filterRuleID uint) (bool, error)
- func (r *RSSFilterAssociationDB) GetByFilterRuleID(filterRuleID uint) ([]uint, error)
- func (r *RSSFilterAssociationDB) GetByRSSID(rssID uint) ([]uint, error)
- func (r *RSSFilterAssociationDB) GetFilterRuleIDsForRSS(rssID uint) ([]uint, error)
- func (r *RSSFilterAssociationDB) GetFilterRulesForRSS(rssID uint) ([]FilterRule, error)
- func (r *RSSFilterAssociationDB) HasAssociations(rssID uint) (bool, error)
- func (r *RSSFilterAssociationDB) SetFilterRulesForRSS(rssID uint, filterRuleIDs []uint) error
- type RSSSubscription
- type RegisteredSite
- type ResType
- type SchemaManager
- type SchemaVersion
- type SettingsGlobal
- type Showcase
- type SiteConfig
- type SiteGroup
- type SiteSetting
- type SiteTemplate
- type SiteTemplateExport
- type Statistics
- type Status
- type TorrentDB
- func (t *TorrentDB) DeleteTorrent(torrentHash string) error
- func (t *TorrentDB) GetAllTorrents() ([]TorrentInfo, error)
- func (t *TorrentDB) GetTorrentBySiteAndHash(siteName, torrentHash string) (*TorrentInfo, error)
- func (t *TorrentDB) GetTorrentBySiteAndID(siteName, torrentID string) (*TorrentInfo, error)
- func (t *TorrentDB) UpdateTorrentStatus(torrentHash string, isDownloaded, isPushed bool, pushTime *time.Time) error
- func (t *TorrentDB) UpsertTorrent(torrent *TorrentInfo) error
- func (t *TorrentDB) WithTransaction(fn func(tx *gorm.DB) error) error
- type TorrentInfo
- type TorrentInfoArchive
- type TorrentMetadata
Constants ¶
const ( MinIntervalMinutes int32 = 5 // 最小间隔时间(分钟) DefaultIntervalMinutes int32 = 10 // 默认间隔时间(分钟) MaxIntervalMinutes int32 = 60 // 最大间隔时间(分钟) )
间隔时间常量
const ( MinConcurrency int32 = 1 // 最小并发数 DefaultConcurrency int32 = 3 // 默认并发数 MaxConcurrency int32 = 10 // 最大并发数 )
并发数常量
const ( DBFile = "torrents.db" WorkDir = ".pt-tools" )
const CurrentSchemaVersion = 4
当前数据库架构版本 每次添加新的迁移时递增此值
const (
DefaultAPIUrlMTeam = "https://api.m-team.cc"
)
Variables ¶
var ExampleRSSPatterns = []string{
"springxxx.xxx",
"hdsky.xxx",
"rss.m-team.xxx",
"example.com",
"xxx.xxx",
}
ExampleRSSPatterns 示例 RSS URL 的特征模式 包含这些模式的 URL 被认为是示例配置
Functions ¶
func IsExampleURL ¶ added in v0.2.0
IsExampleURL 检查 URL 是否为示例 URL
func MigrateExampleRSS ¶ added in v0.2.0
MigrateExampleRSS 迁移旧版本的示例 RSS 配置 将 URL 包含示例模式的 RSS 订阅标记为 IsExample=true
func SyncSitesFromRegistry ¶ added in v0.2.0
func SyncSitesFromRegistry(db *gorm.DB, registeredSites []RegisteredSite) error
SyncSitesFromRegistry 从注册表同步站点到数据库 每次应用启动时调用,确保数据库中包含所有注册的站点 保留用户配置(cookie/api_key/enabled),不删除任何用户数据
Types ¶
type APIResponse ¶
type AdminUser ¶ added in v0.1.0
type AdminUser struct {
ID uint `gorm:"primaryKey"`
Username string `gorm:"uniqueIndex;size:64"`
PasswordHash string `gorm:"size:255"`
CreatedAt time.Time
UpdatedAt time.Time
}
Admin 用户(单用户登录)
type Config ¶ added in v0.1.0
type Config struct {
Global SettingsGlobal `json:"global"`
Qbit QbitSettings `json:"qbit"`
Sites map[SiteGroup]SiteConfig `json:"sites"`
}
type DiscountType ¶
type DiscountType string
DiscountType 定义优惠类型
const ( DISCOUNT_NONE DiscountType = "none" DISCOUNT_FREE DiscountType = "free" DISCOUNT_TWO_X DiscountType = "2x" DISCOUNT_TWO_X_FREE DiscountType = "2xfree" DISCOUNT_THIRTY DiscountType = "30%" DISCOUNT_FIFTY DiscountType = "50%" DISCOUNT_TWO_X_FIFTY DiscountType = "2x50%" DISCOUNT_CUSTOM DiscountType = "custom" )
type DownloaderDirectory ¶ added in v0.2.0
type DownloaderDirectory struct {
ID uint `gorm:"primaryKey" json:"id"`
DownloaderID uint `gorm:"index;not null" json:"downloader_id"` // 关联的下载器ID
Path string `gorm:"size:512;not null" json:"path"` // 目录路径
Alias string `gorm:"size:128" json:"alias"` // 目录别名(用于显示)
IsDefault bool `json:"is_default"` // 是否为默认目录
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
DownloaderDirectory 下载器目录配置 用于设置下载器的多个下载目录及其别名
func (DownloaderDirectory) TableName ¶ added in v0.2.0
func (DownloaderDirectory) TableName() string
TableName 指定表名
type DownloaderSetting ¶ added in v0.2.0
type DownloaderSetting struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"uniqueIndex;size:64;not null" json:"name"`
Type string `gorm:"size:32;not null" json:"type"` // qbittorrent, transmission
URL string `gorm:"size:512;not null" json:"url"`
Username string `gorm:"size:128" json:"username"`
Password string `gorm:"size:256" json:"password"`
IsDefault bool `json:"is_default"`
Enabled bool `json:"enabled"`
AutoStart bool `json:"auto_start"` // 推送种子后自动开始下载
ExtraConfig string `gorm:"type:text" json:"extra_config,omitempty"` // JSON格式的额外配置
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
DownloaderSetting 下载器设置
func (DownloaderSetting) TableName ¶ added in v0.2.0
func (DownloaderSetting) TableName() string
TableName 指定表名
type DynamicSiteSetting ¶ added in v0.2.0
type DynamicSiteSetting struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"uniqueIndex;size:64;not null" json:"name"`
DisplayName string `gorm:"size:128" json:"display_name"`
BaseURL string `gorm:"size:512" json:"base_url"`
Enabled bool `json:"enabled"`
AuthMethod string `gorm:"size:16;not null" json:"auth_method"` // cookie, api_key
Cookie string `gorm:"size:2048" json:"cookie,omitempty"`
APIKey string `gorm:"size:512" json:"api_key,omitempty"`
APIURL string `gorm:"size:512" json:"api_url,omitempty"`
DownloaderID *uint `gorm:"index" json:"downloader_id,omitempty"` // 关联的下载器ID
ParserConfig string `gorm:"type:text" json:"parser_config"` // JSON格式的解析器配置
IsBuiltin bool `json:"is_builtin"` // 是否为内置站点
TemplateID *uint `gorm:"index" json:"template_id,omitempty"` // 关联的模板ID
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
DynamicSiteSetting 动态站点设置 扩展SiteSetting以支持动态站点
func (DynamicSiteSetting) TableName ¶ added in v0.2.0
func (DynamicSiteSetting) TableName() string
TableName 指定表名
type FaviconCache ¶ added in v0.2.0
type FaviconCache struct {
ID uint `gorm:"primaryKey" json:"id"`
SiteID string `gorm:"uniqueIndex;size:64;not null" json:"site_id"` // 站点标识,如 "hdsky", "mteam"
SiteName string `gorm:"size:128" json:"site_name"` // 站点名称
FaviconURL string `gorm:"size:512" json:"favicon_url"` // 原始 favicon URL
Data []byte `gorm:"type:blob" json:"-"` // 图标二进制数据
ContentType string `gorm:"size:64" json:"content_type"` // MIME 类型
ETag string `gorm:"size:128" json:"etag"` // 用于缓存验证
LastFetched time.Time `json:"last_fetched"` // 最后获取时间
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
FaviconCache 站点图标缓存(存储在数据库中)
type FilterRule ¶ added in v0.2.0
type FilterRule struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Pattern string `gorm:"size:512;not null" json:"pattern"`
PatternType PatternType `gorm:"size:16;not null;default:'keyword'" json:"pattern_type"`
MatchField MatchField `gorm:"size:16;not null;default:'both'" json:"match_field"`
RequireFree bool `gorm:"default:true" json:"require_free"`
Enabled bool `gorm:"default:true" json:"enabled"`
SiteID *uint `gorm:"index" json:"site_id"`
RSSID *uint `gorm:"index" json:"rss_id"`
Priority int `gorm:"default:100" json:"priority"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
FilterRule represents a user-defined filter rule for RSS items.
func (FilterRule) TableName ¶ added in v0.2.0
func (FilterRule) TableName() string
TableName returns the table name for FilterRule.
type FilterRuleDB ¶ added in v0.2.0
type FilterRuleDB struct {
// contains filtered or unexported fields
}
FilterRuleDB provides database operations for FilterRule.
func NewFilterRuleDB ¶ added in v0.2.0
func NewFilterRuleDB(db *TorrentDB) *FilterRuleDB
NewFilterRuleDB creates a new FilterRuleDB.
func (*FilterRuleDB) Create ¶ added in v0.2.0
func (f *FilterRuleDB) Create(rule *FilterRule) error
Create creates a new filter rule.
func (*FilterRuleDB) Delete ¶ added in v0.2.0
func (f *FilterRuleDB) Delete(id uint) error
Delete deletes a filter rule by ID.
func (*FilterRuleDB) Exists ¶ added in v0.2.0
func (f *FilterRuleDB) Exists(name string) (bool, error)
Exists checks if a filter rule with the given name exists.
func (*FilterRuleDB) ExistsExcluding ¶ added in v0.2.0
func (f *FilterRuleDB) ExistsExcluding(name string, excludeID uint) (bool, error)
ExistsExcluding checks if a filter rule with the given name exists, excluding a specific ID.
func (*FilterRuleDB) GetAll ¶ added in v0.2.0
func (f *FilterRuleDB) GetAll() ([]FilterRule, error)
GetAll retrieves all filter rules.
func (*FilterRuleDB) GetByID ¶ added in v0.2.0
func (f *FilterRuleDB) GetByID(id uint) (*FilterRule, error)
GetByID retrieves a filter rule by ID.
func (*FilterRuleDB) GetByRSSID ¶ added in v0.2.0
func (f *FilterRuleDB) GetByRSSID(rssID uint) ([]FilterRule, error)
GetByRSSID retrieves filter rules for a specific RSS subscription.
func (*FilterRuleDB) GetBySiteID ¶ added in v0.2.0
func (f *FilterRuleDB) GetBySiteID(siteID uint) ([]FilterRule, error)
GetBySiteID retrieves filter rules for a specific site.
func (*FilterRuleDB) GetEnabled ¶ added in v0.2.0
func (f *FilterRuleDB) GetEnabled() ([]FilterRule, error)
GetEnabled retrieves all enabled filter rules ordered by priority.
func (*FilterRuleDB) Update ¶ added in v0.2.0
func (f *FilterRuleDB) Update(rule *FilterRule) error
Update updates an existing filter rule.
type FreeDownChecker ¶
type MTTorrentDetail ¶
type MTTorrentDetail struct {
ID string `json:"id"`
CreatedDate string `json:"createdDate"`
LastModifiedDate string `json:"lastModifiedDate"`
Name string `json:"name"`
SmallDescr string `json:"smallDescr"`
IMDb string `json:"imdb"`
IMDbRating *string `json:"imdbRating"`
Douban string `json:"douban"`
DoubanRating *string `json:"doubanRating"`
DmmCode string `json:"dmmCode"`
Author any `json:"author"`
Category string `json:"category"`
Source string `json:"source"`
Medium any `json:"medium"`
Standard string `json:"standard"`
VideoCodec string `json:"videoCodec"`
AudioCodec string `json:"audioCodec"`
Team string `json:"team"`
Processing any `json:"processing"`
Countries []string `json:"countries"`
NumFiles string `json:"numfiles"`
Size string `json:"size"`
Tags string `json:"tags"`
Labels string `json:"labels"`
MsUp string `json:"msUp"`
Anonymous bool `json:"anonymous"`
InfoHash any `json:"infoHash"`
Status *Status `json:"status"`
EditedBy any `json:"editedBy"`
EditDate any `json:"editDate"`
Collection bool `json:"collection"`
InRss bool `json:"inRss"`
CanVote bool `json:"canVote"`
ImageList any `json:"imageList"`
ResetBox any `json:"resetBox"`
OriginFileName string `json:"originFileName"`
Descr string `json:"descr"`
Nfo any `json:"nfo"`
MediaInfo string `json:"mediainfo"`
CIDs any `json:"cids"`
AIDs any `json:"aids"`
ShowcaseList []Showcase `json:"showcaseList"`
TagList []any `json:"tagList"`
Scope string `json:"scope"`
ScopeTeams []any `json:"scopeTeams"`
Thanked bool `json:"thanked"`
Rewarded bool `json:"rewarded"`
}
func (MTTorrentDetail) CanbeFinished ¶
func (t MTTorrentDetail) CanbeFinished(logger *zap.SugaredLogger, enabled bool, speedLimit, sizeLimitGB int) bool
func (MTTorrentDetail) GetFreeEndTime ¶
func (t MTTorrentDetail) GetFreeEndTime() *time.Time
func (MTTorrentDetail) GetFreeLevel ¶ added in v0.0.6
func (t MTTorrentDetail) GetFreeLevel() string
func (MTTorrentDetail) GetName ¶ added in v0.2.0
func (t MTTorrentDetail) GetName() string
GetName 获取种子名称(返回中文名 Name)
func (MTTorrentDetail) GetSubTitle ¶ added in v0.2.0
func (t MTTorrentDetail) GetSubTitle() string
GetSubTitle 获取副标题(返回 SmallDescr)
func (MTTorrentDetail) IsFree ¶
func (t MTTorrentDetail) IsFree() bool
type MatchField ¶ added in v0.2.0
type MatchField string
MatchField represents which fields to match against.
const ( // MatchFieldTitle matches only against the title field. MatchFieldTitle MatchField = "title" // MatchFieldTag matches only against the tag field. MatchFieldTag MatchField = "tag" // MatchFieldBoth matches against both title and tag fields (default). MatchFieldBoth MatchField = "both" )
type Migration ¶ added in v0.2.0
type Migration struct {
Version int
Description string
Up MigrationFunc
}
Migration 迁移定义
type MigrationFunc ¶ added in v0.2.0
MigrationFunc 迁移函数类型
type PHPTorrentInfo ¶
type PHPTorrentInfo struct {
Title string // 种子标题
SubTitle string // 副标题/标签
TorrentID string // 种子 ID
Discount DiscountType // 优惠类型
EndTime time.Time // 优惠结束时间
SizeMB float64 // 种子大小,单位为 MB
Seeders int // 做种人数
Leechers int // 下载人数
Completed float64 // 最大完成百分比
HR bool // 是否为 HR(Hit & Run)
}
PHPTorrentInfo 定义种子信息结构
func (PHPTorrentInfo) CanbeFinished ¶
func (p PHPTorrentInfo) CanbeFinished(logger *zap.SugaredLogger, enabled bool, speedLimit, sizeLimitGB int) bool
func (PHPTorrentInfo) GetFreeEndTime ¶
func (p PHPTorrentInfo) GetFreeEndTime() *time.Time
func (PHPTorrentInfo) GetFreeLevel ¶ added in v0.0.6
func (p PHPTorrentInfo) GetFreeLevel() string
func (PHPTorrentInfo) GetName ¶ added in v0.2.0
func (p PHPTorrentInfo) GetName() string
GetName 获取种子名称
func (PHPTorrentInfo) GetSubTitle ¶ added in v0.2.0
func (p PHPTorrentInfo) GetSubTitle() string
GetSubTitle 获取副标题
func (PHPTorrentInfo) IsFree ¶
func (p PHPTorrentInfo) IsFree() bool
type PatternType ¶ added in v0.2.0
type PatternType string
PatternType represents the type of pattern matching to use.
const ( // PatternKeyword matches if the title contains the keyword (case-insensitive). PatternKeyword PatternType = "keyword" // PatternWildcard uses * and ? wildcards for matching. PatternWildcard PatternType = "wildcard" // PatternRegex uses regular expressions for matching. PatternRegex PatternType = "regex" )
type PromotionRule ¶
type QbitSettings ¶ added in v0.1.0
type QbitSettings struct {
ID uint `gorm:"primaryKey" json:"id"`
Enabled bool `json:"enabled"`
URL string `gorm:"not null" json:"url"`
User string `gorm:"not null" json:"user"`
Password string `gorm:"not null" json:"password"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
qBittorrent 设置
type RSSConfig ¶ added in v0.1.0
type RSSConfig struct {
ID uint `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Category string `json:"category"`
Tag string `json:"tag"`
IntervalMinutes int32 `json:"interval_minutes"` // RSS 执行间隔(分钟),0 表示使用全局设置
Concurrency int32 `json:"concurrency"` // 并发数,0 表示使用全局设置
DownloadSubPath string `json:"download_sub_path"`
DownloadPath string `json:"download_path"` // 下载器中下载任务的目标下载路径(可选)
DownloaderID *uint `json:"downloader_id"` // 指定下载器,nil 表示使用默认下载器
FilterRuleIDs []uint `json:"filter_rule_ids"` // 关联的过滤规则 ID 列表
IsExample bool `json:"is_example"` // 是否为示例配置,示例配置不会被执行
PauseOnFreeEnd bool `json:"pause_on_free_end"`
}
Runtime-friendly structures for API usage and scheduler/config load
func (*RSSConfig) GetEffectiveConcurrency ¶ added in v0.2.0
func (r *RSSConfig) GetEffectiveConcurrency(globalSettings *SettingsGlobal) int32
GetEffectiveConcurrency 获取有效的并发数 优先级:RSS 配置 > 全局配置 > 默认值
func (*RSSConfig) GetEffectiveDownloadPath ¶ added in v0.2.0
GetEffectiveDownloadPath 获取有效的下载路径 如果 RSS 配置了 DownloadPath 则使用,否则返回空字符串(使用下载器默认路径)
func (*RSSConfig) GetEffectiveIntervalMinutes ¶ added in v0.2.0
func (r *RSSConfig) GetEffectiveIntervalMinutes(globalSettings *SettingsGlobal) int32
GetEffectiveIntervalMinutes 获取有效的间隔时间 优先级:RSS 配置 > 全局配置 > 默认值
func (*RSSConfig) HasCustomDownloadPath ¶ added in v0.2.0
HasCustomDownloadPath 检查是否配置了自定义下载路径
func (*RSSConfig) ShouldSkip ¶ added in v0.2.0
ShouldSkip 判断是否应该跳过此 RSS 配置 示例配置或 URL 为空的配置应该被跳过
type RSSFilterAssociation ¶ added in v0.2.0
type RSSFilterAssociation struct {
ID uint `gorm:"primaryKey" json:"id"`
RSSID uint `gorm:"uniqueIndex:idx_rss_filter;not null" json:"rss_id"`
FilterRuleID uint `gorm:"uniqueIndex:idx_rss_filter;not null" json:"filter_rule_id"`
CreatedAt time.Time `json:"created_at"`
}
RSSFilterAssociation represents a many-to-many relationship between RSS subscriptions and filter rules.
func (RSSFilterAssociation) TableName ¶ added in v0.2.0
func (RSSFilterAssociation) TableName() string
TableName returns the table name for RSSFilterAssociation.
type RSSFilterAssociationDB ¶ added in v0.2.0
type RSSFilterAssociationDB struct {
// contains filtered or unexported fields
}
RSSFilterAssociationDB provides database operations for RSSFilterAssociation.
func NewRSSFilterAssociationDB ¶ added in v0.2.0
func NewRSSFilterAssociationDB(db *gorm.DB) *RSSFilterAssociationDB
NewRSSFilterAssociationDB creates a new RSSFilterAssociationDB.
func (*RSSFilterAssociationDB) Create ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) Create(assoc *RSSFilterAssociation) error
Create creates a new RSS-filter association.
func (*RSSFilterAssociationDB) DeleteByFilterRuleID ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) DeleteByFilterRuleID(filterRuleID uint) error
DeleteByFilterRuleID deletes all associations for a filter rule.
func (*RSSFilterAssociationDB) DeleteByRSSID ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) DeleteByRSSID(rssID uint) error
DeleteByRSSID deletes all associations for an RSS subscription.
func (*RSSFilterAssociationDB) Exists ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) Exists(rssID, filterRuleID uint) (bool, error)
Exists checks if an association exists.
func (*RSSFilterAssociationDB) GetByFilterRuleID ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) GetByFilterRuleID(filterRuleID uint) ([]uint, error)
GetByFilterRuleID retrieves all RSS IDs associated with a filter rule.
func (*RSSFilterAssociationDB) GetByRSSID ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) GetByRSSID(rssID uint) ([]uint, error)
GetByRSSID retrieves all filter rule IDs associated with an RSS subscription.
func (*RSSFilterAssociationDB) GetFilterRuleIDsForRSS ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) GetFilterRuleIDsForRSS(rssID uint) ([]uint, error)
GetFilterRuleIDsForRSS is an alias for GetByRSSID for better readability.
func (*RSSFilterAssociationDB) GetFilterRulesForRSS ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) GetFilterRulesForRSS(rssID uint) ([]FilterRule, error)
GetFilterRulesForRSS retrieves all filter rules associated with an RSS subscription.
func (*RSSFilterAssociationDB) HasAssociations ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) HasAssociations(rssID uint) (bool, error)
HasAssociations checks if an RSS subscription has any filter rule associations.
func (*RSSFilterAssociationDB) SetFilterRulesForRSS ¶ added in v0.2.0
func (r *RSSFilterAssociationDB) SetFilterRulesForRSS(rssID uint, filterRuleIDs []uint) error
SetFilterRulesForRSS sets the filter rules for an RSS subscription (replaces all existing associations).
type RSSSubscription ¶ added in v0.1.0
type RSSSubscription struct {
ID uint `gorm:"primaryKey" json:"id"`
SiteID uint `gorm:"index" json:"site_id"`
Name string `gorm:"size:128;not null" json:"name"`
URL string `gorm:"size:1024;not null" json:"url"`
Category string `gorm:"size:128" json:"category"`
Tag string `gorm:"size:128" json:"tag"`
IntervalMinutes int32 `gorm:"check:interval_minutes >= 1" json:"interval_minutes"` // RSS 执行间隔(分钟),0 表示使用全局设置
Concurrency int32 `json:"concurrency"` // 并发数,0 表示使用全局设置
DownloadSubPath string `gorm:"size:256" json:"download_sub_path"`
DownloadPath string `gorm:"size:512" json:"download_path"` // 下载器中下载任务的目标下载路径(可选)
DownloaderID *uint `gorm:"index" json:"downloader_id"` // 指定下载器,nil 表示使用默认下载器
IsExample bool `json:"is_example"` // 是否为示例配置,示例配置不会被执行
PauseOnFreeEnd bool `gorm:"default:false" json:"pause_on_free_end"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RSS 订阅
type RegisteredSite ¶ added in v0.2.0
type RegisteredSite struct {
ID string
Name string
AuthMethod string // "cookie" 或 "api_key"
DefaultAPIUrl string
}
RegisteredSite 表示从注册表获取的站点信息
type ResType ¶
type ResType interface {
MTTorrentDetail | PHPTorrentInfo
FreeDownChecker
TorrentMetadata
}
type SchemaManager ¶ added in v0.2.0
type SchemaManager struct {
// contains filtered or unexported fields
}
SchemaManager 架构版本管理器
func NewSchemaManager ¶ added in v0.2.0
func NewSchemaManager(db *gorm.DB, appVersion string) *SchemaManager
NewSchemaManager 创建架构版本管理器
func (*SchemaManager) EnsureSchemaVersionTable ¶ added in v0.2.0
func (sm *SchemaManager) EnsureSchemaVersionTable() error
EnsureSchemaVersionTable 确保版本表存在
func (*SchemaManager) GetCurrentVersion ¶ added in v0.2.0
func (sm *SchemaManager) GetCurrentVersion() (int, error)
GetCurrentVersion 获取当前数据库架构版本
func (*SchemaManager) RecordVersion ¶ added in v0.2.0
func (sm *SchemaManager) RecordVersion(version int, description string) error
RecordVersion 记录版本
func (*SchemaManager) RunMigrations ¶ added in v0.2.0
func (sm *SchemaManager) RunMigrations() error
RunMigrations 运行所有待执行的迁移
type SchemaVersion ¶ added in v0.2.0
type SchemaVersion struct {
ID uint `gorm:"primaryKey" json:"id"`
Version int `gorm:"uniqueIndex;not null" json:"version"` // 架构版本号
Description string `gorm:"size:255" json:"description"` // 版本描述
AppliedAt time.Time `gorm:"not null" json:"applied_at"` // 应用时间
AppVersion string `gorm:"size:64" json:"app_version"` // 应用版本
}
SchemaVersion 数据库架构版本表 用于跟踪数据库迁移状态
type SettingsGlobal ¶ added in v0.1.0
type SettingsGlobal struct {
ID uint `gorm:"primaryKey" json:"id"`
DefaultIntervalMinutes int32 `json:"default_interval_minutes" gorm:"default:10"` // 默认 RSS 执行间隔(分钟)
DefaultConcurrency int32 `json:"default_concurrency" gorm:"default:3"` // 默认并发数
DefaultEnabled bool `json:"default_enabled"`
DownloadDir string `gorm:"not null" json:"download_dir"`
DownloadLimitEnabled bool `json:"download_limit_enabled"`
DownloadSpeedLimit int `json:"download_speed_limit"`
TorrentSizeGB int `json:"torrent_size_gb"`
AutoStart bool `json:"auto_start"`
RetainHours int `json:"retain_hours" gorm:"default:24"`
MaxRetry int `json:"max_retry" gorm:"default:3"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
全局设置
func (*SettingsGlobal) GetEffectiveConcurrency ¶ added in v0.2.0
func (s *SettingsGlobal) GetEffectiveConcurrency() int32
GetEffectiveConcurrency 获取有效的并发数(带默认值和边界检查)
func (*SettingsGlobal) GetEffectiveIntervalMinutes ¶ added in v0.2.0
func (s *SettingsGlobal) GetEffectiveIntervalMinutes() int32
GetEffectiveIntervalMinutes 获取有效的间隔时间(带默认值和边界检查)
type Showcase ¶
type Showcase struct {
CreatedDate string `json:"createdDate"`
LastModifiedDate string `json:"lastModifiedDate"`
ID string `json:"id"`
Collection bool `json:"collection"`
UserID string `json:"userid"`
Username string `json:"username"`
CnTitle string `json:"cntitle"`
EnTitle string `json:"entitle"`
Note string `json:"note"`
Pic string `json:"pic"`
Pic1 string `json:"pic1"`
Pic2 string `json:"pic2"`
Count string `json:"count"`
Size string `json:"size"`
View string `json:"view"`
Statistics Statistics `json:"statistics"`
}
type SiteConfig ¶ added in v0.1.0
type SiteGroup ¶
type SiteGroup string
const ( SpringSunday SiteGroup = "springsunday" HDSKY SiteGroup = "hdsky" MTEAM SiteGroup = "mteam" HDDOLBY SiteGroup = "hddolby" )
允许的值
func ValidateSiteName ¶
type SiteSetting ¶ added in v0.1.0
type SiteSetting struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"index;size:32" json:"name"`
Enabled bool `json:"enabled"`
AuthMethod string `gorm:"size:16;not null" json:"auth_method"`
Cookie string `gorm:"size:1024" json:"cookie"`
APIKey string `gorm:"size:512" json:"api_key"`
APIUrl string `gorm:"size:512" json:"api_url"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
站点设置
type SiteTemplate ¶ added in v0.2.0
type SiteTemplate struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"uniqueIndex;size:64;not null" json:"name"`
DisplayName string `gorm:"size:128" json:"display_name"`
BaseURL string `gorm:"size:512;not null" json:"base_url"`
AuthMethod string `gorm:"size:16;not null" json:"auth_method"` // cookie, api_key
ParserConfig string `gorm:"type:text" json:"parser_config"` // JSON格式的解析器配置
Description string `gorm:"size:1024" json:"description"`
Version string `gorm:"size:32" json:"version"`
Author string `gorm:"size:64" json:"author"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SiteTemplate 站点模板 用于导入/导出站点配置(不包含敏感信息)
func (*SiteTemplate) FromExport ¶ added in v0.2.0
func (t *SiteTemplate) FromExport(export *SiteTemplateExport) error
FromExport 从导出格式创建
func (SiteTemplate) TableName ¶ added in v0.2.0
func (SiteTemplate) TableName() string
TableName 指定表名
func (*SiteTemplate) ToExport ¶ added in v0.2.0
func (t *SiteTemplate) ToExport() *SiteTemplateExport
ToExport 转换为导出格式
type SiteTemplateExport ¶ added in v0.2.0
type SiteTemplateExport struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
BaseURL string `json:"base_url"`
AuthMethod string `json:"auth_method"`
ParserConfig json.RawMessage `json:"parser_config,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
Author string `json:"author,omitempty"`
}
SiteTemplateExport 导出格式(不包含数据库字段)
type Statistics ¶
type Statistics struct {
CreatedDate string `json:"createdDate"`
LastModifiedDate string `json:"lastModifiedDate"`
ID string `json:"id"`
Day string `json:"day"`
Week string `json:"week"`
Month string `json:"month"`
Year string `json:"year"`
DayClick string `json:"dayClick"`
WeekClick string `json:"weekClick"`
MonthClick string `json:"monthClick"`
YearClick string `json:"yearClick"`
}
type Status ¶
type Status struct {
ID string `json:"id"`
CreatedDate string `json:"createdDate"`
LastModifiedDate string `json:"lastModifiedDate"`
PickType string `json:"pickType"`
ToppingLevel string `json:"toppingLevel"`
ToppingEndTime string `json:"toppingEndTime"`
Discount string `json:"discount"`
DiscountEndTime string `json:"discountEndTime"`
TimesCompleted string `json:"timesCompleted"`
Comments string `json:"comments"`
LastAction string `json:"lastAction"`
LastSeederAction string `json:"lastSeederAction"`
Views string `json:"views"`
Hits string `json:"hits"`
Support string `json:"support"`
Oppose string `json:"oppose"`
Status string `json:"status"`
Seeders string `json:"seeders"`
Leechers string `json:"leechers"`
Banned bool `json:"banned"`
Visible bool `json:"visible"`
PromotionRule *PromotionRule `json:"promotionRule"`
MallSingleFree any `json:"mallSingleFree"`
}
type TorrentDB ¶
TorrentDB 封装数据库操作
func NewDBWithVersion ¶ added in v0.2.0
NewDBWithVersion 初始化并返回 TorrentDB(带应用版本)
func (*TorrentDB) DeleteTorrent ¶
DeleteTorrent 删除种子信息
func (*TorrentDB) GetAllTorrents ¶
func (t *TorrentDB) GetAllTorrents() ([]TorrentInfo, error)
GetAllTorrents 查询所有种子信息
func (*TorrentDB) GetTorrentBySiteAndHash ¶
func (t *TorrentDB) GetTorrentBySiteAndHash(siteName, torrentHash string) (*TorrentInfo, error)
GetTorrentBySiteAndHash 根据 SiteName 和 TorrentHash 查询种子信息
func (*TorrentDB) GetTorrentBySiteAndID ¶
func (t *TorrentDB) GetTorrentBySiteAndID(siteName, torrentID string) (*TorrentInfo, error)
GetTorrentBySiteAndID 根据 SiteName 和 TorrentID 查询种子信息
func (*TorrentDB) UpdateTorrentStatus ¶
func (t *TorrentDB) UpdateTorrentStatus(torrentHash string, isDownloaded, isPushed bool, pushTime *time.Time) error
UpdateTorrentStatus 更新种子状态
func (*TorrentDB) UpsertTorrent ¶
func (t *TorrentDB) UpsertTorrent(torrent *TorrentInfo) error
UpsertTorrent 插入或更新种子信息
type TorrentInfo ¶
type TorrentInfo struct {
ID uint `gorm:"primaryKey" json:"id"`
SiteName string `gorm:"uniqueIndex:idx_site_torrent" json:"siteName"`
TorrentID string `gorm:"uniqueIndex:idx_site_torrent" json:"torrentId"`
TorrentHash *string `gorm:"index" json:"torrentHash"`
IsFree bool `gorm:"default:false" json:"isFree"`
IsDownloaded bool `gorm:"default:false" json:"isDownloaded"`
IsPushed *bool `gorm:"default:null" json:"isPushed"`
IsSkipped bool `gorm:"default:false" json:"isSkipped"`
FreeLevel string `gorm:"default:'normal'" json:"freeLevel"`
FreeEndTime *time.Time `gorm:"default:null" json:"freeEndTime"`
PushTime *time.Time `gorm:"default:null" json:"pushTime"`
Title string `gorm:"default:''" json:"title"`
Category string `gorm:"default:''" json:"category"`
Tag string `gorm:"default:''" json:"tag"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
IsExpired bool `gorm:"default:false" json:"isExpired"`
LastCheckTime *time.Time `gorm:"default:null" json:"lastCheckTime"`
RetryCount int `gorm:"default:0" json:"retryCount"`
LastError string `gorm:"default:''" json:"lastError"`
DownloadSource string `gorm:"size:32;default:'free_download'" json:"downloadSource"` // free_download or filter_rule
FilterRuleID *uint `gorm:"index" json:"filterRuleId"` // ID of the matched filter rule
// 免费结束管理相关字段
DownloaderID *uint `gorm:"index" json:"downloaderId"` // 推送到的下载器 ID
DownloaderName string `gorm:"size:64;default:''" json:"downloaderName"` // 下载器名称(冗余存储便于查询)
CompletedAt *time.Time `gorm:"default:null" json:"completedAt"` // 下载完成时间
IsPausedBySystem bool `gorm:"default:false" json:"isPausedBySystem"` // 是否被系统自动暂停
PauseOnFreeEnd bool `gorm:"default:false" json:"pauseOnFreeEnd"` // 免费结束时是否暂停(来自 RSS 配置)
PausedAt *time.Time `gorm:"default:null" json:"pausedAt"` // 系统暂停时间
PauseReason string `gorm:"size:256;default:''" json:"pauseReason"` // 暂停原因
IsCompleted bool `gorm:"default:false;index" json:"isCompleted"` // 下载是否已完成
Progress float64 `gorm:"default:0" json:"progress"` // 下载进度 (0-100)
TorrentSize int64 `gorm:"default:0" json:"torrentSize"` // 种子大小(字节)
DownloaderTaskID string `gorm:"size:128;default:''" json:"downloaderTaskId"` // 下载器中的任务 ID(用于暂停/删除操作)
CheckCount int `gorm:"default:0" json:"checkCount"` // 进度检查次数
}
TorrentInfo 表示种子信息
func (*TorrentInfo) GetExpired ¶ added in v0.0.10
func (t *TorrentInfo) GetExpired() bool
type TorrentInfoArchive ¶ added in v0.3.0
type TorrentInfoArchive struct {
ID uint `gorm:"primaryKey" json:"id"`
OriginalID uint `gorm:"index" json:"originalId"`
SiteName string `gorm:"index" json:"siteName"`
TorrentID string `gorm:"index" json:"torrentId"`
TorrentHash *string `gorm:"index" json:"torrentHash"`
IsFree bool `json:"isFree"`
IsDownloaded bool `json:"isDownloaded"`
IsPushed *bool `json:"isPushed"`
IsSkipped bool `json:"isSkipped"`
FreeLevel string `json:"freeLevel"`
FreeEndTime *time.Time `json:"freeEndTime"`
PushTime *time.Time `json:"pushTime"`
Title string `json:"title"`
Category string `json:"category"`
Tag string `json:"tag"`
OriginalCreatedAt time.Time `json:"originalCreatedAt"`
OriginalUpdatedAt time.Time `json:"originalUpdatedAt"`
IsExpired bool `json:"isExpired"`
LastCheckTime *time.Time `json:"lastCheckTime"`
RetryCount int `json:"retryCount"`
LastError string `json:"lastError"`
DownloadSource string `json:"downloadSource"`
FilterRuleID *uint `json:"filterRuleId"`
DownloaderID *uint `json:"downloaderId"`
DownloaderName string `json:"downloaderName"`
CompletedAt *time.Time `json:"completedAt"`
IsPausedBySystem bool `json:"isPausedBySystem"`
PauseOnFreeEnd bool `json:"pauseOnFreeEnd"`
PausedAt *time.Time `json:"pausedAt"`
PauseReason string `json:"pauseReason"`
IsCompleted bool `json:"isCompleted"`
Progress float64 `json:"progress"`
TorrentSize int64 `json:"torrentSize"`
DownloaderTaskID string `json:"downloaderTaskId"`
CheckCount int `json:"checkCount"`
ArchivedAt time.Time `gorm:"autoCreateTime" json:"archivedAt"`
}
TorrentInfoArchive 种子信息归档表(存储超过保留期的记录)
type TorrentMetadata ¶ added in v0.2.0
type TorrentMetadata interface {
// GetName 获取种子名称(优先返回中文名)
GetName() string
// GetSubTitle 获取副标题/标签信息
GetSubTitle() string
}
TorrentMetadata 统一的种子元数据接口 用于获取种子的标题、副标题等信息,便于过滤规则匹配