Documentation
¶
Overview ¶
Package home 是首页(媒体中心 M8):同时取各块的数据,一块出错不影响别的;另算待处理、存储与状态行。 各块的数据由各自的包算(今天播出在 subscribe、最近入库与继续观看在 organize),这里只编排。
Index ¶
Constants ¶
const ( DiskDownload = "download" DiskLibrary = "library" )
存储里一块盘是什么(Disk.Kind)。
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 的顺序。
const ( ToneDanger = "dang" ToneWarn = "warn" TonePrimary = "primary" ToneInfo = "info" )
chip 的颜色(TodoGroup.Tone),同界面的语义色。
const TargetDrawer = "drawer"
TargetDrawer 是不去别的页面、在首页的抽屉里处理的那几类(媒体服务器里删了的与库文件不见了:每行有「处理」「忽略」)。
Variables ¶
This section is empty.
Functions ¶
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 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 ¶
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 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 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 是这一行说的条目(「处理」打开它的删除弹窗、「看版本」打开它的详情)。