Documentation
¶
Index ¶
- Constants
- Variables
- func SeedDefaultSites(db *gorm.DB) error
- type APIResponse
- type AdminUser
- type Config
- type DiscountType
- type FreeDownChecker
- type MTTorrentDetail
- type PHPTorrentInfo
- type PromotionRule
- type QbitSettings
- type RSSConfig
- type RSSPreset
- type RSSSubscription
- type ResType
- type SettingsGlobal
- type Showcase
- type SiteConfig
- type SiteGroup
- type SitePreset
- type SiteSetting
- 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
Constants ¶
View Source
const ( DBFile = "torrents.db" WorkDir = ".pt-tools" )
View Source
const (
DefaultAPIUrlMTeam = "https://api.m-team.cc/api"
)
View Source
const MinIntervalMinutes int32 = 5
Variables ¶
View Source
var DefaultSitePresets = []SitePreset{ { Name: string(CMCT), AuthMethod: "cookie", Enabled: false, APIUrl: "", RSS: []RSSPreset{{ Name: "CMCT", URL: "https://springxxx.xxx", Category: "Tv", Tag: "CMCT", IntervalMinutes: 5, DownloadSubPath: "cmct/", }}, }, { Name: string(HDSKY), AuthMethod: "cookie", Enabled: false, APIUrl: "", RSS: []RSSPreset{{ Name: "HDSky", URL: "https://hdsky.xxx/torrentrss.php?xxx", Category: "Mv", Tag: "HDSKY", IntervalMinutes: 5, DownloadSubPath: "hdsky/", }}, }, { Name: string(MTEAM), AuthMethod: "api_key", Enabled: false, APIUrl: DefaultAPIUrlMTeam, RSS: []RSSPreset{{ Name: "TMP2", URL: "https://rss.m-team.xxx/api/rss/xxx", Category: "Tv", Tag: "MT", IntervalMinutes: 10, DownloadSubPath: "mteam/tvs", }}, }, }
Functions ¶
func SeedDefaultSites ¶ added in v0.1.0
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 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 interface{} `json:"author"`
Category string `json:"category"`
Source string `json:"source"`
Medium interface{} `json:"medium"`
Standard string `json:"standard"`
VideoCodec string `json:"videoCodec"`
AudioCodec string `json:"audioCodec"`
Team string `json:"team"`
Processing interface{} `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 interface{} `json:"infoHash"`
Status *Status `json:"status"`
EditedBy interface{} `json:"editedBy"`
EditDate interface{} `json:"editDate"`
Collection bool `json:"collection"`
InRss bool `json:"inRss"`
CanVote bool `json:"canVote"`
ImageList interface{} `json:"imageList"`
ResetBox interface{} `json:"resetBox"`
OriginFileName string `json:"originFileName"`
Descr string `json:"descr"`
Nfo interface{} `json:"nfo"`
MediaInfo string `json:"mediainfo"`
CIDs interface{} `json:"cids"`
AIDs interface{} `json:"aids"`
ShowcaseList []Showcase `json:"showcaseList"`
TagList []interface{} `json:"tagList"`
Scope string `json:"scope"`
ScopeTeams []interface{} `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) IsFree ¶
func (t MTTorrentDetail) IsFree() bool
type PHPTorrentInfo ¶
type PHPTorrentInfo struct {
Title 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) IsFree ¶
func (p PHPTorrentInfo) IsFree() bool
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"`
DownloadSubPath string `json:"download_sub_path"`
}
Runtime-friendly structures for API usage and scheduler/config load
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"`
DownloadSubPath string `gorm:"size:256" json:"download_sub_path"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
RSS 订阅
type ResType ¶
type ResType interface {
MTTorrentDetail | PHPTorrentInfo
FreeDownChecker
}
type SettingsGlobal ¶ added in v0.1.0
type SettingsGlobal struct {
ID uint `gorm:"primaryKey" json:"id"`
DefaultIntervalMinutes int32 `json:"default_interval_minutes"`
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"`
}
全局设置
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 SitePreset ¶ added in v0.1.0
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 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 interface{} `json:"mallSingleFree"`
}
type TorrentDB ¶
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"`
}
TorrentInfo 表示种子信息
func (*TorrentInfo) GetExpired ¶ added in v0.0.10
func (t *TorrentInfo) GetExpired() bool
Click to show internal directories.
Click to hide internal directories.