home

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: 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 home 是首页(媒体中心 M8):同时取各块的数据,一块出错不影响别的;另算待处理、存储与状态行。 各块的数据由各自的包算(今天播出在 subscribe、最近入库与继续观看在 organize),这里只编排。

Index

Constants

View Source
const (
	DiskDownload = "download"
	DiskLibrary  = "library"
)

存储里一块盘是什么(Disk.Kind)。

View Source
const (
	TodoOrganizeFailed   = "organize_failed"
	TodoRecognize        = "recognize"
	TodoWaitingVersion   = "waiting_version"
	TodoAttendanceFailed = "attendance_failed"
	TodoLoginFailed      = "login_failed"
	TodoServerRemoved    = "server_removed"
	TodoLibraryMissing   = "library_missing"
	TodoBackup           = "backup"
	TodoHealth           = "health"
)

待处理的类别(TodoGroup.Kind、TodoItem.Kind),也是首页上 chip 的顺序。

View Source
const (
	ToneDanger  = "dang"
	ToneWarn    = "warn"
	TonePrimary = "primary"
	ToneInfo    = "info"
)

chip 的颜色(TodoGroup.Tone),同界面的语义色。

View Source
const TargetDrawer = "drawer"

TargetDrawer 是不去别的页面、在首页的抽屉里处理的那几类(媒体服务器里删了的与库文件不见了:每行有「处理」「忽略」)。

Variables

This section is empty.

Functions

func Collect

func Collect(ctx context.Context, parts []Part, timeout time.Duration) map[string]Block

Collect 同时取各块,每块最多等 timeout:出错、超时与意外(panic)写进那一块的 Error(去掉凭证),别的块照样给。

Types

type BackupLine

type BackupLine struct {
	Enabled  bool       `json:"enabled"`
	LastAt   *time.Time `json:"last_at,omitempty"`
	LastOKAt *time.Time `json:"last_ok_at,omitempty"`
	Error    string     `json:"error,omitempty"`
	Late     bool       `json:"late"`
	Days     int        `json:"days"`
}

BackupLine 是状态行的备份:Late 同待处理(开着定时备份时,最近一次失败或两天没成功),Days 是最近一次成功距今几天(-1 是没成功过)。

type Block

type Block struct {
	Data  any    `json:"data"`
	Error string `json:"error,omitempty"`
}

Block 是首页的一块:Data 是这一块的数据,Error 是没取到的原因(别的块照样给)。

type Disk

type Disk struct {
	Kind  string `json:"kind"`
	Label string `json:"label"`
	Path  string `json:"path"`
	Free  uint64 `json:"free"`
	Total uint64 `json:"total"`
	Low   bool   `json:"low"`
	Error string `json:"error,omitempty"`
}

Disk 是首页存储里的一块盘:Label 写它是哪几个目录(下载盘 · qb、媒体库 · 电影),Path 是第一个目录。 Total 为 0 是不知道总量(下载器只报剩余);Low 同体检的警告线(剩不到 5% 或 20 GB);Error 是取不到的原因。

func Storage

func Storage(downloads []DownloadDir, libs []LibraryDir) []Disk

Storage 列出下载盘与媒体库所在的盘,同一块盘(同一个设备)只列一次。pt-tools 读得到下载目录时按本机读到的算 (能知道总量);读不到时用下载器报的剩余空间。

type DownloadDir

type DownloadDir struct {
	Downloader string
	Path       string
	Local      string
	Free       int64
	Err        error
}

DownloadDir 是一台下载器的默认保存路径:Path 是下载器里看到的,Local 是按路径映射换成 pt-tools 里看到的 (没有映射时同 Path);Free 是下载器报的剩余空间(小于 0 是没报),Err 是取不到的原因。

type HealthLine

type HealthLine struct {
	At      time.Time `json:"at"`
	OK      int       `json:"ok"`
	Warn    int       `json:"warn"`
	Fail    int       `json:"fail"`
	Skip    int       `json:"skip"`
	Problem string    `json:"problem,omitempty"`
}

HealthLine 是状态行的体检:上一次体检的时间与各状态的项数;Problem 是第一项失败(没有时第一项提醒)的标题与说明。

type LibraryDir

type LibraryDir struct {
	Name string
	Path string
}

LibraryDir 是一个媒体库的目录。

type Part

type Part struct {
	Name string
	Get  func(ctx context.Context) (any, error)
}

Part 是要取的一块。

type ServerLine

type ServerLine struct {
	ID         uint       `json:"id"`
	Name       string     `json:"name"`
	Kind       string     `json:"kind"`
	Version    string     `json:"version,omitempty"`
	Online     bool       `json:"online"`
	Error      string     `json:"error,omitempty"`
	IndexedAt  *time.Time `json:"indexed_at,omitempty"`
	IndexError string     `json:"index_error,omitempty"`
	Movies     int        `json:"movies"`
	Series     int        `json:"series"`
	Episodes   int        `json:"episodes"`
	OpenURL    string     `json:"open_url,omitempty"`
}

ServerLine 是状态行的一台媒体服务器:连不连得上与版本(现测,最多等 5 秒)、索引上次同步的时间与条目数。 OpenURL 是服务器网页的地址(「打开」)。

type Status

type Status struct {
	Health  *HealthLine  `json:"health"`
	Backup  *BackupLine  `json:"backup"`
	Servers []ServerLine `json:"servers"`
}

Status 是首页 NAS 状态最下面的几行:体检、备份、媒体服务器。

func BuildStatus

func BuildStatus(ctx context.Context, in StatusInput) (*Status, error)

BuildStatus 算状态行。媒体服务器是启用的那几台,几台同时测。

type StatusInput

type StatusInput struct {
	DB      *gorm.DB
	Now     time.Time
	Health  *health.Report
	Backup  func() (health.BackupState, error)
	Test    func(ctx context.Context, srv models.MediaServer) (health.ServerInfo, error)
	HomeURL func(srv models.MediaServer) string
}

StatusInput 是算状态行要用的:Health 是上一次体检(没体检过时为 nil);Test 测一台媒体服务器(同体检); HomeURL 是一台服务器网页的地址。

type Todo

type Todo struct {
	Groups []TodoGroup `json:"groups"`
	Items  []TodoItem  `json:"items"`
}

Todo 是首页的待处理:每类一组,另给抽屉里的各行(每类最多 20 行)。都没有时两个都是空的。

func BuildTodo

func BuildTodo(ctx context.Context, in TodoInput) (*Todo, error)

BuildTodo 算首页的待处理(只读库,不发请求):整理失败(不在自动重试的)、识别不出、等版本的集、今天签到失败的站点、 登录探测失败的站点、媒体服务器里删了的、库文件不见了、备份没成功、体检失败的项。

type TodoGroup

type TodoGroup struct {
	Kind   string `json:"kind"`
	Count  int    `json:"count"`
	Label  string `json:"label"`
	Target string `json:"target"`
	Tone   string `json:"tone"`
}

TodoGroup 是待处理的一类:首页上的一个 chip,点了去 Target(带着筛选的页面,或者 drawer)。

type TodoInput

type TodoInput struct {
	DB     *gorm.DB
	Now    time.Time
	Backup func() (health.BackupState, error)
	Health *health.Report
}

TodoInput 是算待处理要用的:Backup 是备份的设置与最近一次的结果,Health 是上一次体检(没体检过时为 nil)。

type TodoItem

type TodoItem struct {
	Kind      string `json:"kind"`
	Title     string `json:"title"`
	Detail    string `json:"detail,omitempty"`
	Target    string `json:"target,omitempty"`
	IssueIDs  []uint `json:"issue_ids,omitempty"`
	MediaType string `json:"media_type,omitempty"`
	TMDBID    int    `json:"tmdb_id,omitempty"`
	Season    int    `json:"season,omitempty"`
	Episode   int    `json:"episode,omitempty"`
	// Episodes 是问题说的那几集(剧集;有说整季的问题时为空,删除弹窗按整季)
	Episodes []int `json:"episodes,omitempty"`
}

TodoItem 是待处理抽屉里的一行。IssueIDs 是媒体服务器里删了的与库文件不见了的问题(「忽略」把它们都忽略掉); MediaType 到 Episode 是这一行说的条目(「处理」打开它的删除弹窗、「看版本」打开它的详情)。

Jump to

Keyboard shortcuts

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