iyuu

package
v1.0.0-rc.21 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 13 Imported by: 0

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。

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

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
}

RateLimitError 是 IYUU 返回的 429:RetryAfter 之后再试。

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