iyuu

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: 13 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

Overview

Package iyuu 是 IYUU 辅种接口的客户端。

接口按 MIT 许可的 iyuuplus-dev 客户端(composer/reseed-client)核对:请求头 token,响应信封 {code, msg, data}, code 为 0 成功、429 限流(data 里有 Retry-After),其余为错误。只参考接口行为,不移植代码。

Index

Constants

View Source
const (
	// DefaultBaseURL 是 IYUU 的接口地址(token 在请求头里,只用 https)。
	DefaultBaseURL = "https://2025.iyuu.cn"
	// Version 是查询时报给 IYUU 的客户端版本,与现行 iyuuplus-dev 一致。
	Version = "8.3.24"
	// MaxBatch 是一次查询最多的 info hash 数。
	MaxBatch = 200
)

Variables

View Source
var ErrNoToken = errors.New("没有设置 IYUU token")

ErrNoToken 表示没有配置 IYUU token。

View Source
var ErrTokenNotBound = errors.New("IYUU token 还没有绑定合作站点")

ErrTokenNotBound 表示 IYUU token 还没有绑定合作站点(#740):IYUU 回 401「token未注册,请先绑定推荐站点」。 这时站点列表照常能读,报告站点与查询都被拒绝;token 在哪个客户端里绑定过一次都算。

Functions

func HashParam

func HashParam(hashes []string) (string, string)

HashParam 是查询用的 hash 参数:排序后的 info hash 数组的 JSON(与 PHP json_encode 一致,无空格)及其 SHA-1。

Types

type APIError

type APIError struct {
	Code int
	Msg  string
}

APIError 是 IYUU 返回的非 0 code(限流除外)。

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap 让 errors.Is(err, ErrTokenNotBound) 认出要求先绑定合作站点的 401。

type Candidate

type Candidate struct {
	SID       int    `json:"sid"`
	TorrentID string `json:"torrent_id"`
	InfoHash  string `json:"info_hash"`
}

Candidate 是一个可以辅种的种子:哪个站点(sid)、站内种子 ID、info hash。

func (*Candidate) UnmarshalJSON

func (c *Candidate) UnmarshalJSON(b []byte) error

UnmarshalJSON 兼容 torrent_id 是数字或字符串两种写法。

type Client

type Client struct {
	BaseURL string
	Token   string
	HTTP    *http.Client
	Now     func() time.Time
}

Client 调用 IYUU 接口。

func New

func New(token string) *Client

New 返回一个用默认地址的客户端。

func (*Client) Query

func (c *Client) Query(ctx context.Context, hashes []string, sidSha1 string) (map[string][]Candidate, error)

Query 查询一批(最多 MaxBatch 个)info hash 的辅种结果:源 info hash → 可辅种的种子。

func (*Client) ReportExisting

func (c *Client) ReportExisting(ctx context.Context, sids []int) (string, error)

ReportExisting 报告用户开启辅种的站点(sid 列表),返回查询时要带的 sid_sha1(有效 7 天)。

func (*Client) Sites

func (c *Client) Sites(ctx context.Context) ([]Site, error)

Sites 返回 IYUU 支持的站点。

type RateLimitError

type RateLimitError struct {
	Msg        string
	RetryAfter time.Duration
	ResetAt    time.Time
	Limit      int
}

RateLimitError 是 IYUU 返回的 429:RetryAfter 之后再试。ResetAt 是限额重置的时刻(429 数据里的 X-RateLimit-Reset, Unix 秒),Limit 是 X-RateLimit-Limit;没给时为零值(与 iyuuplus-dev 的 TooManyRequestsException 读的是同几个字段)。

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type Site

type Site struct {
	SID          int    `json:"id"`
	Site         string `json:"site"`
	Nickname     string `json:"nickname"`
	BaseURL      string `json:"base_url"`
	DownloadPage string `json:"download_page"`
	IsHTTPS      int    `json:"is_https"`
}

Site 是 IYUU 支持的一个站点。

Jump to

Keyboard shortcuts

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