Documentation
¶
Overview ¶
Package internal provides site compatibility types and functions These were moved from the deprecated site package to support existing functionality
Index ¶
- func CommonFetchTorrentInfo(ctx context.Context, c *colly.Collector, cfg *SiteMapConfig, url string) (*models.PHPTorrentInfo, error)
- 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 NewCollectorWithTransport() *colly.Collector
- 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 DefaultReferer
- type DownloaderInfo
- type LegacyParserAdapter
- func (a *LegacyParserAdapter) ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)
- func (a *LegacyParserAdapter) ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)
- func (a *LegacyParserAdapter) ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)
- func (a *LegacyParserAdapter) ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)
- type PTSiteInter
- type PushTorrentRequest
- type PushTorrentResult
- type RefererProvider
- type SharedSiteConfig
- type SiteConfig
- type SiteMapConfig
- type SiteParser
- 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 CommonFetchTorrentInfo ¶ added in v0.2.0
func CommonFetchTorrentInfo(ctx context.Context, c *colly.Collector, cfg *SiteMapConfig, url string) (*models.PHPTorrentInfo, error)
CommonFetchTorrentInfo fetches torrent info from a URL
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.9.1
func GetGlobalDownloaderManager() *downloader.DownloaderManager
func IsSiteGroupSupported ¶ added in v0.2.0
func NewCollectorWithTransport ¶ added in v0.2.0
NewCollectorWithTransport creates a new colly collector with custom transport
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.9.1
func SetGlobalDownloaderManager(dm *downloader.DownloaderManager)
Types ¶
type DefaultReferer ¶ added in v0.2.0
type DefaultReferer struct {
// contains filtered or unexported fields
}
DefaultReferer implements RefererProvider
func NewDefaultReferer ¶ added in v0.2.0
func NewDefaultReferer(name models.SiteGroup) *DefaultReferer
NewDefaultReferer creates a new DefaultReferer based on site group
func (*DefaultReferer) GetReferer ¶ added in v0.2.0
func (d *DefaultReferer) GetReferer() string
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 LegacyParserAdapter ¶ added in v0.2.0
type LegacyParserAdapter struct {
// contains filtered or unexported fields
}
LegacyParserAdapter adapts v2.NexusPHPDetailParser to the legacy SiteParser interface This allows using the new v2 parsers with the existing colly-based fetching code
func NewLegacyParserAdapter ¶ added in v0.2.0
func NewLegacyParserAdapter(parser v2.NexusPHPDetailParser) *LegacyParserAdapter
NewLegacyParserAdapter creates a new adapter for a v2 parser
func (*LegacyParserAdapter) ParseDiscount ¶ added in v0.2.0
func (a *LegacyParserAdapter) ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)
func (*LegacyParserAdapter) ParseHR ¶ added in v0.2.0
func (a *LegacyParserAdapter) ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)
func (*LegacyParserAdapter) ParseTitleAndID ¶ added in v0.2.0
func (a *LegacyParserAdapter) ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)
func (*LegacyParserAdapter) ParseTorrentSizeMB ¶ added in v0.2.0
func (a *LegacyParserAdapter) ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)
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 RefererProvider ¶ added in v0.2.0
type RefererProvider interface {
GetReferer() string
}
RefererProvider provides referer URL for requests
type SharedSiteConfig ¶ added in v0.2.0
type SharedSiteConfig struct {
}
SharedSiteConfig holds shared configuration across sites
type SiteConfig ¶ added in v0.2.0
type SiteConfig struct {
RefererConf RefererProvider
}
SiteConfig holds site-specific configuration
type SiteMapConfig ¶ added in v0.2.0
type SiteMapConfig struct {
Name string
Config models.SiteConfig
Parser SiteParser
CustomHeaders map[string]string
}
SiteMapConfig holds complete site configuration
func NewSiteMapConfig ¶ added in v0.2.0
func NewSiteMapConfig(name models.SiteGroup, cookie string, conf models.SiteConfig, parser SiteParser) *SiteMapConfig
NewSiteMapConfig creates a new SiteMapConfig
type SiteParser ¶ added in v0.2.0
type SiteParser interface {
ParseTitleAndID(e *colly.HTMLElement, info *models.PHPTorrentInfo)
ParseDiscount(e *colly.HTMLElement, info *models.PHPTorrentInfo)
ParseHR(e *colly.HTMLElement, info *models.PHPTorrentInfo)
ParseTorrentSizeMB(e *colly.HTMLElement, info *models.PHPTorrentInfo)
}
SiteParser interface for parsing torrent pages
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.9.1
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 返回站点分组标识