Documentation
¶
Index ¶
- Constants
- Variables
- func GetGroupSites(name string) []string
- func MatchSite(domain string, siteConfig *SiteConfigStruct) bool
- func ParseGroupAndOtherNames(names ...string) []string
- func ParseGroupAndOtherNamesWithoutDeduplicate(names ...string) []string
- func Set() error
- func UpdateSites(updatesites []*SiteConfigStruct)
- type ClientConfigStruct
- type ConfigStruct
- type CookiecloudConfigStruct
- type GroupConfigStruct
- type SiteConfigStruct
Constants ¶
View Source
const ( BRUSH_CAT = "_brush" XSEED_TAG = "_xseed" NOADD_TAG = "_noadd" NOXSEED_TAG = "noxseed" // BT 客户端里含有此 tag 的种子不会被辅种 STATS_FILENAME = "ptool_stats.txt" HISTORY_FILENAME = "ptool_history" DEFAULT_SHELL_MAX_SUGGESTIONS = int64(5) DEFAULT_SHELL_MAX_HISTORY = int64(500) DEFAULT_SITE_TIMEZONE = "Asia/Shanghai" DEFAULT_CLIENT_BRUSH_MIN_DISK_SPACE = int64(5 * 1024 * 1024 * 1024) DEFAULT_CLIENT_BRUSH_SLOW_UPLOAD_SPEED_TIER = int64(100 * 1024) DEFAULT_CLIENT_BRUSH_MAX_DOWNLOADING_TORRENTS = int64(6) DEFAULT_CLIENT_BRUSH_MAX_TORRENTS = int64(9999) DEFAULT_CLIENT_BRUSH_MIN_RATION = float64(0.2) DEFAULT_CLIENT_BRUSH_DEFAULT_UPLOAD_SPEED_LIMIT = int64(10 * 1024 * 1024) DEFAULT_SITE_BRUSH_TORRENT_MIN_SIZE_LIMIT = int64(0) DEFAULT_SITE_BRUSH_TORRENT_MAX_SIZE_LIMIT = int64(1024 * 1024 * 1024 * 1024 * 1024) // 1PB, that's say, unlimited DEFAULT_SITE_TORRENT_UPLOAD_SPEED_LIMIT = int64(10 * 1024 * 1024) DEFAULT_SITE_FLOW_CONTROL_INTERVAL = int64(3) )
Variables ¶
View Source
var ( VerboseLevel = 0 InShell = false Initialized = false ConfigDir = "" // "/root/.config/ptool" ConfigFile = "" // "ptool.toml" ConfigName = "" // "ptool" ConfigType = "" // "toml" LockFile = "" LockOrExit = false Fork = false )
Functions ¶
func GetGroupSites ¶
if name is a group, return it's sites, otherwise return nil
func MatchSite ¶ added in v0.1.1
func MatchSite(domain string, siteConfig *SiteConfigStruct) bool
func ParseGroupAndOtherNames ¶
parse an slice of groupOrOther names, expand group name to site names, return the final slice of names
func Set ¶ added in v0.1.8
func Set() error
Re-write the whole config file using memory data. Currently, only sites will be overrided. Due to technical limitations, all existing comments will be LOST. For now, new config data will NOT take effect for current ptool process.
func UpdateSites ¶ added in v0.1.8
func UpdateSites(updatesites []*SiteConfigStruct)
Update configed sites in place, merge the provided (updated) sites with existing config.
Types ¶
type ClientConfigStruct ¶
type ClientConfigStruct struct { Type string `yaml:"type"` Name string `yaml:"name"` Comment string `yaml:"comment"` Disabled bool `yaml:"disabled"` Url string `yaml:"url"` Username string `yaml:"username"` Password string `yaml:"password"` BrushMinDiskSpace string `yaml:"brushMinDiskSpace"` BrushSlowUploadSpeedTier string `yaml:"brushSlowUploadSpeedTier"` BrushMaxDownloadingTorrents int64 `yaml:"brushMaxDownloadingTorrents"` BrushMaxTorrents int64 `yaml:"brushMaxTorrents"` BrushMinRatio float64 `yaml:"brushMinRatio"` BrushDefaultUploadSpeedLimit string `yaml:"brushDefaultUploadSpeedLimit"` BrushMinDiskSpaceValue int64 BrushSlowUploadSpeedTierValue int64 BrushDefaultUploadSpeedLimitValue int64 QbittorrentNoLogin bool `yaml:"qbittorrentNoLogin"` // if set, will NOT send login request QbittorrentNoLogout bool `yaml:"qbittorrentNoLogout"` // if set, will NOT send logout request }
func GetClientConfig ¶
func GetClientConfig(name string) *ClientConfigStruct
type ConfigStruct ¶
type ConfigStruct struct { Hushshell bool `yaml:"hushshell"` ShellMaxSuggestions int64 `yaml:"shellMaxSuggestions"` ShellMaxHistory int64 `yaml:"shellMaxHistory"` IyuuToken string `yaml:"iyuuToken"` SiteProxy string `yaml:"siteProxy"` SiteUserAgent string `yaml:"siteUserAgent"` SiteNoDefaultHttpHeaders bool `yaml:"siteNoDefaultHttpHeaders"` SiteHttpHeaders *map[string]string `yaml:"siteHttpHeaders"` SiteJa3 string `yaml:"siteJa3"` BrushEnableStats bool `yaml:"brushEnableStats"` Clients []*ClientConfigStruct `yaml:"clients"` Sites []*SiteConfigStruct `yaml:"sites"` Groups []*GroupConfigStruct `yaml:"groups"` Cookieclouds []*CookiecloudConfigStruct `yaml:"cookieclouds"` Comment string `yaml:"comment"` ClientsEnabled []*ClientConfigStruct SitesEnabled []*SiteConfigStruct }
func Get ¶
func Get() *ConfigStruct
func (*ConfigStruct) UpdateSitesDerivative ¶ added in v0.1.8
func (configData *ConfigStruct) UpdateSitesDerivative()
type CookiecloudConfigStruct ¶ added in v0.1.8
type CookiecloudConfigStruct struct { Name string `yaml:"name"` Disabled bool `yaml:"disabled"` Server string `yaml:"server"` // CookieCloud API Server Url (with API_ROOT, if exists) Uuid string `yaml:"uuid"` Password string `yaml:"password"` Proxy string `yaml:"proxy"` Sites []string `yaml:"sites"` Comment string `yaml:"comment"` }
func GetCookiecloudConfig ¶ added in v0.1.8
func GetCookiecloudConfig(name string) *CookiecloudConfigStruct
type GroupConfigStruct ¶
type GroupConfigStruct struct { Name string `yaml:"name"` Sites []string `yaml:"sites"` Comment string `yaml:"comment"` }
func GetGroupConfig ¶ added in v0.1.6
func GetGroupConfig(name string) *GroupConfigStruct
type SiteConfigStruct ¶
type SiteConfigStruct struct { Type string `yaml:"type"` Name string `yaml:"name"` Aliases []string // for internal use only Comment string `yaml:"comment"` Disabled bool `yaml:"disabled"` Hidden bool `yaml:"hidden"` // exclude from default groups (like "_all") Url string `yaml:"url"` Domains []string `yaml:"domains"` // other site domains (do not include subdomain part) TorrentsUrl string `yaml:"torrentsUrl"` SearchUrl string `yaml:"searchUrl"` TorrentsExtraUrls []string `yaml:"torrentsExtraUrls"` Cookie string `yaml:"cookie"` UserAgent string `yaml:"userAgent"` HttpHeaders *map[string]string `yaml:"httpHeaders"` NoDefaultHttpHeaders bool `yaml:"noDefaultHttpHeaders"` Ja3 string `yaml:"ja3"` Ja3ForceAttemptHTTP2 bool `yaml:"ja3ForceAttemptHTTP2"` Proxy string `yaml:"proxy"` Insecure bool `yaml:"insecure"` // 访问站点时跳过TLS证书安全校验 TorrentUploadSpeedLimit string `yaml:"torrentUploadSpeedLimit"` GlobalHnR bool `yaml:"globalHnR"` Timezone string `yaml:"timezone"` BrushTorrentMinSizeLimit string `yaml:"brushTorrentMinSizeLimit"` BrushTorrentMaxSizeLimit string `yaml:"brushTorrentMaxSizeLimit"` BrushAllowNoneFree bool `yaml:"brushAllowNoneFree"` BrushAllowPaid bool `yaml:"brushAllowPaid"` BrushAllowHr bool `yaml:"brushAllowHr"` BrushAllowZeroSeeders bool `yaml:"brushAllowZeroSeeders"` BrushExcludes []string `yaml:"brushExcludes"` SelectorTorrentsListHeader string `yaml:"selectorTorrentsListHeader"` SelectorTorrentsList string `yaml:"selectorTorrentsList"` SelectorTorrentBlock string `yaml:"selectorTorrentBlock"` // dom block of a torrent in list SelectorTorrent string `yaml:"selectorTorrent"` SelectorTorrentDownloadLink string `yaml:"selectorTorrentDownloadLink"` SelectorTorrentDetailsLink string `yaml:"selectorTorrentDetailsLink"` SelectorTorrentTime string `yaml:"selectorTorrentTime"` SelectorTorrentSeeders string `yaml:"selectorTorrentSeeders"` SelectorTorrentLeechers string `yaml:"selectorTorrentLeechers"` SelectorTorrentSnatched string `yaml:"selectorTorrentSnatched"` SelectorTorrentSize string `yaml:"selectorTorrentSize"` SelectorTorrentProcessBar string `yaml:"selectorTorrentProcessBar"` SelectorTorrentFree string `yaml:"SelectorTorrentFree"` SelectorTorrentNoTraffic string `yaml:"selectorTorrentNoTraffic"` SelectorTorrentNeutral string `yaml:"selectorTorrentNeutral"` SelectorTorrentHnR string `yaml:"selectorTorrentHnR"` SelectorTorrentPaid string `yaml:"selectorTorrentPaid"` SelectorTorrentDiscountEndTime string `yaml:"selectorTorrentDiscountEndTime"` SelectorUserInfo string `yaml:"selectorUserInfo"` SelectorUserInfoUserName string `yaml:"selectorUserInfoUserName"` SelectorUserInfoUploaded string `yaml:"selectorUserInfoUploaded"` SelectorUserInfoDownloaded string `yaml:"selectorUserInfoDownloaded"` TorrentDownloadUrl string `yaml:"torrentDownloadUrl"` // use {id} placeholders in url TorrentDownloadUrlPrefix string `yaml:"torrentDownloadUrlPrefix"` Passkey string `yaml:"passkey"` UseCuhash bool `yaml:"useCuhash"` // hdcity 使用机制。种子下载地址里必须有cuhash参数 UseDigitHash bool `yaml:"useDigitHash"` // ttg 使用机制。种子下载地址末段必须有4位数字校验码或Passkey参数(即使有 Cookie) TorrentUrlIdRegexp string `yaml:"torrentUrlIdRegexp"` FlowControlInterval int64 `yaml:"flowControlInterval"` // 暂定名。两次请求种子列表页间隔时间(秒) NexusphpNoLetDown bool `yaml:"nexusphpNoLetDown"` TorrentUploadSpeedLimitValue int64 BrushTorrentMinSizeLimitValue int64 BrushTorrentMaxSizeLimitValue int64 AutoComment string // 自动更新 ptool.toml 时系统生成的 comment。会被写入 Comment 字段 }
func GetSiteConfig ¶ added in v0.1.1
func GetSiteConfig(name string) *SiteConfigStruct
func (*SiteConfigStruct) GetName ¶
func (siteConfig *SiteConfigStruct) GetName() string
func (*SiteConfigStruct) GetTimezone ¶ added in v0.1.8
func (siteConfig *SiteConfigStruct) GetTimezone() string
func (*SiteConfigStruct) ParseSiteUrl ¶
func (siteConfig *SiteConfigStruct) ParseSiteUrl(siteUrl string, appendQueryStringDelimiter bool) string
parse a site internal url (eg. special.php), return absolute url
func (*SiteConfigStruct) Register ¶ added in v0.1.8
func (siteConfig *SiteConfigStruct) Register()
Generate derivative info from site config and register itself
Click to show internal directories.
Click to hide internal directories.