subscribe

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 47 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 subscribe 是订阅:按电影或剧集的一季找资源(RSS 拉到的种子与定时主动搜索),按质量档案挑、推送到下载器, 剧集按 TMDB 的分集找缺的集;洗版时接着找更好的版本,入库后替换旧文件;豆瓣想看定时建订阅。

Index

Constants

View Source
const (
	GuardKeepTag     = "keep_tag"
	GuardProtectTag  = "protect_tag"
	GuardHR          = "hr"
	GuardDownloading = "downloading"
	GuardMinRetain   = "min_retain"
)

保护规则(Protection.Rule),同 scheduler 的 GuardKeepTag 等(cmd 里接 SeedGuard 时原样转过来)。

View Source
const (
	// DeleteSubPause 暂停(默认):不暂停的话,台账会把删掉的集当成缺的,再去下一遍
	DeleteSubPause = "pause"
	// DeleteSubDelete 删除订阅:以后不再找
	DeleteSubDelete = "delete"
	// DeleteSubKeep 保留、继续追
	DeleteSubKeep = "keep"
)

订阅怎么办(DeleteRequest.Subscription)。

View Source
const (
	DeleteStepSubscription = "subscription"
	DeleteStepTorrent      = "torrent"
	DeleteStepFile         = "file"
)

删除的一步(DeleteStep.Kind)。

View Source
const (
	ExploreSearch   = "search"
	ExploreDiscover = "discover"
)

探索页的列表:TMDB 的列表(本周趋势、热门、高分,电影的正在上映与即将上映,剧集的正在播出与今天播出,见 tmdb.HasList)、 按条件发现(见 Discover),或者搜索。

View Source
const (
	ItemTorrentSeeding     = "seeding"
	ItemTorrentDownloading = "downloading"
	ItemTorrentPaused      = "paused"
	ItemTorrentError       = "error"
	// ItemTorrentUnknown 是下载器读不到(连不上):不知道它现在怎样
	ItemTorrentUnknown = "unknown"
)

关联的种子在下载器里的状态。

View Source
const (
	DefaultSearchIntervalHours = 12
	MinSearchIntervalHours     = 6
)

设置的默认值与范围。

View Source
const (
	EpisodeLibrary     = models.MediaEpisodeLibrary
	EpisodeDownloading = models.MediaEpisodeDownloading
	EpisodeMissing     = models.MediaEpisodeMissing
	EpisodeUpcoming    = models.MediaEpisodeUpcoming
	EpisodeWaiting     = models.MediaEpisodeWaitingVersion
	EpisodeSkipped     = models.MediaEpisodeSkipped
)

一集的情况。

View Source
const (
	// ReviewByName 只复核按名字对上的(种子与订阅没有都写 IMDb 编号)
	ReviewByName = "name"
	// ReviewAll 每个要推送的候选都复核
	ReviewAll = "all"
)

AI 复核的范围。

View Source
const (
	NoticeDownloaded     = "subscribe_downloaded"
	NoticeDoubanAbnormal = "douban_abnormal"
	// 追剧(剧集按自己的定时搜索的):下载了新的集、锁住的版本久等不到、连续几次没搜成
	NoticeFollowFound   = "followshow_found"
	NoticeFollowWaiting = "followshow_waiting"
	NoticeFollowFailed  = "followshow_failed"
)

通知的种类。

View Source
const DefaultSubdirTemplate = "{title} ({year})"

DefaultSubdirTemplate 是子目录名的默认模板。

View Source
const NoticeCalendarToday = "calendar_today"

NoticeCalendarToday 是每天推送的今日更新。

View Source
const PreviewMax = 10

PreviewMax 是定时预览最多给几次。

Variables

View Source
var (
	Resolutions = []string{"4320p", "2160p", "1440p", "1080p", "720p", "576p", "480p"}
	Sources     = []string{"UHD BluRay", "BluRay", "WEB-DL", "WEBRip", "HDTV", "DVD"}
	Codecs      = []string{"H.265", "AV1", "H.264", "VC-1", "MPEG-2", "XviD"}
)

分辨率、来源、编码的可选值(internal/media/meta 解析出的写法),列表里从好到差。档案里没有选时按这个顺序比较 分辨率与来源,编码不比。

View Source
var (
	ErrInvalid  = errors.New("参数不对")
	ErrNotFound = errors.New("没有这条记录")
	// ErrBusy 是同一件事正在做(例如这个豆瓣来源正在拉取)
	ErrBusy = errors.New("正在处理")
)

错误。接口层按它们回 400 / 404。

View Source
var ErrReviewUnclear = errors.New("看不出模型回答的是还是不是")

ErrReviewUnclear 是模型的回答看不出是还是不是:只是这一个候选没复核成,后面的候选照常复核。

Functions

func AirClock

func AirClock(e CalendarEntry) string

AirClock 是按播出时间追剧的播出时刻(HH:MM);不按播出时间的为空。

func BlockKey

func BlockKey(site, torrentID string) string

BlockKey 是认一个种子的键(站点名不分大小写),按它查 GlobalBlocks 的结果。

func Describe

func Describe(sub *models.MediaSubscription) string

Describe 是给人看的订阅设置(定时、版本锁、起始集),ChatOps 建追剧时回给用户。

func EntryTitle

func EntryTitle(e CalendarEntry) string

EntryTitle 是给人看的一项:订阅名(年份、季)加集号与集名,电影写上映。

func FollowDefaults

func FollowDefaults(in *SubscriptionInput)

FollowDefaults 是新建追剧的默认设置:剧集没有指定时按播出时间搜索、开着版本锁(同组同分辨率)。电影不变。 网页、App API 与 ChatOps 的 /follow 新建时用它;豆瓣想看与 /sub 建的保持原来的行为。

func StateLabel

func StateLabel(state string) string

StateLabel 是状态的中文说明。

Types

type BangumiAPI

type BangumiAPI interface {
	Calendar(ctx context.Context) ([]bangumi.CalendarDay, error)
}

BangumiAPI 是番剧日历用的 Bangumi 客户端(生产环境是 *bangumi.Client)。

type BangumiMatch

type BangumiMatch struct {
	MediaType string `json:"media_type"`
	TMDBID    int    `json:"tmdb_id"`
	Title     string `json:"title"`
}

BangumiMatch 是番剧日历里一部动画在 TMDB 上对应的剧集。

type BlockInput

type BlockInput struct {
	MediaType string `json:"media_type"`
	TMDBID    int    `json:"tmdb_id"`
	Season    int    `json:"season"`
	// MediaTitle 是条目的名字(带季),列表里写作用于哪个条目;为空时有订阅就用订阅的名字
	MediaTitle string      `json:"media_title"`
	Reason     string      `json:"reason"`
	Items      []BlockItem `json:"items"`
	// ExcludeGroup 为真时把第一个种子的制作组加进这一季订阅的标题排除词(「以后也不要这个制作组」);要有订阅
	ExcludeGroup bool `json:"exclude_group"`
}

BlockInput 是一次拉黑:作用于一个条目(剧集是其中一季),TMDBID 为 0 时对所有条目生效。

type BlockItem

type BlockItem struct {
	Site      string `json:"site"`
	TorrentID string `json:"torrent_id"`
	Title     string `json:"title"`
}

BlockItem 是要拉黑的一个种子。

type BlockResult

type BlockResult struct {
	Blocks        []models.MediaTorrentBlock `json:"blocks"`
	ExcludedGroup string                     `json:"excluded_group,omitempty"`
}

BlockResult 是拉黑的结果:写好的行,以及加进标题排除词的制作组(没有加时为空)。

type BlockTorrentInput

type BlockTorrentInput struct {
	Reason string `json:"reason"`
	// ExcludeGroup 为真时把这个种子的制作组加进订阅的标题排除词
	ExcludeGroup bool `json:"exclude_group"`
}

BlockTorrentInput 是追剧详情里的「不要这个种子」。

type Calendar

type Calendar struct {
	From    string          `json:"from"`
	To      string          `json:"to"`
	Today   string          `json:"today"`
	Entries []CalendarEntry `json:"entries"`
	Errors  []string        `json:"errors"`
}

Calendar 是一段日子(From 到 To,含两头)的日历。Errors 是没读到 TMDB 的订阅(别的照样列出)。

type CalendarEntry

type CalendarEntry struct {
	SubscriptionID uint   `json:"subscription_id"`
	MediaType      string `json:"media_type"`
	TMDBID         int    `json:"tmdb_id"`
	Title          string `json:"title"`
	Year           int    `json:"year,omitempty"`
	// Season、Episode 是季与集(电影是 0);Name 是集名
	Season  int    `json:"season,omitempty"`
	Episode int    `json:"episode,omitempty"`
	Name    string `json:"name,omitempty"`
	AirDate string `json:"air_date"`
	// AirAt、SearchAt 是播出时刻与开始搜的时刻:按播出时间的追剧才有
	AirAt    *time.Time `json:"air_at,omitempty"`
	SearchAt *time.Time `json:"search_at,omitempty"`
	// State 同追剧台账:library、downloading、waiting_version、missing、upcoming、skipped
	State      string `json:"state"`
	PosterPath string `json:"poster_path,omitempty"`
	StillPath  string `json:"still_path,omitempty"`
}

CalendarEntry 是日历上的一项:剧集的一集,或电影的上映。

type Candidate

type Candidate struct {
	Site string
	Item v2.TorrentItem
	Meta meta.Meta
	From string
	// SiteHR 是站点整站都有 H&R 要求
	SiteHR bool
	// SeenAt 是取得这条数据的时间(RSS 是取详情的时间,搜索是发起搜索的时间)
	SeenAt time.Time
	// Chosen 是用户在一键追剧里自己选的种子:推送前不让 AI 复核
	Chosen bool
}

Candidate 是一个候选种子:站点上的种子、从标题解析出的信息,以及从哪里来的(rss 或 search)。

type Config

type Config struct {
	DB          *gorm.DB
	Recognizer  Recognizer
	Search      Searcher
	Sites       SitesFunc
	SiteNames   func() []string
	Push        PushFunc
	Downloaders Downloaders
	Library     Library
	Organizer   Organizer
	// Deleter 是条目详情里「删除一部片」要用的整理入库的动作(生产环境是 *organize.Service);Guard 是删种的保护规则
	// (生产环境是 scheduler.SeedGuard)。为空时删除预览与执行回错误,条目详情里的种子一律当作受保护
	Deleter LibraryDeleter
	Guard   GuardFunc
	Notify  Notifier
	Logger  *zap.SugaredLogger
	Now     func() time.Time
	// Jitter 是主动搜索与豆瓣拉取的随机偏移(测试里换成固定的)
	Jitter func(limit time.Duration) time.Duration
	// HTTP 拉豆瓣用(为空时用带超时的默认客户端,走系统代理)
	HTTP *http.Client
	// DoubanBase 是豆瓣的地址(测试与 QA 换成假服务)
	DoubanBase string
	// Bangumi 是探索页番剧日历用的 Bangumi 客户端(为空时番剧日历回错误)
	Bangumi BangumiAPI
}

Config 是订阅服务的依赖。

type DeletePreview

type DeletePreview struct {
	Files         []organize.LibraryFile `json:"files"`
	Torrents      []DeleteTorrent        `json:"torrents"`
	Subscriptions []ItemSubscription     `json:"subscriptions"`
	Issues        []models.MediaIssue    `json:"issues"`
	Errors        []string               `json:"errors"`
}

DeletePreview 是删除预览:库里的文件(整理记录)、关联的种子、覆盖这一部的订阅与范围里还开着的问题。Errors 是没读到的部分: 读不到的下载器里的种子不列,读不到保护规则时种子一律当作受保护。

type DeleteRequest

type DeleteRequest struct {
	DeleteSelector
	HistoryIDs       []uint             `json:"history_ids"`
	AllowExisting    bool               `json:"allow_existing"`
	Torrents         []DeleteTorrentReq `json:"torrents"`
	ConfirmProtected []TorrentKey       `json:"confirm_protected"`
	Subscription     string             `json:"subscription"`
}

DeleteRequest 是删除的请求:选择器、要连文件删的整理记录(预览里看到的那些,空的不删库文件)、导入的已有文件也删、 要删的种子与受保护的种子里确认了要删的(按下载器编号与 hash)、订阅怎么办(为空时暂停)。

type DeleteResult

type DeleteResult struct {
	Steps  []DeleteStep `json:"steps"`
	Failed int          `json:"failed"`
}

DeleteResult 是删除的结果:每一步(订阅、种子、库文件的顺序)与失败了几步。

type DeleteSelector

type DeleteSelector struct {
	MediaType string `json:"media_type"`
	TMDBID    int    `json:"tmdb_id"`
	Season    int    `json:"season"`
	Episodes  []int  `json:"episodes"`
}

DeleteSelector 选要删的:一部电影;剧集的一季,Episodes 不为空时只是其中几集。

type DeleteStep

type DeleteStep struct {
	Kind   string `json:"kind"`
	Target string `json:"target"`
	// ID 是订阅或整理记录的编号;种子写 DownloaderID 与 Hash
	ID           uint   `json:"id,omitempty"`
	DownloaderID uint   `json:"downloader_id,omitempty"`
	Hash         string `json:"hash,omitempty"`
	OK           bool   `json:"ok"`
	Message      string `json:"message"`
}

DeleteStep 是删除的一步:一个订阅、一个种子或一条整理记录(连库里的文件),各自成功或失败。

type DeleteTorrent

type DeleteTorrent struct {
	ItemTorrent
	Rule string `json:"rule,omitempty"`
	// Why 是受保护的短句,弹窗写在「受保护:」后面(完整的原因在 Protection)
	Why        string     `json:"why,omitempty"`
	CoversMore bool       `json:"covers_more"`
	More       string     `json:"more,omitempty"`
	Shares     []ShareRef `json:"shares"`
}

DeleteTorrent 是删除预览里的一个关联种子:同条目详情的种子(能不能删按保护规则),另写命中的规则、种子里是不是还有这次没选的集 (CoversMore,默认不勾),以及同一台下载器里和它共用数据的种子(Shares:要连数据删,得这几个也一起删)。

type DeleteTorrentReq

type DeleteTorrentReq struct {
	TorrentKey
	DeleteData bool `json:"delete_data"`
}

DeleteTorrentReq 是要删的一个种子;DeleteData 为真时连数据删(还有别的种子用着这份数据时只删种子)。

type DoubanSourceInput

type DoubanSourceInput struct {
	UserID    string `json:"user_id"`
	Name      string `json:"name"`
	Enabled   bool   `json:"enabled"`
	Confirm   bool   `json:"confirm"`
	ProfileID uint   `json:"profile_id"`
}

DoubanSourceInput 是新建或修改豆瓣来源的内容。

type DoubanSourceView

type DoubanSourceView struct {
	models.MediaDoubanSource
	Subscribed int `json:"subscribed"`
	Unmatched  int `json:"unmatched"`
}

DoubanSourceView 是豆瓣来源加上建过的订阅数(包括后来删掉的)与没找到条目的数。

type Downloaders

type Downloaders interface {
	Get(ctx context.Context, id uint) (downloader.Downloader, models.DownloaderSetting, error)
}

Downloaders 按编号取下载器(洗版以后删旧种子用)。

type EpisodeIssue

type EpisodeIssue struct {
	ID     uint   `json:"id"`
	Server string `json:"server"`
}

EpisodeIssue 是一集的 server_removed 或 library_missing 问题:编号(忽略时用)与哪台服务器(库文件的问题没有)。

type EpisodeRuleInput

type EpisodeRuleInput struct {
	Group  string `json:"group"`
	Mode   string `json:"mode"`
	Offset int    `json:"offset"`
	Note   string `json:"note"`
	// Source 是规则从哪里来的(manual、ai;为空当作 manual)
	Source string `json:"source,omitempty"`
}

EpisodeRuleInput 是一条集号规则:Group 为空时对所有制作组。

type EpisodeState

type EpisodeState struct {
	Number  int    `json:"number"`
	Name    string `json:"name,omitempty"`
	AirDate string `json:"air_date,omitempty"`
	State   string `json:"state"`
	// Source 是状态从哪里来的(library、subscription、downloader);Version 是这一集现在的版本(制作组与分辨率)
	Source       string `json:"source,omitempty"`
	Version      string `json:"version,omitempty"`
	ManualSkip   bool   `json:"manual_skip,omitempty"`
	ManualUnlock bool   `json:"manual_unlock,omitempty"`
}

EpisodeState 是一集的情况:library 已入库、downloading 下载中、missing 缺、waiting_version 等锁住的版本、 upcoming 还没播出、skipped 不追(起始集以前的或跳过的)。

type ExploreFilter

type ExploreFilter struct {
	Country string
	Genres  string
}

ExploreFilter 是按条件发现的筛选:Country 是出品国家或地区(两个大写字母,例如 CN、JP),Genres 是 TMDB 的类型编号 (几个用 | 隔开时是其中任意一个,例如综艺是 10764|10767)。空的不限。

type ExploreItem

type ExploreItem struct {
	tmdb.Result
	InLibrary bool `json:"in_library"`
	// Subscribed 是这个条目有订阅(剧集是任意一季);SubscriptionID 是其中最新的一个
	Subscribed     bool `json:"subscribed"`
	SubscriptionID uint `json:"subscription_id,omitempty"`
}

ExploreItem 是探索页的一个条目,标上库里有没有、订阅过没有。

type ExplorePage

type ExplorePage struct {
	Items      []ExploreItem `json:"items"`
	Page       int           `json:"page"`
	TotalPages int           `json:"total_pages"`
}

ExplorePage 是探索页的一页。

type FromTorrent

type FromTorrent struct {
	Site      string `json:"site"`
	TorrentID string `json:"torrent_id"`
	Title     string `json:"title,omitempty"`
}

FromTorrent 是一键追剧时选中的站点上的种子。Title 可选,只在搜索缓存里找不到这个种子时用作在这个站点搜索的关键字, 不参与任何判断(编号要完全相同)。

type Guard

type Guard interface {
	Check(t downloader.Torrent) Protection
	// Rules 是开着的规则(条目详情的说明用)
	Rules() []string
}

Guard 是删种的保护规则(生产环境是 scheduler.SeedGuard:和自动删种共用全局设置里「自动删种」的保护项)。

type GuardFunc

type GuardFunc func(ctx context.Context) (Guard, error)

GuardFunc 按现在的设置建保护规则;返回错误时分不清哪些种子受保护,一律当作受保护、不删。

type HomeCalendar

type HomeCalendar struct {
	Today         []TodayItem     `json:"today"`
	Week          []CalendarEntry `json:"week"`
	Errors        []string        `json:"errors"`
	Subscriptions int64           `json:"subscriptions"`
}

HomeCalendar 是首页用的今天播出与这周还要播(明天起 6 天)。Errors 是没读到 TMDB 的订阅(别的照样列); Subscriptions 是订阅的个数(一个都没有时首页写「还没有追剧」,不写「今天没有要播的集」)。

type ItemDetail

type ItemDetail struct {
	Item            ItemInfo           `json:"item"`
	Seasons         []ItemSeason       `json:"seasons"`
	NAS             ItemNAS            `json:"nas"`
	Servers         []ItemServer       `json:"servers"`
	Subscriptions   []ItemSubscription `json:"subscriptions"`
	Torrents        []ItemTorrent      `json:"torrents"`
	Recommendations []ExploreItem      `json:"recommendations"`
	// ProtectRules 是删除时按哪几条保护(开着的保护规则,见 Guard);读不到保护规则时为空
	ProtectRules []string `json:"protect_rules"`
	Errors       []string `json:"errors"`
}

ItemDetail 是条目详情页的数据。Errors 是没取到的部分(演职员、各季、推荐、某个下载器、媒体服务器的索引),其余照样给。

type ItemInfo

type ItemInfo struct {
	MediaType     string `json:"media_type"`
	TMDBID        int    `json:"tmdb_id"`
	Title         string `json:"title"`
	OriginalTitle string `json:"original_title,omitempty"`
	Year          int    `json:"year,omitempty"`
	// Date 是电影的上映日期、剧集的首播日期
	Date     string   `json:"date,omitempty"`
	Overview string   `json:"overview,omitempty"`
	Genres   []string `json:"genres"`
	// Countries 是出品国家或地区(ISO 3166-1)
	Countries []string `json:"countries"`
	// Runtime 是片长(分钟):电影是整部,剧集是一集
	Runtime int `json:"runtime,omitempty"`
	// Status 是 TMDB 的状态原文(Returning Series、Ended、Released……)
	Status       string            `json:"status,omitempty"`
	PosterPath   string            `json:"poster_path,omitempty"`
	BackdropPath string            `json:"backdrop_path,omitempty"`
	Rating       float64           `json:"rating,omitempty"`
	Votes        int               `json:"votes,omitempty"`
	IMDbID       string            `json:"imdb_id,omitempty"`
	TVDBID       int               `json:"tvdb_id,omitempty"`
	Studios      []string          `json:"studios"`
	Directors    []string          `json:"directors"`
	Cast         []tmdb.CastMember `json:"cast"`
	// SeasonsCount、EpisodesCount 是剧集的季数与总集数(不算特别篇)
	SeasonsCount  int `json:"seasons_count,omitempty"`
	EpisodesCount int `json:"episodes_count,omitempty"`
}

ItemInfo 是条目的资料:TMDB 详情与 Extras 合在一起。

type ItemLibrary

type ItemLibrary struct {
	Seasons   []ItemSeasonHave `json:"seasons"`
	Files     int              `json:"files"`
	Size      int64            `json:"size"`
	Libraries []string         `json:"libraries"`
	// Version 是电影最新入库的那个文件的版本(分辨率与制作组)
	Version string `json:"version,omitempty"`
	// RecordID 是最新的一条整理记录(详情页的「重新刮削」用它:刮削这条记录所在的电影或剧集)
	RecordID uint `json:"record_id,omitempty"`
	// Missing 是还开着的「库里的文件不见了」(library_missing,见每天的巡检)
	Missing []ItemServerIssue `json:"missing"`
}

ItemLibrary 是库里的情况:剧集按季写入库了几集(只列有入库的季),整理好的文件数、体积与媒体库;电影另写版本。

type ItemNAS

type ItemNAS struct {
	Library ItemLibrary `json:"library"`
	Seeding ItemSeeding `json:"seeding"`
}

ItemNAS 是「你的 NAS 上」:库里的情况与做种的情况。

type ItemSeason

type ItemSeason struct {
	Number       int    `json:"n"`
	Name         string `json:"name,omitempty"`
	EpisodeCount int    `json:"episode_count"`
	AirDate      string `json:"air_date,omitempty"`
	PosterPath   string `json:"poster_path,omitempty"`
	Have         int    `json:"have"`
}

ItemSeason 是剧集的一季:Have 是这一季已入库的集数。

type ItemSeasonHave

type ItemSeasonHave struct {
	Number int `json:"n"`
	Have   int `json:"have"`
	Total  int `json:"total"`
}

ItemSeasonHave 是一季入库了几集(Total 是这一季的集数)。

type ItemSeeding

type ItemSeeding struct {
	Count         int      `json:"count"`
	HRPending     int      `json:"hr_pending"`
	HRLeftSeconds int64    `json:"hr_left_seconds,omitempty"`
	LowestRatio   *float64 `json:"lowest_ratio,omitempty"`
}

ItemSeeding 是做种的情况:在做种的种子数,有 H&R 要求还没做够的个数与其中离做够最近的还差几秒,在做种的种子里最低的分享率。

type ItemServer

type ItemServer struct {
	ServerID uint              `json:"server_id"`
	Name     string            `json:"name"`
	Kind     string            `json:"kind"`
	SyncedAt *time.Time        `json:"synced_at,omitempty"`
	Have     bool              `json:"have"`
	Episodes int               `json:"episodes,omitempty"`
	Seasons  []ItemSeasonHave  `json:"seasons,omitempty"`
	OpenURL  string            `json:"open_url,omitempty"`
	Removed  []ItemServerIssue `json:"removed"`
}

ItemServer 是一台媒体服务器里有没有这一部(「你的 NAS 上」的媒体服务器那一行与「在 Jellyfin 播放」):开着、索引开着、 同步过的服务器才列。剧集写服务器里有几集与各季几集;Removed 是 pt-tools 整理过、服务器里删了、还没处理的。

type ItemServerIssue

type ItemServerIssue struct {
	ID      uint `json:"id"`
	Season  int  `json:"season,omitempty"`
	Episode int  `json:"episode,omitempty"`
}

ItemServerIssue 是一个 server_removed 问题(剧集带季集)。

type ItemSubscription

type ItemSubscription struct {
	ID     uint             `json:"id"`
	Status string           `json:"status"`
	Season int              `json:"season"`
	Follow bool             `json:"follow"`
	Lock   *MediaSearchLock `json:"lock,omitempty"`
}

ItemSubscription 是这个条目的一个订阅(剧集每季一个)。Follow 是追剧(按自己的定时搜索)。

type ItemTorrent

type ItemTorrent struct {
	Site      string `json:"site"`
	TorrentID string `json:"torrent_id,omitempty"`
	Title     string `json:"title"`
	// Season 是剧集的季(0 是不知道);Episodes 是种子里的集(E01–E04、整季),不知道时为空
	Season         int     `json:"season"`
	Episodes       string  `json:"episodes,omitempty"`
	Version        string  `json:"version,omitempty"`
	Size           int64   `json:"size"`
	DownloaderID   uint    `json:"downloader_id"`
	Downloader     string  `json:"downloader"`
	Hash           string  `json:"hash"`
	State          string  `json:"state"`
	Percent        float64 `json:"percent"`
	ETASeconds     int64   `json:"eta_seconds,omitempty"`
	Ratio          float64 `json:"ratio"`
	SeedingSeconds int64   `json:"seeding_seconds"`
	HR             bool    `json:"hr"`
	HRHours        int     `json:"hr_hours,omitempty"`
	Deletable      bool    `json:"deletable"`
	Reason         string  `json:"reason"`
	Protection     string  `json:"protection,omitempty"`
}

ItemTorrent 是和这个条目有关、还在下载器里的一个种子:推送时说明了这个条目的、订阅下载的、整理进库的。 Deletable 是能不能删(按自动删种的保护规则,见 Guard):Reason 是「能不能删」那一列的短字,Protection 是受保护时的完整原因。

type Library

type Library interface {
	InLibrary(ctx context.Context, kind string, tmdbID int, imdbID, title string) (bool, error)
}

Library 报告条目在不在媒体服务器里(没有配媒体服务器时返回 false;生产环境是 *organize.Service)。

type LibraryDeleter

type LibraryDeleter interface {
	LibraryFiles(ctx context.Context, q organize.FileQuery) ([]organize.LibraryFile, error)
	DeleteHistoryWith(ctx context.Context, id uint, opt organize.DeleteOptions) ([]string, error)
	KeepLinks(ctx context.Context, ids []uint) error
}

LibraryDeleter 是删除一部片要用的整理入库的动作(生产环境是 *organize.Service)。

type LibraryMovie

type LibraryMovie struct {
	Have bool
	Size int64
	Dir  string
}

LibraryMovie 是库里一部电影的情况:有没有整理好的文件、文件一共多大、最近整理的文件所在的目录。

type LibrarySeason

type LibrarySeason struct {
	Episodes int
	Size     int64
}

LibrarySeason 是库里一季的情况:入库了几集、这些集的文件一共多大。

type MediaSearchBlock

type MediaSearchBlock struct {
	ID     uint   `json:"id"`
	Reason string `json:"reason,omitempty"`
	All    bool   `json:"all,omitempty"`
}

MediaSearchBlock 是拉黑的记录:ID 用来移出黑名单,All 为真时是对所有条目拉黑的。

type MediaSearchDraft

type MediaSearchDraft struct {
	ProfileID       uint   `json:"profile_id"`
	IncludeKeywords string `json:"include_keywords"`
	ExcludeKeywords string `json:"exclude_keywords"`
}

MediaSearchDraft 是试搜索时还没保存的表单。ProfileID 为 0 时用设置里的默认档案(和保存这张表单以后一样); IncludeKeywords、ExcludeKeywords 是表单里的原样文字(写法见 models.MediaSubscription)。 别名、集号规则、剧集组与手填的集数照旧用库里这一季的订阅,没有订阅时按 TMDB。

type MediaSearchEpisode

type MediaSearchEpisode struct {
	Episode int    `json:"episode"`
	State   string `json:"state"`
	Site    string `json:"site,omitempty"`
	AirDate string `json:"air_date,omitempty"`
	Name    string `json:"name,omitempty"`
}

MediaSearchEpisode 是一集现在的情况:library 已入库、downloading 在下载(Site 是来源站点,下载器里认领的种子为空)、 waiting_version 等锁住的版本、missing 缺、upcoming 还没播。

type MediaSearchError

type MediaSearchError struct {
	Site     string `json:"site"`
	Error    string `json:"error"`
	TimedOut bool   `json:"timed_out,omitempty"`
}

MediaSearchError 是一个站点(Site 为空时是一次搜索)的错误。TimedOut 为真时是到了时限还没有回应。

type MediaSearchGroup

type MediaSearchGroup struct {
	GroupID string              `json:"group_id"`
	Members []MediaSearchMember `json:"members"`
	// Meta 与 Verdict 是首选的
	Meta    meta.Meta           `json:"meta"`
	Verdict *MediaSearchVerdict `json:"verdict"`
	// Span 是剧集里有的集(电影为空)
	Span *MediaSearchSpan `json:"span,omitempty"`
	// Covers 是能补上的集(缺的与等版本的);Downloading 是这一组里正在下载的集;InLibrary 是这一组的集都已入库(电影是库里有)
	Covers      []int `json:"covers"`
	Downloading []int `json:"downloading"`
	InLibrary   bool  `json:"in_library"`
	// Blocked 是这一组的成员都拉黑了(排在最后)
	Blocked bool `json:"blocked,omitempty"`
}

MediaSearchGroup 是同一个资源:Members 的第一个是首选。

type MediaSearchInput

type MediaSearchInput struct {
	MediaType string `json:"media_type"`
	TMDBID    int    `json:"tmdb_id"`
	// Season 是剧集的季,0 是最新的一季;电影不用
	Season int `json:"season"`
	// ProfileID 只影响这一次搜索,不改订阅:大于 0 用这个档案;0 用这一季订阅的档案,没有订阅或订阅没设档案时用设置里的
	// 默认档案(都没有时按分辨率与来源从好到差比);-1 不按档案
	ProfileID int `json:"profile_id"`
	// Sites 只搜这些站点;为空时搜全部
	Sites []string `json:"sites"`
	// IncludeUnmatched 为真时把对不上这个条目的结果也返回,写明原因
	IncludeUnmatched bool `json:"include_unmatched"`
	// Draft 是还没保存的表单(试搜索):给了它时质量档案、标题包含与排除按它来,不按库里的订阅;不能和 ProfileID 同时给
	Draft *MediaSearchDraft `json:"draft,omitempty"`
	// Deadline 只管站点搜索这一段:不为零时站点搜索最晚到这个时间(比 mediaSearchTimeout 早时),到点没回来的站点写进 Errors
	// 并标 TimedOut,已经回来的照常出结果。只由调用方的代码设(App 的试搜索),请求体里设不了
	Deadline time.Time `json:"-"`
}

MediaSearchInput 是按条目搜索的请求。

func (MediaSearchInput) Validate

func (in MediaSearchInput) Validate() error

Validate 检查请求(和 SearchMedia 开头的检查一样),不搜索:调用方要先过滤站点、可能不搜时用它,参数不对照样报错。

type MediaSearchItem

type MediaSearchItem struct {
	MediaType     string `json:"media_type"`
	TMDBID        int    `json:"tmdb_id"`
	Season        int    `json:"season,omitempty"`
	Title         string `json:"title"`
	OriginalTitle string `json:"original_title,omitempty"`
	// Year 是剧集这一季的年份
	Year       int    `json:"year,omitempty"`
	PosterPath string `json:"poster_path,omitempty"`
	// Seasons 是剧集一共几季;TotalEpisodes 是这一季几集
	Seasons       int `json:"seasons,omitempty"`
	TotalEpisodes int `json:"total_episodes,omitempty"`
}

MediaSearchItem 是搜的条目。

type MediaSearchLock

type MediaSearchLock struct {
	Group      string `json:"group"`
	Resolution string `json:"resolution"`
}

MediaSearchLock 是锁住的版本:制作组与分辨率,认不出的那一项为空。

type MediaSearchMember

type MediaSearchMember struct {
	Site       string `json:"site"`
	TorrentID  string `json:"torrent_id"`
	Title      string `json:"title"`
	Subtitle   string `json:"subtitle,omitempty"`
	InfoHash   string `json:"info_hash,omitempty"`
	SizeBytes  int64  `json:"size_bytes"`
	UploadedAt int64  `json:"uploaded_at,omitempty"`
	Seeders    int    `json:"seeders"`
	Leechers   int    `json:"leechers"`
	Snatched   int    `json:"snatched,omitempty"`
	// Discount 是优惠(站点的 DiscountLevel 原样);Free 是现在免费,FreeLeftSeconds 是免费还剩几秒(不知道结束时间时为 0)
	Discount        string `json:"discount"`
	Free            bool   `json:"free"`
	FreeLeftSeconds int64  `json:"free_left_seconds,omitempty"`
	// HR 是有 H&R 要求(种子自己有,或者站点整站有);HRHours 是要做种多少小时,不知道时为 0
	HR          bool   `json:"hr"`
	HRHours     int    `json:"hr_hours,omitempty"`
	URL         string `json:"url,omitempty"`
	DownloadURL string `json:"download_url,omitempty"`
	Category    string `json:"category,omitempty"`
	// ByIMDb 是按 IMDb 编号对上的(不是按名字)
	ByIMDb  bool                `json:"by_imdb,omitempty"`
	Meta    meta.Meta           `json:"meta"`
	Verdict *MediaSearchVerdict `json:"verdict"`
	// Reason 是对不上这个条目的原因(只在 unmatched 里)
	Reason string `json:"reason,omitempty"`
	// Block 是这个种子拉黑了(对这个条目,或对所有条目);没拉黑时为空
	Block *MediaSearchBlock `json:"block,omitempty"`
}

MediaSearchMember 是一个站点上的一个种子。

type MediaSearchMovie

type MediaSearchMovie struct {
	State string `json:"state"`
	Site  string `json:"site,omitempty"`
}

MediaSearchMovie 是电影现在的情况:library、downloading 或 missing。

type MediaSearchProfile

type MediaSearchProfile struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
}

MediaSearchProfile 是打分用的档案。

type MediaSearchResult

type MediaSearchResult struct {
	Item MediaSearchItem `json:"item"`
	// Subscription 是这一季(电影就是这部)的订阅,没有时为空
	Subscription *MediaSearchSubscription `json:"subscription"`
	// Profile 是这次打分用的档案;不按档案时为空,没有档案(按分辨率与来源比)时编号为 0
	Profile  *MediaSearchProfile `json:"profile"`
	Keywords []string            `json:"keywords"`
	// Episodes 是这一季每集现在的情况(剧集);Movie 是电影现在的情况
	Episodes []MediaSearchEpisode `json:"episodes"`
	Movie    *MediaSearchMovie    `json:"movie,omitempty"`
	// Groups 是对上这个条目的结果,同一资源一组,排好了序
	Groups []MediaSearchGroup `json:"groups"`
	// Total 是对上这个条目的结果数(各组成员数之和)
	Total int `json:"total"`
	// BlockedCount 是对上了、但拉黑了的结果数(成员数)
	BlockedCount int `json:"blocked_count"`
	// UnmatchedCount 是对不上这个条目的结果数;Unmatched 只在请求 include_unmatched 时带上
	UnmatchedCount int                 `json:"unmatched_count"`
	Unmatched      []MediaSearchMember `json:"unmatched,omitempty"`
	Errors         []MediaSearchError  `json:"errors"`
}

MediaSearchResult 是按条目搜索的结果。

type MediaSearchSpan

type MediaSearchSpan struct {
	Start int  `json:"start,omitempty"`
	End   int  `json:"end,omitempty"`
	Whole bool `json:"whole,omitempty"`
}

MediaSearchSpan 是种子里的集:Whole 为真时是整季,否则是 [Start, End]。

type MediaSearchSubscription

type MediaSearchSubscription struct {
	ID     uint   `json:"id"`
	Status string `json:"status"`
	// Lock 是锁住的版本,没开版本锁时为空
	Lock *MediaSearchLock `json:"lock"`
}

MediaSearchSubscription 是条目的订阅。

type MediaSearchVerdict

type MediaSearchVerdict struct {
	Score  int    `json:"score"`
	Reject string `json:"reject,omitempty"`
}

MediaSearchVerdict 是按档案的结果:Reject 不为空时不符合(全部原因),Score 是 0–100 的分。

type Notice

type Notice struct {
	Channels []uint
	Kind     string
	Subject  string
	EventKey string
	Title    string
	Body     string
	ImageURL string
	// Event 是这条通知对应的事件(消息模板用)
	Event *notify.Event
}

Notice 是一条订阅的通知:下载了订阅的资源,或豆瓣想看拉取连续失败。

type Notifier

type Notifier func(ctx context.Context, n Notice) error

Notifier 发通知(生产环境经监控通知投递器)。

type Organizer

type Organizer interface {
	Retire(ctx context.Context, id uint, reason string) ([]string, error)
	Retry(ctx context.Context, id uint) (*organize.Result, error)
	// Retrying 报告失败的记录是不是正在重试(排上队以后记录里的重试时间是空的)
	Retrying(id uint) bool
	// Organize 整理下载器里的一个种子(按手动整理处理:指定了条目时用那个条目)
	Organize(ctx context.Context, req organize.Request) (*organize.Result, error)
	// Rescrape 重新刮削一条整理记录所在的电影或剧集
	Rescrape(ctx context.Context, id uint) (*organize.RescrapeResult, error)
}

Organizer 是订阅要用的整理入库的动作(生产环境是 *organize.Service):洗版换掉旧版本、重新整理, 以及追剧详情里的「重新整理」「重新刮削」。

type Profile

type Profile struct {
	ID          uint     `json:"id"`
	Name        string   `json:"name"`
	Resolutions []string `json:"resolutions"`
	Sources     []string `json:"sources"`
	Codecs      []string `json:"codecs"`
	Remux       string   `json:"remux"`
	HDR         string   `json:"hdr"`
	ChineseSubs string   `json:"chinese_subs"`
	Free        string   `json:"free"`
	Groups      []string `json:"groups"`
	MinSizeGB   float64  `json:"min_size_gb"`
	MaxSizeGB   float64  `json:"max_size_gb"`
	MinSeeders  int      `json:"min_seeders"`
	ExcludeHR   bool     `json:"exclude_hr"`
}

Profile 是解开 JSON 以后的质量档案。

func (Profile) Score

func (p Profile) Score(c Candidate, episodes int) Verdict

Score 按档案给候选种子打分。episodes 是种子里有几集(剧集按每集算体积;电影与认不出集数的传 1)。 RSS 里刚发布的种子做种数还没有意义,最少做种数只对搜索到的种子生效。

func (Profile) TargetReached

func (p Profile) TargetReached(m meta.Meta) bool

TargetReached 报告资源是不是已经达到档案里排第一的分辨率与来源(档案要优先 Remux 时还要是 Remux): 洗版到这里就停。档案里没有选分辨率或来源时,那一项不限。

type ProfileInput

type ProfileInput struct {
	Name        string   `json:"name"`
	Resolutions []string `json:"resolutions"`
	Sources     []string `json:"sources"`
	Codecs      []string `json:"codecs"`
	Remux       string   `json:"remux"`
	HDR         string   `json:"hdr"`
	ChineseSubs string   `json:"chinese_subs"`
	Free        string   `json:"free"`
	Groups      []string `json:"groups"`
	MinSizeGB   float64  `json:"min_size_gb"`
	MaxSizeGB   float64  `json:"max_size_gb"`
	MinSeeders  int      `json:"min_seeders"`
	ExcludeHR   bool     `json:"exclude_hr"`
}

ProfileInput 是新建或修改质量档案的内容。

type Progress

type Progress struct {
	Total       int   `json:"total"`
	Required    int   `json:"required"`
	Aired       int   `json:"aired"`
	InLibrary   int   `json:"in_library"`
	Downloading int   `json:"downloading"`
	Waiting     int   `json:"waiting"`
	Skipped     int   `json:"skipped"`
	Missing     []int `json:"missing,omitempty"`
	// States 是每一集的状态(按集号,剧集才有):列表里画格子用,不用另读详情
	States []string `json:"states,omitempty"`
	// Episodes 是每一集的情况(详情里才有)
	Episodes []EpisodeState `json:"episodes,omitempty"`
}

Progress 是订阅的进度。电影:Total 为 1,入了库 InLibrary 为 1。剧集按追剧台账算:Total 是有效总集数, Required 是要追的集(起始集以后、没有跳过的),Missing 是其中已播、不在库也不在下载的(含等版本的)。

type Protection

type Protection struct {
	Rule  string
	Text  string
	Tag   string
	Hours int
	Left  int64
}

Protection 是种子命中的一条保护规则(同 scheduler.Protection):Rule 为空表示不受保护;Text 是完整的原因;Tag 是命中的标签; Hours 是 H&R 要求的做种小时数(0 是要求不明)或最短保种时间;Left 是还差的秒数。

type PushFunc

PushFunc 是推送入口(生产环境是 internal.PushTorrentToDownloader,磁盘与站点容量闸门都在里面)。

type Recognizer

type Recognizer interface {
	Recognize(ctx context.Context, in recognize.Input) (*recognize.Result, error)
	Parse(ctx context.Context, title, subtitle string) (meta.Meta, error)
	TMDB(ctx context.Context) (*tmdb.Client, error)
}

Recognizer 是媒体识别(生产环境是 *recognize.Service)。

type ReviewInput

type ReviewInput struct {
	// Kind 是 movie 或 tv
	Kind          string
	Title         string
	OriginalTitle string
	Year          int
	// Season 是剧集的季(电影为 0)
	Season  int
	Aliases []string
	// TorrentTitle、TorrentSubtitle 是站点上的标题与副标题;Parsed 是从标题解析出的信息与对到的季集(一行)
	TorrentTitle    string
	TorrentSubtitle string
	Parsed          string
}

ReviewInput 是交给模型复核的一个候选:订阅的条目与站点上的种子。

type ReviewResult

type ReviewResult struct {
	Match  bool
	Reason string
	Tokens int64
}

ReviewResult 是模型的结论:Match 为真是「是」;Reason 是它给的理由;Tokens 是这次用的 token 数(不知道时为 0)。

type Reviewer

type Reviewer func(ctx context.Context, in ReviewInput) (ReviewResult, error)

Reviewer 复核一个候选(cmd 接到 AI 助手的 ReviewCandidate)。

type RunPage

type RunPage struct {
	Items []RunView `json:"items"`
	Total int64     `json:"total"`
}

RunPage 是运行记录的一页(新的在前)。

type RunStep

type RunStep struct {
	Kind string `json:"kind"`
	Text string `json:"text"`
}

RunStep 是一次运行里的一步。

type RunView

type RunView struct {
	models.MediaSubscriptionRun
	Steps []RunStep `json:"steps"`
}

RunView 是一次运行记录(带上解开的步骤)。

type Schedule

type Schedule struct {
	Kind string `json:"kind"`
	// At 是钟点(HH:MM):按播出时间时是当地的播出时刻(TMDB 只有日期),空的按 20:00
	At string `json:"at,omitempty"`
	// Every 是每隔几天(every_days,1–30)
	Every int `json:"every,omitempty"`
	// Days 是每周的星期几(weekly,0–6,0 是星期日)或每月的几号(monthly,1–31,短月按月末)
	Days []int `json:"days,omitempty"`
	// AirDelayHours、AirRetryHours、AirWindowDays 用在按播出时间:播出后多久开始搜(0 = 2 小时)、
	// 没找到时隔多久再搜(0 = 6 小时)、播出后几天里集中重试(0 = 7 天)
	AirDelayHours int `json:"air_delay_hours,omitempty"`
	AirRetryHours int `json:"air_retry_hours,omitempty"`
	AirWindowDays int `json:"air_window_days,omitempty"`
	// IntervalMinutes 是每隔几分钟搜一次(interval,30 分钟到 7 天),从上次搜索算起
	IntervalMinutes int `json:"interval_minutes,omitempty"`
	// Cron 是 cron 表达式(cron,分 时 日 月 星期;几条用分号或换行分开,到点的取最早的)
	Cron string `json:"cron,omitempty"`
}

Schedule 是追剧主动搜索的定时。Kind 为空时沿用设置里的全局间隔(升级以前的订阅都是它)。

func ScheduleOf

func ScheduleOf(sub *models.MediaSubscription) Schedule

ScheduleOf 读订阅的定时。

type Searcher

type Searcher interface {
	Search(ctx context.Context, q v2.MultiSiteSearchQuery) (*v2.MultiSiteSearchResult, error)
}

Searcher 是多站点搜索(生产环境是 CachedSearchOrchestrator)。

type SeasonDetail

type SeasonDetail struct {
	TMDBID       int                 `json:"tmdb_id"`
	Season       int                 `json:"season"`
	Name         string              `json:"name,omitempty"`
	AirDate      string              `json:"air_date,omitempty"`
	Subscription *SeasonSubscription `json:"subscription,omitempty"`
	Episodes     []SeasonEpisode     `json:"episodes"`
	Errors       []string            `json:"errors"`
}

SeasonDetail 是剧集一季的每一集。Errors 是没取到的部分(某个下载器的进度)。

type SeasonEpisode

type SeasonEpisode struct {
	Episode int    `json:"episode"`
	Name    string `json:"name,omitempty"`
	AirDate string `json:"air_date,omitempty"`
	// AirAt 是按播出时间追剧时这一集的播出时刻
	AirAt      *time.Time `json:"air_at,omitempty"`
	StillPath  string     `json:"still_path,omitempty"`
	Runtime    int        `json:"runtime,omitempty"`
	State      string     `json:"state"`
	Site       string     `json:"site,omitempty"`
	Version    string     `json:"version,omitempty"`
	Size       int64      `json:"size,omitempty"`
	Percent    float64    `json:"percent,omitempty"`
	ETASeconds int64      `json:"eta_seconds,omitempty"`
	Source     string     `json:"source,omitempty"`
	Server     string     `json:"server,omitempty"`
	OpenURL    string     `json:"open_url,omitempty"`
	// ServerIssue 是已入库、媒体服务器里却删了的问题(还开着的)
	ServerIssue *EpisodeIssue `json:"server_issue,omitempty"`
	// LibraryIssue 是已入库、库里的文件却不见了的问题(还开着的,见每天的巡检;Server 为空)
	LibraryIssue *EpisodeIssue `json:"library_issue,omitempty"`
}

SeasonEpisode 是一季里的一集:状态同按条目搜索(已入库、下载中、等版本、缺、没播;按播出时间追剧的,今天还没到播出时刻的写没播); 入库的带版本与体积,下载中的带进度。已入库的另带媒体服务器里的打开链接(服务器里有这一集时)或服务器里删了的问题; Source 是 server 的是算作已入库的集(整理记录里没有、开了「算作已入库」的服务器 Server 里有)。

type SeasonSubscription

type SeasonSubscription struct {
	ID               uint             `json:"id"`
	Status           string           `json:"status"`
	Follow           bool             `json:"follow"`
	Lock             *MediaSearchLock `json:"lock,omitempty"`
	Airtime          bool             `json:"airtime,omitempty"`
	SearchDelayHours int              `json:"search_delay_hours,omitempty"`
}

SeasonSubscription 是这一季的订阅:Airtime 为真时追剧按播出时间搜,SearchDelayHours 是播出后几小时开始搜。

type SeenVersion

type SeenVersion struct {
	Group      string   `json:"group"`
	Resolution string   `json:"resolution"`
	Episodes   []int    `json:"episodes"`
	Sites      []string `json:"sites"`
}

SeenVersion 是一个版本(制作组 + 分辨率)在这次搜索里能补上的缺集与站点。

type SeenVersions

type SeenVersions struct {
	At       string        `json:"at"`
	Versions []SeenVersion `json:"versions"`
}

SeenVersions 是最近一次搜索找到的版本,能补的集多的在前。

type Service

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

Service 是订阅服务。

func New

func New(cfg Config) *Service

New 建订阅服务;Start 以后才接 RSS 与定时搜索。

func (*Service) AddBlocks

func (s *Service) AddBlocks(ctx context.Context, in BlockInput) (*BlockResult, error)

AddBlocks 拉黑几个种子(见 BlockInput)。同一个种子对同一个条目已经拉黑过时改成这次的原因,不报错。 这个条目有订阅时在订阅的运行记录里记一笔。

func (*Service) AfterOrganize

func (s *Service) AfterOrganize(infoHash string)

AfterOrganize 是整理服务整理完一个下载器里的种子、有文件入库以后的回调(见 organize.Service.SetAfterOrganize): 不阻塞地交给后台循环,循环马上刷新订阅里这个种子,不等下一拍。队列满了丢掉,下一拍的刷新兜底。

func (*Service) AiredEpisodes

func (s *Service) AiredEpisodes(ctx context.Context, row *models.MediaSubscription) int

AiredEpisodes 是一个追剧这一季已播出的集数(按台账,没有台账时重建一次);读不到时为 0。

func (*Service) BangumiCalendar

func (s *Service) BangumiCalendar(ctx context.Context) ([]bangumi.CalendarDay, error)

BangumiCalendar 取 Bangumi 的每日放送(缓存 6 小时)。

func (*Service) BangumiToTMDB

func (s *Service) BangumiToTMDB(ctx context.Context, id int) (*BangumiMatch, error)

BangumiToTMDB 在 TMDB 上找番剧日历里的一部动画(只找剧集):先用去掉第几季的中文名、再用原名搜,在首播年份不晚于 这一季开播的下一年的动画里,名字(中文名或原名)完全相同的只有一个时用它;没有完全相同的、以这个名字开头(或名字以它 开头)的只有一个时也用它。拿不准或没搜到时返回 ErrNotFound(写明搜过的名字)。

func (*Service) BlockSubscriptionTorrent

func (s *Service) BlockSubscriptionTorrent(ctx context.Context, subID, rowID uint, in BlockTorrentInput) (*BlockResult, error)

BlockSubscriptionTorrent 是追剧详情里「不要这个种子」:按订阅的条目拉黑这个种子;种子还在下载时改成失败,它的集重新算缺的, 订阅在找资源时马上搜一次。已整理入库的不改(库里的文件不动)。下载器里的种子不在这里删(页面按用户的选择调删种接口)。

func (*Service) Blocks

func (s *Service) Blocks(ctx context.Context) ([]models.MediaTorrentBlock, error)

Blocks 列出全部拉黑的种子,新的在前。

func (*Service) Calendar

func (s *Service) Calendar(ctx context.Context, from, to string) (*Calendar, error)

Calendar 列出 from 到 to(YYYY-MM-DD,含两头,最多 62 天)里订阅的剧集播出的集与电影的上映。from 为空时从今天起,to 为空时列 7 天。

func (*Service) CreateSubscription

func (s *Service) CreateSubscription(ctx context.Context, in SubscriptionInput, source string) (*models.MediaSubscription, error)

CreateSubscription 按 TMDB 条目建订阅:取详情(名字、年份、IMDb、海报、别名),剧集取这一季的集数。 同一个条目的同一季已经订阅过时返回 ErrInvalid。

func (*Service) DeleteDoubanSource

func (s *Service) DeleteDoubanSource(ctx context.Context, id uint) error

DeleteDoubanSource 删除豆瓣来源与它见过的条目(建过的订阅留着)。

func (*Service) DeleteEpisodeRule

func (s *Service) DeleteEpisodeRule(ctx context.Context, id uint, group string) ([]models.MediaEpisodeRule, error)

DeleteEpisodeRule 删掉一个制作组的集号规则(group 为空时是对所有组的那条)。

func (*Service) DeleteItem

func (s *Service) DeleteItem(ctx context.Context, req DeleteRequest) (*DeleteResult, error)

DeleteItem 按请求删除(见 DeleteRequest):先处理订阅(删的过程中订阅不会把删掉的集当成缺的再去下),再删种子,再删库里的文件。 种子在删除锁里(同自动删种)现读下载器、重新算保护:受保护又没确认的不删(预览以后才变成受保护的也一样);不是这一部的不删。 每一步单独给结果,失败的不影响已经做完的。

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(ctx context.Context, id uint) error

DeleteProfile 删除质量档案:还有订阅、豆瓣来源在用或是默认档案时不删。

func (*Service) DeleteSubscription

func (s *Service) DeleteSubscription(ctx context.Context, id uint) error

DeleteSubscription 删除订阅与它下载过的种子记录(下载器里的种子与库里的文件不动)。

func (*Service) Discover

func (s *Service) Discover(ctx context.Context, kind string, f ExploreFilter, page int) (*ExplorePage, error)

Discover 按出品国家与类型发现 TMDB 上的电影或剧集(按热度排),标上已入库与已订阅。

func (*Service) DoubanItems

func (s *Service) DoubanItems(ctx context.Context, id uint) ([]models.MediaDoubanItem, error)

DoubanItems 是一个来源见过的条目(新的在前)。

func (*Service) DoubanSources

func (s *Service) DoubanSources(ctx context.Context) ([]DoubanSourceView, error)

DoubanSources 列出豆瓣来源。

func (*Service) Draft

func (s *Service) Draft(ctx context.Context, kind string, id, season int) (*SubscriptionDraft, error)

Draft 读新建订阅前要显示的条目:名字、年份、一共几季与这一季的集数(剧集的 season 为 0 时取最新一季)、是不是动画、 媒体库选「自动」时整理会选到的库,以及这一季是不是已经在追。只读,不写库;条目与季在 TMDB 上没有时报错,同新建订阅。

func (*Service) EpisodeGroups

func (s *Service) EpisodeGroups(ctx context.Context, tvID int) ([]tmdb.EpisodeGroupSummary, error)

EpisodeGroups 是一部剧在 TMDB 上的剧集组(追剧的「修改」里选)。没有时是空的。

func (*Service) EpisodeRules

func (s *Service) EpisodeRules(ctx context.Context, id uint) ([]models.MediaEpisodeRule, error)

EpisodeRules 列出一个追剧的集号规则。

func (*Service) Episodes

func (s *Service) Episodes(ctx context.Context, id uint) ([]EpisodeState, error)

Episodes 是一个追剧每一集的情况(重建一次台账)。

func (*Service) Explore

func (s *Service) Explore(ctx context.Context, kind, list string, page int, query string) (*ExplorePage, error)

Explore 取 TMDB 的一个列表(见 tmdb.HasList)或搜索结果(搜索只有一页),标上已入库(整理记录里有)与已订阅。 按条件发现用 Discover。

func (*Service) FetchDouban

func (s *Service) FetchDouban(ctx context.Context, id uint) (int, error)

FetchDouban 立即拉一次豆瓣来源,返回新建的订阅数。这个来源正在拉取时返回 ErrBusy。

func (*Service) FollowLine

func (s *Service) FollowLine(ctx context.Context, day, label string) string

FollowLine 是每日战报里追剧的那一行:day 那天播出的集(还没到播出时刻的不算)与其中已入库的,label(「今日」「昨日」)写在行首。 订阅总开关关着、TMDB 读不到或那天没有播出的集时为空串。

func (*Service) GlobalBlocks

func (s *Service) GlobalBlocks(ctx context.Context) (map[string]models.MediaTorrentBlock, error)

GlobalBlocks 是对所有条目拉黑的种子(关键字搜索里标「已拉黑」),按 BlockKey 查。

func (*Service) HomeCalendar

func (s *Service) HomeCalendar(ctx context.Context) (*HomeCalendar, error)

HomeCalendar 列出今天播出的集与上映的电影(带上首页卡片要写的)和明天起 6 天的。

func (*Service) Item

func (s *Service) Item(ctx context.Context, kind string, id int) (*ItemDetail, error)

Item 是一部电影或剧集的详情(见 ItemDetail)。TMDB 上没有这个条目时返回 tmdb.ErrNotFound。

func (*Service) ItemDownloadDir

func (s *Service) ItemDownloadDir(ctx context.Context, kind string, tmdbID, season int, dlID uint, base string) (string, error)

ItemDownloadDir 是按条目推送时「按条目建子目录」的保存路径:base(空的是下载器的默认保存路径)加上按订阅设置里的模板起的子目录。 读不到下载器的默认保存路径、算不出子目录名时返回错误(调用方照原来的保存路径推送并写明)。

func (*Service) LibrarySeasons

func (s *Service) LibrarySeasons(ctx context.Context, tmdbID int) (map[int]LibrarySeason, error)

LibrarySeasons 是一部剧库里每一季的情况(按整理记录;季号 → 情况,没有入库的季不在里面)。

func (*Service) MediaFor

func (s *Service) MediaFor(ctx context.Context, downloaderID uint, hash string) (organize.MediaHint, bool, error)

MediaFor 是订阅的条目与媒体库(给整理入库用,见 organize.MediaFor):按种子的编号找订阅推送或认领的种子(任何状态, 同一个编号在几个下载器里时先看这个下载器的,再取最新的),回那个订阅的条目与媒体库(库为 0 是没指定)。

func (*Service) MovieLibrary

func (s *Service) MovieLibrary(ctx context.Context, tmdbID int) (LibraryMovie, error)

MovieLibrary 是库里这部电影的情况(按整理记录)。

func (*Service) Offer

func (s *Service) Offer(site string, item v2.TorrentItem)

Offer 把 RSS 拉到的种子交给订阅(不阻塞;队列满时丢掉,主动搜索还会找到)。

func (*Service) OrganizeTorrent

func (s *Service) OrganizeTorrent(ctx context.Context, subID, torrentID uint) (*organize.Result, error)

OrganizeTorrent 重新整理订阅下载的一个种子(整季包与单集一样):按订阅的条目与媒体库整理(不靠识别, 订阅知道它下载的是哪部剧哪一季),已经整理好的文件不动。整理完马上更新种子的状态,运行记录里记一条。

func (*Service) PreviewDelete

func (s *Service) PreviewDelete(ctx context.Context, in DeleteSelector) (*DeletePreview, error)

PreviewDelete 是删除的预览(见 DeletePreview):下载器的种子列表现读,不用缓存。

func (*Service) Profiles

func (s *Service) Profiles(ctx context.Context) ([]Profile, error)

Profiles 列出质量档案。

func (*Service) RemoveBlock

func (s *Service) RemoveBlock(ctx context.Context, id uint) error

RemoveBlock 把一个种子移出黑名单。

func (*Service) RescrapeTorrent

func (s *Service) RescrapeTorrent(ctx context.Context, subID, torrentID uint) (*organize.RescrapeResult, error)

RescrapeTorrent 重新刮削订阅下载的一个种子整理进的电影或剧集(同一部在这个媒体库里的都刮削)。

func (*Service) Runs

func (s *Service) Runs(ctx context.Context, id uint, limit, offset int) (*RunPage, error)

Runs 列出一个订阅的运行记录(新的在前)。

func (*Service) SaveDoubanSource

func (s *Service) SaveDoubanSource(ctx context.Context, id uint, in DoubanSourceInput) (*models.MediaDoubanSource, error)

SaveDoubanSource 新建(id 为 0)或修改豆瓣来源。新建与重新启用的马上拉一次。

func (*Service) SaveEpisodeRule

func (s *Service) SaveEpisodeRule(ctx context.Context, id uint, in EpisodeRuleInput) ([]models.MediaEpisodeRule, error)

SaveEpisodeRule 设一个制作组的集号规则(同一个组已有时替换),然后重建台账、马上搜一次。

func (*Service) SaveProfile

func (s *Service) SaveProfile(ctx context.Context, id uint, in ProfileInput) (Profile, error)

SaveProfile 新建(id 为 0)或修改质量档案。

func (*Service) SaveSettings

func (s *Service) SaveSettings(ctx context.Context, in Settings) (Settings, error)

SaveSettings 保存订阅设置。

func (*Service) SchedulePreview

func (s *Service) SchedulePreview(ctx context.Context, sc Schedule, mediaType string, anchor time.Time, n int) ([]time.Time, error)

SchedulePreview 是一个定时接下来几次主动搜索的时间:页面上改定时时给人看(不算随机偏移与搜索本身花的时间, 两次之间至少隔 30 分钟,和真正排的一样)。按播出时间的要看每一集的播出日期,这里不算,返回空; 没有定时的按设置里的全局间隔。anchor 是每隔几天的起点(订阅建立的时间,新建的是现在)。

func (*Service) SearchMedia

func (s *Service) SearchMedia(ctx context.Context, in MediaSearchInput) (*MediaSearchResult, error)

SearchMedia 按条目搜索(见 MediaSearchInput)。这一季已经订阅时按订阅本身对(别名、集号规则、标题关键词),没有时按 TMDB 上的条目。

func (*Service) SearchNow

func (s *Service) SearchNow(ctx context.Context, id uint) (string, error)

SearchNow 立即搜索一个订阅,返回结果说明。

func (*Service) SearchSoon

func (s *Service) SearchSoon(ctx context.Context, id uint) error

SearchSoon 让一个在找的订阅尽快主动搜一次:下次搜索的时间改成现在,后台每分钟看一次到期的搜索(订阅的总开关关着时不搜)。 不在找(暂停、待确认、已完成)时返回 ErrInvalid。

func (*Service) SeasonItem

func (s *Service) SeasonItem(ctx context.Context, id, n int) (*SeasonDetail, error)

SeasonItem 是剧集一季的每一集(见 SeasonDetail)。这一季订阅了时按订阅(集号规则、有效集数、在下载的种子、等版本), 没有时按 TMDB 上的条目拼一份(同按条目搜索,不写库)。

func (*Service) SetMonitored

func (s *Service) SetMonitored(ctx context.Context, id uint, on, searchNow bool) (*models.MediaSubscription, error)

SetMonitored 按 Servarr 的 monitored 打开或暂停订阅。打开:没在找的(暂停、待确认、已完成)改成在找,searchNow 为真时马上搜, 为假时按定时排下次搜索;已经在找的 searchNow 为真时提前到现在。关上:只暂停在找的,已完成与待确认的不动。

func (*Service) SetProfile

func (s *Service) SetProfile(ctx context.Context, id, profileID uint) (*models.MediaSubscription, error)

SetProfile 改订阅的质量档案(0 是订阅设置里的默认档案,档案要存在)。改了时在找的订阅尽快搜一次(新的条件可能对得上了)。

func (*Service) SetReviewer

func (s *Service) SetReviewer(r Reviewer)

SetReviewer 接上 AI 复核(订阅服务启动以后也能接;nil 断开)。

func (*Service) SetStatus

func (s *Service) SetStatus(ctx context.Context, id uint, status string) (*models.MediaSubscription, error)

SetStatus 暂停、恢复或确认订阅:status 要是 active 或 paused。

func (*Service) Settings

func (s *Service) Settings(ctx context.Context) (Settings, error)

Settings 读订阅设置(没有保存过时是默认值)。

func (*Service) SkipEpisode

func (s *Service) SkipEpisode(ctx context.Context, id uint, n int, skip bool) ([]EpisodeState, error)

SkipEpisode 跳过(skip 为真)或重新要一集:跳过的集不算缺,也不影响完成。

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Start 启动后台:处理 RSS 交来的种子,每分钟看一次到期的搜索、下载中的种子与豆瓣想看。

func (*Service) Stop

func (s *Service) Stop()

Stop 停掉后台并等它退出。

func (*Service) Subscription

func (s *Service) Subscription(ctx context.Context, id uint) (*SubscriptionDetail, error)

Subscription 是一个订阅的详情。

func (*Service) SubscriptionRow

func (s *Service) SubscriptionRow(ctx context.Context, id uint) (models.MediaSubscription, error)

SubscriptionRow 是一条订阅(不算进度)。

func (*Service) Subscriptions

func (s *Service) Subscriptions(ctx context.Context, q SubscriptionQuery) ([]SubscriptionView, error)

Subscriptions 列出订阅(新的在前),带进度。

func (*Service) SubscriptionsOf

func (s *Service) SubscriptionsOf(ctx context.Context, kind string, tmdbID int) ([]models.MediaSubscription, error)

SubscriptionsOf 是一类订阅(电影或剧集)的全部行,按编号排;tmdbID 大于 0 时只要这个条目的。不算进度。

func (*Service) Tick

func (s *Service) Tick(ctx context.Context)

Tick 做一轮后台工作:下载中的种子入库了没有、订阅完成了没有、到期的主动搜索与豆瓣想看、到点的今日更新。总开关关着时什么都不做。

func (*Service) Today

func (s *Service) Today(ctx context.Context) (*Calendar, error)

Today 是今天的日历。

func (*Service) UnknownDownloader

func (s *Service) UnknownDownloader(ctx context.Context, id uint) (bool, error)

UnknownDownloader 是给的下载器编号不存在(0 是用设置里的,不算):App API 与 MCP 改订阅的下载器时先查一下。

func (*Service) UnknownSites

func (s *Service) UnknownSites(names []string) []string

UnknownSites 是给的站点里没有注册的那些(没配置、没启用或不认识的站点名):App API 与 MCP 改订阅的站点时先查一下。 按站点查找函数判断,没配置时按站点名单;两个都没配置时不查。

func (*Service) UnlockEpisode

func (s *Service) UnlockEpisode(ctx context.Context, id uint, n int, unlock bool) ([]EpisodeState, error)

UnlockEpisode 让一集不受版本锁限制(unlock 为真;锁住的版本久等不到时用),并马上搜一次;unlock 为假时恢复。

func (*Service) UpdateSubscription

func (s *Service) UpdateSubscription(ctx context.Context, id uint, in SubscriptionInput) (*models.MediaSubscription, error)

UpdateSubscription 修改订阅(条目与季不能改)。

type Settings

type Settings struct {
	Enabled             bool     `json:"enabled"`
	SearchIntervalHours int      `json:"search_interval_hours"`
	SearchSkipSites     []string `json:"search_skip_sites"`
	DefaultProfileID    uint     `json:"default_profile_id"`
	DefaultDownloaderID uint     `json:"default_downloader_id"`
	NotifyChannels      []uint   `json:"notify_channels"`
	UpgradeOld          string   `json:"upgrade_old"`
	// TodayEnabled 为真时每天 TodayTime 把今天播出的集推送到 TodayChannels(空的用 NotifyChannels)
	TodayEnabled  bool   `json:"today_enabled"`
	TodayTime     string `json:"today_time"`
	TodayChannels []uint `json:"today_channels"`
	// SubdirEnabled 为真时下载时按条目建子目录:订阅推送的种子放进保存路径(没有时是下载器的默认保存路径)下按 SubdirTemplate
	// 起名的一级子目录(见 subdir.go);SubdirTemplate 空着保存时按 DefaultSubdirTemplate
	SubdirEnabled  bool   `json:"subdir_enabled"`
	SubdirTemplate string `json:"subdir_template"`
	// AIReviewEnabled 为真时推送一个候选以前让 AI 助手的模型复核是不是要的条目(见 review.go);AIReviewScope 是
	// ReviewByName(只复核按名字对上的,默认)或 ReviewAll
	AIReviewEnabled bool   `json:"ai_review_enabled"`
	AIReviewScope   string `json:"ai_review_scope"`
	// UnlockAfterDays 是追剧开着版本锁时,一集等锁住的版本满几天以后改用别的版本(见 autoUnlock);0 是一直等
	UnlockAfterDays int `json:"unlock_after_days"`
}

Settings 是订阅的设置。

type ShareRef

type ShareRef struct {
	Hash string `json:"hash"`
	Name string `json:"name"`
}

ShareRef 是和一个种子共用数据的种子(同一台下载器)。

type SitesFunc

type SitesFunc func(name string) (v2.Site, bool)

SitesFunc 按站点名取共享的站点实例(下载种子文件用,与搜索、登录探测共用限速)。

type SubscriptionDetail

type SubscriptionDetail struct {
	SubscriptionView
	// TorrentList 是下载过的种子,带上每个文件整理、刮削得怎样(见 torrents.go)
	TorrentList []TorrentView `json:"torrent_list"`
}

SubscriptionDetail 是订阅详情:订阅、进度与下载过的种子。

type SubscriptionDraft

type SubscriptionDraft struct {
	MediaType string `json:"media_type"`
	TMDBID    int    `json:"tmdb_id"`
	// Season 是这一季:请求的 0 换成最新一季;电影是 0
	Season int `json:"season"`
	// Seasons 是一共几季,TotalEpisodes 是这一季的集数(电影都是 0)
	Seasons       int    `json:"seasons"`
	TotalEpisodes int    `json:"total_episodes"`
	Title         string `json:"title"`
	OriginalTitle string `json:"original_title"`
	// Year 是年份(剧集是这一季的)
	Year       int    `json:"year"`
	PosterPath string `json:"poster_path"`
	// Anime 是 TMDB 类型里有没有「动画」
	Anime bool `json:"anime"`
	// AutoLibraryID 是媒体库选「自动」时整理会选到的库(选法同整理,见 models.ChooseLibrary);没有能用的库时是 0
	AutoLibraryID uint `json:"auto_library_id"`
	// SubscriptionID 是这一季已有的订阅;没有时是 0
	SubscriptionID uint `json:"subscription_id"`
}

SubscriptionDraft 是新建订阅前给编辑页看的条目(只读,不写库)。

type SubscriptionInput

type SubscriptionInput struct {
	MediaType    string   `json:"media_type"`
	TMDBID       int      `json:"tmdb_id"`
	Season       int      `json:"season"`
	ProfileID    uint     `json:"profile_id"`
	Sites        []string `json:"sites"`
	DownloaderID uint     `json:"downloader_id"`
	Category     string   `json:"category"`
	Tags         string   `json:"tags"`
	SavePath     string   `json:"save_path"`
	Upgrade      bool     `json:"upgrade"`
	// Pending 为真时建成待确认
	Pending bool `json:"pending"`
	// Paused 为真时建成暂停(Servarr 兼容入口:Seerr 加了不监控的条目);只在新建时用,接口不收
	Paused bool `json:"-"`
	// Deferred 为真时建好以后不马上搜,下次搜索按定时排(Servarr 兼容入口:Seerr 设了不自动搜索);只在新建时用,接口不收
	Deferred bool `json:"-"`
	// IncludeKeywords、ExcludeKeywords 是标题的包含词与排除词(见 models.MediaSubscription):不传时新建为空、修改时不变
	IncludeKeywords *string `json:"include_keywords,omitempty"`
	ExcludeKeywords *string `json:"exclude_keywords,omitempty"`

	// Schedule 是主动搜索的定时(kind 为空沿用全局间隔)
	Schedule *Schedule `json:"schedule,omitempty"`
	// LockVersion 是版本锁;LockGroup、LockResolution 改锁住的版本(改完都是空串是清掉:不再按库里已有的文件定,
	// 下一个推送成功的版本成为新锁)
	LockVersion    *bool   `json:"lock_version,omitempty"`
	LockGroup      *string `json:"lock_group,omitempty"`
	LockResolution *string `json:"lock_resolution,omitempty"`
	// StartEpisode 是从第几集开始追(0 与 1 是整季)
	StartEpisode     *int  `json:"start_episode,omitempty"`
	FollowNextSeason *bool `json:"follow_next_season,omitempty"`
	// LibraryID 是整理进哪个媒体库(0 按类型自动选)
	LibraryID *uint `json:"library_id,omitempty"`
	// TotalEpisodes 是手动填的这一季的集数:大于 0 时以它为准,0 改回按 TMDB
	TotalEpisodes *int `json:"total_episodes,omitempty"`
	// EpisodeGroupID 是种子按 TMDB 的哪个剧集组写季集(见 models.MediaSubscription):空串是不用剧集组,要是这部剧的剧集组
	EpisodeGroupID *string `json:"episode_group_id,omitempty"`
	// FromTorrent 是「从这个种子开始追」:只在新建时用
	FromTorrent *FromTorrent `json:"from_torrent,omitempty"`
}

SubscriptionInput 是新建或修改订阅的内容。新建时要条目(类型、TMDB 编号;剧集的季可以省略或为 0,取最新一季); 修改时这几项不能改。

type SubscriptionQuery

type SubscriptionQuery struct {
	Status  string
	Keyword string
}

SubscriptionQuery 是订阅列表的筛选。

type SubscriptionView

type SubscriptionView struct {
	models.MediaSubscription
	Sites    []string  `json:"sites"`
	Schedule Schedule  `json:"schedule"`
	Progress *Progress `json:"progress,omitempty"`
	Torrents int       `json:"torrents"`
	// SeenVersions 是最近一次搜索找到的、能补上缺的集的版本(剧集;没搜过时没有)
	SeenVersions *SeenVersions `json:"seen_versions,omitempty"`
}

SubscriptionView 是订阅加上进度与已下载的种子数。

type TodayItem

type TodayItem struct {
	CalendarEntry
	BackdropPath string  `json:"backdrop_path,omitempty"`
	Version      string  `json:"version,omitempty"`
	Site         string  `json:"site,omitempty"`
	Percent      float64 `json:"percent,omitempty"`
	ETASeconds   int64   `json:"eta_seconds,omitempty"`
	Lock         string  `json:"lock,omitempty"`
	OpenURL      string  `json:"open_url,omitempty"`
}

TodayItem 是首页「今天播出」的一项:日历的一项(见 CalendarEntry),另加

  • BackdropPath:没有剧照时用的背景图(这一部的);
  • Version:已入库的版本(按整理记录的种子名解析,例如 2160p HHWEB);
  • Site、Percent、ETASeconds:下载中的站点、进度(0–100)与预计还要多久(秒,不知道时为 0);
  • Lock:等版本时锁住的版本(例如 HHWEB 2160p);
  • OpenURL:已入库、媒体服务器里有这一集(电影是这一部)时,在服务器里打开它的链接。

type TorrentFile

type TorrentFile struct {
	ID           uint       `json:"id"`
	Name         string     `json:"name"`
	Episode      int        `json:"episode,omitempty"`
	EpisodeEnd   int        `json:"episode_end,omitempty"`
	Status       string     `json:"status"`
	Message      string     `json:"message,omitempty"`
	ScrapeStatus string     `json:"scrape_status,omitempty"`
	ScrapeNote   string     `json:"scrape_note,omitempty"`
	NextRetryAt  *time.Time `json:"next_retry_at,omitempty"`
	// Retrying 是整理队列里正在重试它
	Retrying bool `json:"retrying,omitempty"`
}

TorrentFile 是种子里一个视频文件的整理记录。

type TorrentKey

type TorrentKey struct {
	DownloaderID uint   `json:"downloader_id"`
	Hash         string `json:"hash"`
}

TorrentKey 认一个下载器里的种子:(下载器编号, hash)。同一个 hash 在两台下载器上是两个种子。

type TorrentView

type TorrentView struct {
	models.MediaSubscriptionTorrent
	// Files 是这个种子的整理记录(每个视频文件一条;还没整理过时为空)
	Files []TorrentFile `json:"files"`
	// CanOrganize 是能「重新整理」:有整理没成(失败、跳过)且不在自动重试的文件,或者种子标成了失败、还没有整理记录
	CanOrganize bool `json:"can_organize"`
	// CanRescrape 是能「重新刮削」:有整理好的文件
	CanRescrape bool `json:"can_rescrape"`
	// Blocked 是这个种子对订阅的条目拉黑了(「不要这个种子」或在搜索里点了「不要」)
	Blocked bool `json:"blocked,omitempty"`
}

TorrentView 是订阅下载过的一个种子,带上它整理进媒体库的情况。

type Verdict

type Verdict struct {
	Score  int
	Reject string
}

Verdict 是一个候选种子按质量档案的结果:Reject 不为空时不要(写明原因),否则 Score 是分数。

Jump to

Keyboard shortcuts

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