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 ActionAudit
- type AdminUser
- type BotToken
- type ChannelBinding
- type Config
- type DiscountType
- type DownloaderDirectory
- type DownloaderSetting
- type FaviconCache
- type FilterMode
- 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) GetSizeBytes() int64
- func (t MTTorrentDetail) GetSubTitle() string
- func (t MTTorrentDetail) IsFree() bool
- type MatchField
- type Migration
- type MigrationFunc
- type NotificationConf
- type NotificationOutbox
- 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) GetSizeBytes() int64
- 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) GetEffectiveFilterMode(globalSettings *SettingsGlobal) FilterMode
- 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 RSSNotificationLog
- type RSSSubscription
- type RegisteredSite
- type ResType
- type SchemaManager
- type SchemaVersion
- type SettingsGlobal
- type Showcase
- type SiteConfig
- type SiteData
- type SiteGroup
- type SiteRateLimit
- type SiteRepository
- func (r *SiteRepository) BatchUpdateSiteDownloader(siteIDs []uint, downloaderID uint) (int64, error)
- func (r *SiteRepository) CreateSite(data SiteData) (uint, error)
- func (r *SiteRepository) DeleteSite(name string) error
- func (r *SiteRepository) GetSiteByID(id uint) (*SiteSetting, error)
- func (r *SiteRepository) GetSiteByName(name string) (*SiteSetting, error)
- func (r *SiteRepository) ListEnabledSites() ([]SiteSetting, error)
- func (r *SiteRepository) ListSites() ([]SiteSetting, error)
- func (r *SiteRepository) SiteExistsByName(name string) (bool, error)
- func (r *SiteRepository) UpdateSiteCredentials(name string, enabled *bool, authMethod, cookie, apiKey, apiURL, passkey string) error
- func (r *SiteRepository) UpdateSiteDownloader(name string, downloaderID *uint) error
- func (r *SiteRepository) UpdateSiteDownloaderByID(siteID uint, downloaderID *uint) error
- 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
- func (t *TorrentDB) WithTransactionContext(ctx context.Context, fn func(tx *gorm.DB) error) error
- type TorrentInfo
- type TorrentInfoArchive
- type TorrentMetadata
Constants ¶
const ( MinIntervalMinutes int32 = 5 // 最小间隔时间(分钟) DefaultIntervalMinutes int32 = 10 // 默认间隔时间(分钟) MaxIntervalMinutes int32 = 1440 // 最大间隔时间(分钟) )
间隔时间常量
const ( MinConcurrency int32 = 1 // 最小并发数 DefaultConcurrency int32 = 3 // 默认并发数 MaxConcurrency int32 = 10 // 最大并发数 )
并发数常量
const ( DefaultPeerRatioMaxSL = 30.0 MinPeerRatioMaxSL = 1.0 DefaultPeerRatioIntervalMin = 10 MinPeerRatioIntervalMin = 5 )
const ( DBFile = "torrents.db" WorkDir = ".pt-tools" )
const CurrentSchemaVersion = 8
当前数据库架构版本 每次添加新的迁移时递增此值
const DefaultFilterMode = FilterModeAutoFree
DefaultFilterMode is the fallback when neither RSS nor Global specifies one.
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 ActionAudit ¶ added in v0.31.0
type ActionAudit struct {
ID uint `gorm:"primaryKey" json:"id"`
NotificationConfID uint `gorm:"not null;index:idx_action_audit_conf_user_time,priority:1" json:"notification_conf_id"`
ChannelType string `gorm:"size:32;not null" json:"channel_type"`
ChannelUserID string `gorm:"size:128;not null;index:idx_action_audit_conf_user_time,priority:2" json:"channel_user_id"`
Command string `gorm:"size:64;not null;index:idx_action_audit_command" json:"command"`
ArgsJSON string `gorm:"type:text" json:"args_json"`
Result string `gorm:"size:32;not null" json:"result"`
LatencyMs int64 `gorm:"default:0" json:"latency_ms"`
CreatedAt time.Time `gorm:"index:idx_action_audit_conf_user_time,priority:3,sort:desc" json:"created_at"`
}
ActionAudit 命令执行审计日志,Result 取值如 "ok" / "denied" / "error"。 复合索引 (notification_conf_id, channel_user_id, created_at) 用于按用户分页倒序查询。
func (ActionAudit) TableName ¶ added in v0.31.0
func (ActionAudit) TableName() string
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 BotToken ¶ added in v0.31.0
type BotToken struct {
ID uint `gorm:"primaryKey" json:"id"`
Kind string `gorm:"size:16;not null;index:idx_bot_token_kind" json:"kind"`
CodeOrTokenHash string `gorm:"size:255;not null;index:idx_bot_token_hash" json:"-"`
Scope string `gorm:"size:255;default:''" json:"scope"`
ExpiresAt *time.Time `gorm:"index:idx_bot_token_expires" json:"expires_at"`
UsedAt *time.Time `json:"used_at"`
CreatedBy string `gorm:"size:64" json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
BotToken 鉴权用 token / 8-char bind code 的持久化记录。 Kind 取值如 "bind_code" / "bearer";CodeOrTokenHash 为 bcrypt hash。
type ChannelBinding ¶ added in v0.31.0
type ChannelBinding struct {
ID uint `gorm:"primaryKey" json:"id"`
NotificationConfID uint `gorm:"not null;index:idx_channel_binding_conf_user,priority:1" json:"notification_conf_id"`
ChannelType string `gorm:"size:32;not null;index:idx_channel_binding_type" json:"channel_type"`
ChannelUserID string `gorm:"size:128;not null;index:idx_channel_binding_conf_user,priority:2" json:"channel_user_id"`
PtAdmin bool `gorm:"default:false" json:"pt_admin"`
Allowed bool `gorm:"default:false" json:"allowed"`
Label string `gorm:"size:128" json:"label"`
ReplyLang string `gorm:"size:16;default:''" json:"reply_lang"`
CreatedAt time.Time `json:"created_at"`
LastActiveAt *time.Time `json:"last_active_at"`
}
ChannelBinding 渠道用户与 NotificationConf 的绑定关系。 PtAdmin 标记该用户是否为管理员;Allowed 表示是否在白名单内。
func (ChannelBinding) TableName ¶ added in v0.31.0
func (ChannelBinding) TableName() string
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 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 FilterMode ¶ added in v0.25.0
type FilterMode string
FilterMode controls which download channels are active for an RSS feed.
const ( // FilterModeAutoFree enables both the free auto-download channel and // the filter-rule channel. This preserves pre-v0.25 behavior and is the default. FilterModeAutoFree FilterMode = "auto_free" // FilterModeFilterOnly disables the free auto-download channel; only torrents // matching an associated filter rule are downloaded. FilterModeFilterOnly FilterMode = "filter_only" // FilterModeFreeOnly disables the filter-rule channel; only free torrents // that can be finished in time are downloaded (ignores associated rules). FilterModeFreeOnly FilterMode = "free_only" )
func NormalizeFilterMode ¶ added in v0.25.0
func NormalizeFilterMode(m FilterMode) FilterMode
NormalizeFilterMode returns a validated FilterMode, falling back to DefaultFilterMode when the input is empty or unrecognized.
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"`
MinSizeGB int `gorm:"default:0" json:"min_size_gb"`
MaxSizeGB int `gorm:"default:0" json:"max_size_gb"`
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"`
// Purpose 区分规则用途:
// "download" — 仅用于下载(默认,向后兼容空值)
// "notify" — 仅用于通知(filtered 模式)
// "both" — 下载与通知都使用
Purpose string `gorm:"column:purpose;not null;default:'download'" json:"purpose"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
FilterRule represents a user-defined filter rule for RSS items.
func (*FilterRule) MatchesSize ¶ added in v0.25.0
func (r *FilterRule) MatchesSize(sizeGB float64) bool
MatchesSize reports whether the torrent size (in GB) satisfies this rule's optional MinSizeGB / MaxSizeGB bounds. Zero on either side means "no bound". The rule's bounds can only narrow the global TorrentSizeGB; never widen it.
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) GetSizeBytes ¶ added in v0.25.0
func (t MTTorrentDetail) GetSizeBytes() int64
GetSizeBytes 获取种子大小(字节);解析失败时返回 0。
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 NotificationConf ¶ added in v0.31.0
type NotificationConf struct {
ID uint `gorm:"primaryKey" json:"id"`
ChannelType string `gorm:"size:32;not null;index:idx_notification_conf_type" json:"channel_type"`
Name string `gorm:"size:128;not null" json:"name"`
ConfigJSON string `gorm:"type:text" json:"-"`
Enabled bool `gorm:"default:true;index:idx_notification_conf_enabled" json:"enabled"`
// QuietHoursStart / QuietHoursEnd 控制静默时段,格式 "HH:MM";空字符串表示无静默。
// 若 start > end(如 "22:00"–"08:00")表示窗口跨越午夜。
QuietHoursStart string `gorm:"column:quiet_hours_start;default:''" json:"quiet_hours_start"`
QuietHoursEnd string `gorm:"column:quiet_hours_end;default:''" json:"quiet_hours_end"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NotificationConf 通知通道配置(Telegram / QQ / Webhook / WeCom 等)。 ConfigJSON 由 internal/crypto AES-GCM 加密后存入,本层仅原样存取字符串。
func (NotificationConf) TableName ¶ added in v0.31.0
func (NotificationConf) TableName() string
TableName 强制单数表名,避免 GORM 默认复数化与项目命名风格不一致。
type NotificationOutbox ¶ added in v0.31.0
type NotificationOutbox struct {
ID uint `gorm:"primaryKey" json:"id"`
NotificationConfID uint `gorm:"not null;index:idx_notification_outbox_conf" json:"notification_conf_id"`
PayloadJSON string `gorm:"type:text;not null" json:"payload_json"`
Status string `gorm:"size:16;not null;default:'pending';index:idx_notification_outbox_status_retry,priority:1" json:"status"`
RetryCount int `gorm:"default:0" json:"retry_count"`
NextRetryAt time.Time `gorm:"index:idx_notification_outbox_status_retry,priority:2" json:"next_retry_at"`
CreatedAt time.Time `json:"created_at"`
SentAt *time.Time `json:"sent_at"`
ErrorMsg string `gorm:"size:1024;default:''" json:"error_msg"`
}
NotificationOutbox 离线投递队列。Status 取值:pending / sent / failed / dead。 复合索引 (status, next_retry_at) 用于 worker 高效扫描待发送记录。
func (NotificationOutbox) TableName ¶ added in v0.31.0
func (NotificationOutbox) TableName() string
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) GetSizeBytes ¶ added in v0.25.0
func (p PHPTorrentInfo) GetSizeBytes() int64
GetSizeBytes 获取种子大小(字节),由 SizeMB 换算得到。
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"`
FilterMode FilterMode `json:"filter_mode"` // 空字符串表示使用全局 DefaultFilterMode
NotifyMode string `json:"notify_mode"`
NotifyConfIDs string `json:"notify_conf_ids"`
MaxNotificationsPerHour int `json:"max_notifications_per_hour"`
}
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) GetEffectiveFilterMode ¶ added in v0.25.0
func (r *RSSConfig) GetEffectiveFilterMode(globalSettings *SettingsGlobal) FilterMode
GetEffectiveFilterMode resolves the filter mode using the RSS > Global > Default priority. RSS-level value takes precedence; empty falls through to the global default; unknown values also fall back to DefaultFilterMode via NormalizeFilterMode.
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 RSSNotificationLog ¶ added in v0.31.0
type RSSNotificationLog struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
RSSID uint `` /* 132-byte string literal not displayed */
SiteName string `gorm:"column:site_name;not null;uniqueIndex:idx_rss_notify_dedup,priority:2" json:"site_name"`
TorrentID string `gorm:"column:torrent_id;not null;uniqueIndex:idx_rss_notify_dedup,priority:3" json:"torrent_id"`
NotifyKind string `gorm:"column:notify_kind;not null;uniqueIndex:idx_rss_notify_dedup,priority:4" json:"notify_kind"`
NotificationConfID uint `gorm:"column:notification_conf_id;not null;uniqueIndex:idx_rss_notify_dedup,priority:5" json:"notification_conf_id"`
MatchedFilterRuleID *uint `gorm:"column:matched_filter_rule_id" json:"matched_filter_rule_id,omitempty"`
Result string `gorm:"not null;index:idx_rss_notify_pending,priority:1" json:"result"`
Attempts int `gorm:"default:0" json:"attempts"`
NextRetryAt *time.Time `gorm:"column:next_retry_at;index:idx_rss_notify_pending,priority:2" json:"next_retry_at,omitempty"`
LastError string `gorm:"default:''" json:"last_error,omitempty"`
PayloadJSON string `gorm:"column:payload_json" json:"payload_json,omitempty"`
DeliveredAt *time.Time `gorm:"column:delivered_at" json:"delivered_at,omitempty"`
CreatedAt time.Time `gorm:"index:idx_rss_notify_rss_throttle,priority:2" json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RSSNotificationLog records every (rss_id, torrent_id, notify_kind, conf_id) notification attempt. Acts as the durable record AND the idempotency guard (via the unique index idx_rss_notify_dedup).
result values: 'sent' | 'failed' | 'suppressed' | 'pending' | 'throttled'
- 'sent' — accepted by NotificationService.Push (note: may have fallen back to outbox internally; not strictly equal to "delivered to user")
- 'failed' — Push returned an error
- 'suppressed' — overshadowed by a later 'filtered' notification for the same (rss_id, site_name, torrent_id)
- 'pending' — queued but not yet attempted (S3 retry worker uses this)
- 'throttled' — rejected because RSS hit max_notifications_per_hour
func (RSSNotificationLog) TableName ¶ added in v0.31.0
func (RSSNotificationLog) TableName() string
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"`
FilterMode FilterMode `gorm:"size:16;default:''" json:"filter_mode"` // 空字符串表示使用全局 DefaultFilterMode
NotifyMode string `gorm:"column:notify_mode;default:''" json:"notify_mode"`
NotifyConfIDs string `gorm:"column:notify_conf_ids;default:'[]'" json:"notify_conf_ids"`
MaxNotificationsPerHour int `gorm:"column:max_notifications_per_hour;default:100" json:"max_notifications_per_hour"`
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"
DefaultBaseURL string
APIUrls []string // API URL 列表,用于轮换(如 mTorrent 站点)
}
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"`
MinFreeMinutes int `json:"min_free_minutes" gorm:"default:30"`
AutoStart bool `json:"auto_start"`
RetainHours int `json:"retain_hours" gorm:"default:24"`
MaxRetry int `json:"max_retry" gorm:"default:3"`
// 自动删种
CleanupEnabled bool `json:"cleanup_enabled" gorm:"default:false"`
CleanupIntervalMin int `json:"cleanup_interval_min" gorm:"default:30"`
CleanupScope string `json:"cleanup_scope" gorm:"size:16;default:'database'"`
CleanupScopeTags string `json:"cleanup_scope_tags" gorm:"size:256"`
CleanupRemoveData bool `json:"cleanup_remove_data" gorm:"default:true"`
CleanupConditionMode string `json:"cleanup_condition_mode" gorm:"size:8;default:'or'"`
CleanupMaxSeedTimeH int `json:"cleanup_max_seed_time_h" gorm:"default:0"`
CleanupMinRatio float64 `json:"cleanup_min_ratio" gorm:"default:0"`
CleanupMaxInactiveH int `json:"cleanup_max_inactive_h" gorm:"default:0"`
CleanupSlowSeedTimeH int `json:"cleanup_slow_seed_time_h" gorm:"default:0"`
CleanupSlowMaxRatio float64 `json:"cleanup_slow_max_ratio" gorm:"default:0"`
CleanupDelFreeExpired bool `json:"cleanup_del_free_expired" gorm:"default:true"`
CleanupDiskProtect bool `json:"cleanup_disk_protect" gorm:"default:true"`
CleanupMinDiskSpaceGB float64 `json:"cleanup_min_disk_space_gb" gorm:"default:50"`
CleanupProtectDL bool `json:"cleanup_protect_dl" gorm:"default:false"`
CleanupProtectHR bool `json:"cleanup_protect_hr" gorm:"default:true"`
CleanupMinRetainH int `json:"cleanup_min_retain_h" gorm:"default:24"`
CleanupProtectTags string `json:"cleanup_protect_tags" gorm:"size:256"`
// 免费结束自动删除
AutoDeleteOnFreeEnd bool `json:"auto_delete_on_free_end" gorm:"default:false"` // 免费期结束时自动删除未完成的种子及数据
// 默认下载模式(RSS 级别可 override)
DefaultFilterMode FilterMode `json:"default_filter_mode" gorm:"size:16;default:'auto_free'"`
// 做种竞争度监控(Peer Ratio Monitor)
PeerRatioEnabled bool `json:"peer_ratio_enabled" gorm:"default:false"` // 是否启用做种竞争度监控
PeerRatioMaxSL float64 `json:"peer_ratio_max_sl" gorm:"default:30.0"` // Seeder/Leecher 比值上限
PeerRatioIntervalMin int `json:"peer_ratio_interval_min" gorm:"default:10"` // 检查间隔(分钟)
PeerRatioRemoveData bool `json:"peer_ratio_remove_data" gorm:"default:false"` // 超标时删除种子及数据(否则仅暂停)
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 获取有效的间隔时间(带默认值和边界检查)
func (*SettingsGlobal) GetEffectivePeerRatioIntervalMin ¶ added in v0.23.0
func (s *SettingsGlobal) GetEffectivePeerRatioIntervalMin() int
func (*SettingsGlobal) GetEffectivePeerRatioMaxSL ¶ added in v0.23.0
func (s *SettingsGlobal) GetEffectivePeerRatioMaxSL() float64
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 SiteConfig struct {
Enabled *bool `json:"enabled"`
AuthMethod string `json:"auth_method"`
Cookie string `json:"cookie"`
APIKey string `json:"api_key"`
APIUrl string `json:"api_url"`
Passkey string `json:"passkey"`
UploadLimitKBs int `json:"upload_limit_kbs"`
DownloadLimitKBs int `json:"download_limit_kbs"`
RSS []RSSConfig `json:"rss"`
}
type SiteData ¶ added in v0.6.0
type SiteData struct {
Name string
DisplayName string
BaseURL string
Enabled bool
AuthMethod string
Cookie string
APIKey string
APIURL string
Passkey string
DownloaderID *uint
ParserConfig string
IsBuiltin bool
TemplateID *uint
}
SiteData 站点数据(用于创建/更新)
type SiteRateLimit ¶ added in v0.8.0
type SiteRateLimit struct {
SiteID string `gorm:"primaryKey;size:64" json:"site_id"`
WindowStart time.Time `gorm:"not null" json:"window_start"` // 当前窗口开始时间
RequestCount int `gorm:"default:0" json:"request_count"` // 当前窗口内请求数
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
SiteRateLimit 站点速率限制记录 每个站点一行,使用滑动窗口算法持久化请求计数
func (SiteRateLimit) TableName ¶ added in v0.8.0
func (SiteRateLimit) TableName() string
TableName 指定表名
type SiteRepository ¶ added in v0.6.0
type SiteRepository struct {
// contains filtered or unexported fields
}
SiteRepository 站点数据库操作封装
func NewSiteRepository ¶ added in v0.6.0
func NewSiteRepository(db *gorm.DB) *SiteRepository
func (*SiteRepository) BatchUpdateSiteDownloader ¶ added in v0.6.0
func (r *SiteRepository) BatchUpdateSiteDownloader(siteIDs []uint, downloaderID uint) (int64, error)
func (*SiteRepository) CreateSite ¶ added in v0.6.0
func (r *SiteRepository) CreateSite(data SiteData) (uint, error)
func (*SiteRepository) DeleteSite ¶ added in v0.6.0
func (r *SiteRepository) DeleteSite(name string) error
func (*SiteRepository) GetSiteByID ¶ added in v0.6.0
func (r *SiteRepository) GetSiteByID(id uint) (*SiteSetting, error)
func (*SiteRepository) GetSiteByName ¶ added in v0.6.0
func (r *SiteRepository) GetSiteByName(name string) (*SiteSetting, error)
func (*SiteRepository) ListEnabledSites ¶ added in v0.6.0
func (r *SiteRepository) ListEnabledSites() ([]SiteSetting, error)
func (*SiteRepository) ListSites ¶ added in v0.6.0
func (r *SiteRepository) ListSites() ([]SiteSetting, error)
func (*SiteRepository) SiteExistsByName ¶ added in v0.6.0
func (r *SiteRepository) SiteExistsByName(name string) (bool, error)
func (*SiteRepository) UpdateSiteCredentials ¶ added in v0.6.0
func (r *SiteRepository) UpdateSiteCredentials(name string, enabled *bool, authMethod, cookie, apiKey, apiURL, passkey string) error
func (*SiteRepository) UpdateSiteDownloader ¶ added in v0.6.0
func (r *SiteRepository) UpdateSiteDownloader(name string, downloaderID *uint) error
func (*SiteRepository) UpdateSiteDownloaderByID ¶ added in v0.6.0
func (r *SiteRepository) UpdateSiteDownloaderByID(siteID uint, downloaderID *uint) error
type SiteSetting ¶ added in v0.1.0
type SiteSetting 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 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"`
APIUrls string `gorm:"size:2048" json:"api_urls,omitempty"`
Passkey string `gorm:"size:512" json:"passkey,omitempty"`
DownloaderID *uint `gorm:"index" json:"downloader_id,omitempty"`
ParserConfig string `gorm:"type:text" json:"parser_config,omitempty"`
UploadLimitKBs int `gorm:"default:0" json:"upload_limit_kbs"`
DownloadLimitKBs int `gorm:"default:0" json:"download_limit_kbs"`
IsBuiltin bool `json:"is_builtin"`
TemplateID *uint `gorm:"index" json:"template_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SiteSetting 站点设置(统一表,合并原 DynamicSiteSetting)
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 插入或更新种子信息
func (*TorrentDB) WithTransaction ¶
WithTransaction 使用事务
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"`
HasHR bool `gorm:"default:false" json:"hasHR"`
HRSeedTimeH int `gorm:"default:0" json:"hrSeedTimeH"` // 下载器中的任务 ID(用于暂停/删除操作)
CheckCount int `gorm:"default:0" json:"checkCount"` // 进度检查次数
Seeders int `gorm:"default:0" json:"seeders"`
Leechers int `gorm:"default:0" json:"leechers"`
}
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"`
HasHR bool `json:"hasHR"`
HRSeedTimeH int `json:"hrSeedTimeH"`
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
// GetSizeBytes 获取种子大小(字节),用于过滤规则的大小匹配
GetSizeBytes() int64
}
TorrentMetadata 统一的种子元数据接口 用于获取种子的标题、副标题等信息,便于过滤规则匹配