Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDefaultConfig() (err error)
- 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 AliasConfigStruct
- type ClientConfigStruct
- type ConfigStruct
- type CookiecloudConfigStruct
- type GroupConfigStruct
- type SiteConfigStruct
- func (siteConfig *SiteConfigStruct) GetName() string
- func (siteConfig *SiteConfigStruct) GetTimezone() string
- func (siteConfig *SiteConfigStruct) MatchFilter(filter string) bool
- func (siteConfig *SiteConfigStruct) ParseSiteUrl(siteUrl string, appendQueryStringDelimiter bool) string
- func (siteConfig *SiteConfigStruct) Register()
Constants ¶
View Source
const ( NONE = "none" // 如果字符串类型配置项值为空,使用系统默认值。使用 NONE 值显式设置该配置项为空值 BRUSH_CAT = "_brush" XSEED_TAG = "_xseed" NOADD_TAG = "_noadd" NOXSEED_TAG = "noxseed" // BT 客户端里含有此 tag 的种子不会被辅种 STATS_FILENAME = "ptool_stats.txt" HISTORY_FILENAME = "ptool_history" SITE_TORRENTS_WIDTH = 120 // min width for printing site torrents CLIENT_TORRENTS_WIDTH = 120 // min width for printing client torrents GLOBAL_INTERNAL_LOCK_FILE = "ptool.lock" GLOBAL_LOCK_FILE = "ptool-global.lock" DEFAULT_IYUU_DOMAIN = "api.iyuu.cn" DEFAULT_TIMEOUT = int64(5) 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_TIMEOUT = DEFAULT_TIMEOUT DEFAULT_SITE_BRUSH_TORRENT_MIN_SIZE_LIMIT = int64(0) DEFAULT_SITE_BRUSH_TORRENT_MAX_SIZE_LIMIT = int64(1024 * 1024 * 1024 * 1024 * 1024) //1PB=effectively no limit DEFAULT_SITE_TORRENT_UPLOAD_SPEED_LIMIT = int64(10 * 1024 * 1024) DEFAULT_SITE_FLOW_CONTROL_INTERVAL = int64(3) DEFAULT_SITE_MAX_REDIRECTS = int64(3) DEFAULT_COOKIECLOUD_TIMEOUT = DEFAULT_TIMEOUT )
Variables ¶
View Source
var ( VerboseLevel = 0 InShell = false Initialized = false ConfigDir = "" // "/root/.config/ptool" ConfigFile = "" // "ptool.toml" DefaultConfigFile = "" // set when start ConfigName = "" // "ptool" ConfigType = "" // "toml" LockFile = "" GlobalLock = false LockOrExit = false Fork = false )
View Source
var InternalAliases = []*AliasConfigStruct{ { Name: "add2", Cmd: "add --add-category-auto --sequential-download", DefaultArgs: "*.torrent", MinArgs: 1, Internal: true, }, { Name: "batchdl2", Cmd: "batchdl --action=add --add-category-auto --add-client", MinArgs: 1, Internal: true, }, { Name: "parsetorrent2", Cmd: "parsetorrent *.torrent", Internal: true, }, }
Functions ¶
func CreateDefaultConfig ¶ added in v0.1.9
func CreateDefaultConfig() (err error)
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 AliasConfigStruct ¶ added in v0.1.9
type AliasConfigStruct struct { Name string `yaml:"name"` Cmd string `yaml:"cmd"` DefaultArgs string `yaml:"defaultArgs"` MinArgs int64 `yaml:"minArgs"` Internal bool }
func GetAliasConfig ¶ added in v0.1.9
func GetAliasConfig(name string) *AliasConfigStruct
func (*AliasConfigStruct) MatchFilter ¶ added in v0.1.9
func (aliasConfig *AliasConfigStruct) MatchFilter(filter string) bool
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
func (*ClientConfigStruct) MatchFilter ¶ added in v0.1.9
func (clientConfig *ClientConfigStruct) MatchFilter(filter string) bool
type ConfigStruct ¶
type ConfigStruct struct { Hushshell bool `yaml:"hushshell"` ShellMaxSuggestions int64 `yaml:"shellMaxSuggestions"` // -1 禁用 ShellMaxHistory int64 `yaml:"shellMaxHistory"` // -1 禁用 IyuuToken string `yaml:"iyuuToken"` IyuuDomain string `yaml:"iyuuDomain"` // iyuu API 域名。默认使用 api.iyuu.cn SiteProxy string `yaml:"siteProxy"` SiteUserAgent string `yaml:"siteUserAgent"` SiteImpersonate string `yaml:"siteImpersonate"` SiteHttpHeaders [][]string `yaml:"siteHttpHeaders"` SiteJa3 string `yaml:"siteJa3"` SiteTimeout int64 `yaml:"siteTimeout"` // 访问网站超时时间(秒) SiteInsecure bool `yaml:"siteInsecure"` // 强制禁用所有站点 TLS 证书校验。 SiteH2Fingerprint string `yaml:"siteH2Fingerprint"` BrushEnableStats bool `yaml:"brushEnableStats"` Clients []*ClientConfigStruct `yaml:"clients"` Sites []*SiteConfigStruct `yaml:"sites"` Groups []*GroupConfigStruct `yaml:"groups"` Aliases []*AliasConfigStruct `yaml:"aliases"` Cookieclouds []*CookiecloudConfigStruct `yaml:"cookieclouds"` Comment string `yaml:"comment"` ClientsEnabled []*ClientConfigStruct SitesEnabled []*SiteConfigStruct }
func Get ¶
func Get() *ConfigStruct
func (*ConfigStruct) GetIyuuDomain ¶ added in v0.1.9
func (configData *ConfigStruct) GetIyuuDomain() string
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"` Timeoout int64 `yaml:"timeout"` Comment string `yaml:"comment"` }
func GetCookiecloudConfig ¶ added in v0.1.8
func GetCookiecloudConfig(name string) *CookiecloudConfigStruct
func (*CookiecloudConfigStruct) MatchFilter ¶ added in v0.1.9
func (cookieCloudConfig *CookiecloudConfigStruct) MatchFilter(filter string) bool
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
func (*GroupConfigStruct) MatchFilter ¶ added in v0.1.9
func (groupConfig *GroupConfigStruct) MatchFilter(filter string) bool
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"` SearchQueryVariable string `yaml:"searchQueryVariable"` TorrentsExtraUrls []string `yaml:"torrentsExtraUrls"` Cookie string `yaml:"cookie"` UserAgent string `yaml:"userAgent"` Impersonate string `yaml:"impersonate"` HttpHeaders [][]string `yaml:"httpHeaders"` Ja3 string `yaml:"ja3"` Timeoout int64 `yaml:"timeout"` H2Fingerprint string `yaml:"h2Fingerprint"` Proxy string `yaml:"proxy"` Insecure bool `yaml:"insecure"` // 访问站点时强制跳过TLS证书安全校验 Secure bool `yaml:"secure"` // 访问站点时强制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参数 // ttg 使用机制。种子下载地址末段必须有4位数字校验码或Passkey参数(即使有 Cookie) UseDigitHash bool `yaml:"useDigitHash"` TorrentUrlIdRegexp string `yaml:"torrentUrlIdRegexp"` FlowControlInterval int64 `yaml:"flowControlInterval"` // 暂定名。两次请求种子列表页间隔时间(秒) NexusphpNoLetDown bool `yaml:"nexusphpNoLetDown"` MaxRedirects int64 `yaml:"maxRedirects"` 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) MatchFilter ¶ added in v0.1.9
func (siteConfig *SiteConfigStruct) MatchFilter(filter string) bool
func (*SiteConfigStruct) ParseSiteUrl ¶
func (siteConfig *SiteConfigStruct) ParseSiteUrl(siteUrl string, appendQueryStringDelimiter bool) string
Parse a site internal url (e.g.: 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.