Documentation
¶
Index ¶
- func FetchAndDownloadFreeRSS[T models.ResType](ctx context.Context, siteName models.SiteGroup, m PTSiteInter[T], ...) error
- func FetchAndDownloadFreeRSSUnified(ctx context.Context, m UnifiedPTSite, rssCfg models.RSSConfig) error
- func GetAllSupportedSiteGroups() []models.SiteGroup
- func GetDownloaderForRSS(rssCfg models.RSSConfig) (downloader.Downloader, error)
- func GetGlobalDownloaderManager() *downloader.DownloaderManager
- func IsSiteGroupSupported(siteGroup models.SiteGroup) bool
- func ProcessTorrentsWithDBUpdate(ctx context.Context, qbitClient *qbit.QbitClient, ...) error
- func ProcessTorrentsWithDownloaderByRSS(ctx context.Context, rssCfg models.RSSConfig, dirPath, category, tags string, ...) error
- func RegisterTorrentScheduler(f TorrentScheduleFunc)
- func ScheduleTorrentForMonitoring(torrent models.TorrentInfo)
- func SetGlobalDownloaderManager(dm *downloader.DownloaderManager)
- type DownloaderInfo
- type PTSiteInter
- type PushTorrentRequest
- type PushTorrentResult
- type TorrentDetailForTest
- type TorrentScheduleFunc
- type UnifiedPTSite
- type UnifiedSiteImpl
- func (u *UnifiedSiteImpl) Context() context.Context
- func (u *UnifiedSiteImpl) DownloadTorrent(url, title, downloadDir string) (string, error)
- func (u *UnifiedSiteImpl) GetTorrentDetails(item *gofeed.Item) (*v2.TorrentItem, error)
- func (u *UnifiedSiteImpl) IsEnabled() bool
- func (u *UnifiedSiteImpl) MaxRetries() int
- func (u *UnifiedSiteImpl) RetryDelay() time.Duration
- func (u *UnifiedSiteImpl) SendTorrentToDownloader(ctx context.Context, rssCfg models.RSSConfig) error
- func (u *UnifiedSiteImpl) SiteGroup() models.SiteGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchAndDownloadFreeRSS ¶
func FetchAndDownloadFreeRSS[T models.ResType](ctx context.Context, siteName models.SiteGroup, m PTSiteInter[T], rssCfg models.RSSConfig) error
FetchAndDownloadFreeRSS 旧的泛型版本(已废弃,请使用 FetchAndDownloadFreeRSSUnified) Deprecated: Use FetchAndDownloadFreeRSSUnified instead for new implementations
func FetchAndDownloadFreeRSSUnified ¶ added in v0.2.0
func FetchAndDownloadFreeRSSUnified(ctx context.Context, m UnifiedPTSite, rssCfg models.RSSConfig) error
FetchAndDownloadFreeRSSUnified 使用 UnifiedPTSite 接口获取并下载免费 RSS 种子
func GetAllSupportedSiteGroups ¶ added in v0.2.0
func GetDownloaderForRSS ¶ added in v0.2.0
func GetDownloaderForRSS(rssCfg models.RSSConfig) (downloader.Downloader, error)
GetDownloaderForRSS 根据 RSS 配置获取下载器 优先级:RSS 指定的下载器 > 默认下载器 返回下载器实例和下载器信息
func GetGlobalDownloaderManager ¶ added in v0.6.0
func GetGlobalDownloaderManager() *downloader.DownloaderManager
func IsSiteGroupSupported ¶ added in v0.2.0
func ProcessTorrentsWithDownloaderByRSS ¶ added in v0.2.0
func ProcessTorrentsWithDownloaderByRSS( ctx context.Context, rssCfg models.RSSConfig, dirPath, category, tags string, siteName models.SiteGroup, ) error
ProcessTorrentsWithDownloaderByRSS 根据 RSS 配置选择下载器并处理种子
func RegisterTorrentScheduler ¶ added in v0.3.0
func RegisterTorrentScheduler(f TorrentScheduleFunc)
func ScheduleTorrentForMonitoring ¶ added in v0.3.0
func ScheduleTorrentForMonitoring(torrent models.TorrentInfo)
func SetGlobalDownloaderManager ¶ added in v0.6.0
func SetGlobalDownloaderManager(dm *downloader.DownloaderManager)
Types ¶
type DownloaderInfo ¶ added in v0.3.0
GetDownloaderForRSS 根据 RSS 配置获取下载器 DownloaderInfo 下载器附加信息,用于记录推送来源
func GetDownloaderForRSSWithInfo ¶ added in v0.3.0
func GetDownloaderForRSSWithInfo(rssCfg models.RSSConfig) (downloader.Downloader, *DownloaderInfo, error)
GetDownloaderForRSSWithInfo 根据 RSS 配置获取下载器及其信息 优先使用全局 DownloaderManager(连接池复用),回退到直接创建实例
type PTSiteInter ¶
type PTSiteInter[T models.ResType] interface { GetTorrentDetails(item *gofeed.Item) (*models.APIResponse[T], error) IsEnabled() bool DownloadTorrent(url, title, downloadDir string) (string, error) MaxRetries() int RetryDelay() time.Duration SendTorrentToDownloader(ctx context.Context, rssCfg models.RSSConfig) error Context() context.Context }
PTSiteInter 旧的泛型接口(已废弃,请使用 UnifiedPTSite) Deprecated: Use UnifiedPTSite instead for new implementations
type PushTorrentRequest ¶ added in v0.2.0
type PushTorrentRequest struct {
SiteID string // 站点ID (如 hdsky, mteam)
TorrentID string // 种子ID
TorrentData []byte // 种子文件数据
Title string // 种子标题
Category string // 分类
Tags string // 标签
SavePath string // 保存路径(可选)
DownloaderID uint // 下载器ID
}
PushTorrentRequest 推送种子请求参数
type PushTorrentResult ¶ added in v0.2.0
type PushTorrentResult struct {
Success bool
Skipped bool // 是否跳过(如已存在)
TorrentHash string
Message string
}
PushTorrentResult 推送种子结果
func PushTorrentToDownloader ¶ added in v0.2.0
func PushTorrentToDownloader(ctx context.Context, req PushTorrentRequest) (*PushTorrentResult, error)
PushTorrentToDownloader 将种子推送到下载器 复用现有的下载和推送逻辑,同时记录到数据库
type TorrentDetailForTest ¶ added in v0.2.0
type TorrentDetailForTest struct {
Title string // 种子标题(优先使用中文名)
Tag string // 种子标签/副标题
IsFree bool // 是否免费
}
TorrentDetailForTest 用于测试的种子详情
func GetTorrentDetailForTest ¶ added in v0.2.0
func GetTorrentDetailForTest(ctx context.Context, siteName models.SiteGroup, item *gofeed.Item) (*TorrentDetailForTest, error)
GetTorrentDetailForTest 获取种子详情用于过滤规则测试 根据站点类型调用对应的 API 获取完整的种子信息
type TorrentScheduleFunc ¶ added in v0.3.0
type TorrentScheduleFunc func(torrent models.TorrentInfo)
type UnifiedPTSite ¶ added in v0.2.0
type UnifiedPTSite interface {
// GetTorrentDetails 获取种子详情,返回统一的 TorrentItem
GetTorrentDetails(item *gofeed.Item) (*v2.TorrentItem, error)
// IsEnabled 检查站点是否启用
IsEnabled() bool
// DownloadTorrent 下载种子文件,返回 torrent hash
DownloadTorrent(url, title, downloadDir string) (string, error)
// MaxRetries 返回最大重试次数
MaxRetries() int
// RetryDelay 返回重试间隔
RetryDelay() time.Duration
// SendTorrentToDownloader 发送种子到下载器
SendTorrentToDownloader(ctx context.Context, rssCfg models.RSSConfig) error
// Context 返回上下文
Context() context.Context
// SiteGroup 返回站点分组标识
SiteGroup() models.SiteGroup
}
UnifiedPTSite 统一的 PT 站点接口(非泛型) 新增站点应使用此接口,无需创建新的实现类
type UnifiedSiteImpl ¶ added in v0.2.0
type UnifiedSiteImpl struct {
// contains filtered or unexported fields
}
UnifiedSiteImpl 统一站点实现 使用 site/v2 的 Driver 模式,无需为每个站点创建单独的实现
func NewUnifiedSiteImpl ¶ added in v0.2.0
func (*UnifiedSiteImpl) Context ¶ added in v0.2.0
func (u *UnifiedSiteImpl) Context() context.Context
Context 返回上下文
func (*UnifiedSiteImpl) DownloadTorrent ¶ added in v0.2.0
func (u *UnifiedSiteImpl) DownloadTorrent(url, title, downloadDir string) (string, error)
DownloadTorrent 下载种子文件,返回 torrent hash
func (*UnifiedSiteImpl) GetTorrentDetails ¶ added in v0.2.0
func (u *UnifiedSiteImpl) GetTorrentDetails(item *gofeed.Item) (*v2.TorrentItem, error)
GetTorrentDetails 获取种子详情,返回统一的 TorrentItem
func (*UnifiedSiteImpl) IsEnabled ¶ added in v0.2.0
func (u *UnifiedSiteImpl) IsEnabled() bool
IsEnabled 检查站点是否启用
func (*UnifiedSiteImpl) MaxRetries ¶ added in v0.2.0
func (u *UnifiedSiteImpl) MaxRetries() int
MaxRetries 返回最大重试次数
func (*UnifiedSiteImpl) RetryDelay ¶ added in v0.2.0
func (u *UnifiedSiteImpl) RetryDelay() time.Duration
RetryDelay 返回重试间隔
func (*UnifiedSiteImpl) SendTorrentToDownloader ¶ added in v0.6.0
func (u *UnifiedSiteImpl) SendTorrentToDownloader(ctx context.Context, rssCfg models.RSSConfig) error
SendTorrentToDownloader 发送种子到下载器
func (*UnifiedSiteImpl) SiteGroup ¶ added in v0.2.0
func (u *UnifiedSiteImpl) SiteGroup() models.SiteGroup
SiteGroup 返回站点分组标识