validator

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod 认证方式

const (
	// AuthMethodCookie Cookie 认证
	AuthMethodCookie AuthMethod = "cookie"
	// AuthMethodAPIKey API Key 认证
	AuthMethodAPIKey AuthMethod = "apikey"
)

type DynamicSiteConfig

type DynamicSiteConfig interface {
	GetName() string
	GetBaseURL() string
	GetAuthMethod() AuthMethod
	GetCookie() string
	GetAPIKey() string
	GetAPIURL() string
}

DynamicSiteConfig 动态站点配置接口

type SiteBasicInfo

type SiteBasicInfo struct {
	Name        string     `json:"name"`
	DisplayName string     `json:"display_name"`
	BaseURL     string     `json:"base_url"`
	AuthMethod  AuthMethod `json:"auth_method"`
}

SiteBasicInfo 站点基本信息

type SiteValidator

type SiteValidator struct {
	// contains filtered or unexported fields
}

SiteValidator 站点验证器 用于验证新站点配置是否有效

func NewSiteValidator

func NewSiteValidator() *SiteValidator

func NewSiteValidatorWithOptions

func NewSiteValidatorWithOptions(opts ...ValidatorOption) *SiteValidator

func (*SiteValidator) Validate

Validate 验证站点配置

func (*SiteValidator) ValidateConfig

func (v *SiteValidator) ValidateConfig(config DynamicSiteConfig) []ValidationError

ValidateConfig 验证DynamicSiteConfig

type TorrentPreview

type TorrentPreview struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

TorrentPreview 种子预览信息

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ValidationError 验证错误

type ValidationRequest

type ValidationRequest struct {
	Name        string     `json:"name"`
	DisplayName string     `json:"display_name"`
	BaseURL     string     `json:"base_url"`
	AuthMethod  AuthMethod `json:"auth_method"`
	Cookie      string     `json:"cookie,omitempty"`
	APIKey      string     `json:"api_key,omitempty"`
	APIURL      string     `json:"api_url,omitempty"`
	RSSURL      string     `json:"rss_url,omitempty"` // 用于验证的RSS URL
}

type ValidationResult

type ValidationResult struct {
	Success       bool              `json:"success"`
	Message       string            `json:"message"`
	Errors        []ValidationError `json:"errors,omitempty"`
	FreeTorrents  []TorrentPreview  `json:"free_torrents,omitempty"`
	TotalTorrents int               `json:"total_torrents"`
	SiteInfo      *SiteBasicInfo    `json:"site_info,omitempty"`
	ResponseTime  time.Duration     `json:"response_time"`
}

ValidationResult 验证结果

type ValidatorOption

type ValidatorOption func(*SiteValidator)

func WithSession added in v0.13.0

func WithSession(session requests.Session) ValidatorOption

func WithTimeout

func WithTimeout(d time.Duration) ValidatorOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL