dlassistant

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 14 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 dlassistant 是下载器助手:给缺站点标签的种子补标签、批量替换 tracker 地址、找出 tracker 报告 未注册或不存在的失效种子。每项都分「预览」与「执行」两步,执行前重新核对,预览之后种子变了就跳过。

tracker 地址里带 passkey,返回给界面的一律脱敏(见 RedactTrackerURL);替换时用的是下载器里的原地址。

Index

Constants

View Source
const MaxScanTorrents = 20000

MaxScanTorrents 是一次扫描或预览最多检查的种子数:种子更多时只检查前这么多个,结果里写明。

Variables

This section is empty.

Functions

func FindMissingSiteTags

func FindMissingSiteTags(ctx context.Context, dl downloader.Downloader, r *v2.TrackerResolver) ([]SiteTagSuggestion, ScanInfo, error)

FindMissingSiteTags 列出按 tracker 能认出站点、但分类和标签里都没有这个站点的种子。

func PreviewTrackerReplace

func PreviewTrackerReplace(ctx context.Context, dl downloader.Downloader, from, to string) ([]TrackerMatch, ScanInfo, error)

PreviewTrackerReplace 列出 tracker 地址里含 from 的种子和替换后的地址(读每个种子完整的 tracker 列表)。

func RedactTrackerMessage

func RedactTrackerMessage(msg string) string

RedactTrackerMessage 遮住 tracker 回复里可能带的凭证:里面的地址按 RedactTrackerURL 处理, 再遮 passkey=… 一类参数和 24 位以上的长串。

func RedactTrackerURL

func RedactTrackerURL(raw string) string

RedactTrackerURL 把 tracker 地址里的 passkey 之类遮掉:敏感查询参数与路径里像密钥的长段。

func ReplaceTrackerURL

func ReplaceTrackerURL(raw, from, to string) (string, error)

ReplaceTrackerURL 把地址里第一处 from 换成 to;结果不是 http(s) 或 udp 地址时返回错误。

func ScanDeadTorrents

func ScanDeadTorrents(ctx context.Context, dl downloader.Downloader, r *v2.TrackerResolver) ([]DeadTorrent, ScanInfo, error)

ScanDeadTorrents 逐个读取种子的 tracker 状态,列出失效种子。

func ValidateTrackerReplace

func ValidateTrackerReplace(from, to string) error

ValidateTrackerReplace 校验替换参数:原内容至少 3 个字,替换后要仍是 http(s) 或 udp 地址(在 ReplaceTrackerURL 里逐个核对)。

Types

type ApplyResult

type ApplyResult struct {
	Done    int         `json:"done"`
	Skipped []ItemError `json:"skipped"`
	Failed  []ItemError `json:"failed"`
	// KeptData 是删除时要求删数据、但数据还被别的种子用着(如辅种),所以只删了种子的个数(算在 Done 里)。
	KeptData int `json:"kept_data,omitempty"`
}

ApplyResult 是一次执行的结果。

func ApplySiteTags

func ApplySiteTags(ctx context.Context, dl downloader.Downloader, r *v2.TrackerResolver, items []SiteTagItem) (ApplyResult, error)

ApplySiteTags 给种子加上站点标签。执行前重新核对:种子还在、tracker 仍属于这个站点、还没有这个标签。 传给下载器的是原有标签加上站点名(qBittorrent 的 addTags 只会新增,Transmission 的 labels 是整份替换)。

func ApplyTrackerReplace

func ApplyTrackerReplace(ctx context.Context, dl downloader.Downloader, from, to string, selected []TrackerSelection) (ApplyResult, error)

ApplyTrackerReplace 只改预览时选中的那几条地址:逐个种子重新读 tracker 列表,地址与替换结果的指纹 仍和预览时一致才改;对不上的(预览之后地址变了)跳过。同一种子改到一半失败时写明已经改了几条。

func DeleteDeadTorrents

func DeleteDeadTorrents(ctx context.Context, dl downloader.Downloader, hashes []string, removeData bool) (ApplyResult, error)

DeleteDeadTorrents 删除选中的失效种子;删除前逐个重新读取 tracker 状态,已经恢复正常的不删。 要求删数据时,数据还被别的种子用着的(如在别的站点辅种的同一份文件)只删种子、保留数据。

type DeadReason

type DeadReason string

DeadReason 是失效的原因。

const (
	// DeadUnregistered 是 tracker 说这个种子没有注册(站点删了种或换了种)。
	DeadUnregistered DeadReason = "unregistered"
	// DeadNotFound 是 tracker 说种子不存在或已被删除。
	DeadNotFound DeadReason = "not_found"
)

type DeadTorrent

type DeadTorrent struct {
	Hash        string     `json:"hash"`
	Name        string     `json:"name"`
	Size        int64      `json:"size"`
	Progress    float64    `json:"progress"`
	Site        string     `json:"site,omitempty"`
	SiteName    string     `json:"site_name,omitempty"`
	TrackerHost string     `json:"tracker_host"`
	Reason      DeadReason `json:"reason"`
	Message     string     `json:"message"`
}

DeadTorrent 是一个失效种子。

type ItemError

type ItemError struct {
	Hash  string `json:"hash"`
	Name  string `json:"name,omitempty"`
	Error string `json:"error"`
}

ItemError 是执行时没成功的一项。

type ScanInfo

type ScanInfo struct {
	Total   int `json:"total"`
	Scanned int `json:"scanned"`
}

ScanInfo 说明一次扫描检查了多少种子:Scanned 小于 Total 时说明种子太多,只检查了一部分。

type SiteTagItem

type SiteTagItem struct {
	Hash string `json:"hash"`
	Site string `json:"site"`
}

SiteTagItem 是要补的一项:种子与站点。

type SiteTagSuggestion

type SiteTagSuggestion struct {
	Hash        string `json:"hash"`
	Name        string `json:"name"`
	Size        int64  `json:"size"`
	Site        string `json:"site"`
	SiteName    string `json:"site_name"`
	TrackerHost string `json:"tracker_host"`
	Tags        string `json:"tags"`
	Category    string `json:"category"`
}

SiteTagSuggestion 是一个按 tracker 认出了站点、但没打这个站点分类或标签的种子。

type TrackerMatch

type TrackerMatch struct {
	ID    string `json:"id"`
	Hash  string `json:"hash"`
	Name  string `json:"name"`
	Old   string `json:"old"`
	New   string `json:"new"`
	Error string `json:"error,omitempty"`
}

TrackerMatch 是一个要改的 tracker 地址(脱敏后展示)。ID 是这条「原地址 → 新地址」的指纹, 执行时只改指纹仍然对得上的地址:预览之后新加的、被改过的地址都不会被动到。 替换后不是有效地址的那条 ID 为空、Error 写明原因,不能执行。

type TrackerSelection

type TrackerSelection struct {
	Hash string `json:"hash"`
	ID   string `json:"id"`
}

TrackerSelection 是执行替换时选中的一条:种子与预览时那条地址的指纹。

Jump to

Keyboard shortcuts

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