Documentation
¶
Index ¶
- func AppKeyPrefix(plain string) string
- func DecryptAppKey(secret string) (string, error)
- func EncryptAppKey(plain string) (string, error)
- func FetchFileReader(ctx context.Context, vfsPath string) io.ReadCloser
- func FillMusicFromLocal(ctx context.Context, item *model.MediaItem)
- func GenerateStrmForItems(ctx context.Context, items []model.MediaItem, opts StrmOptions) (int, error)
- func GenerateStrmForType(ctx context.Context, mediaType model.MediaType, scanPathID uint, ...) (int, error)
- func GetAPIRoot() string
- func GetProgress(mediaType model.MediaType) model.MediaScanProgress
- func GetSupportedExts(mediaType model.MediaType) []string
- func HashToken(token string) string
- func MatchSubsonicToken(password, salt, token string) bool
- func MediaItemFolder(item *model.MediaItem) string
- func NewAppKeyPlain() (string, error)
- func NewDeviceToken() (string, error)
- func RenderStrmContent(tpl, apiRoot, rawPath string) string
- func ScanMedia(cfg *model.MediaConfig)
- func ScanMediaPath(sp *model.MediaScanPath)
- func SetAPIRoot(u string)
- func SubsonicToken(password, salt string) string
- func TriggerStrmOnScan(mediaType model.MediaType, apiRoot string)
- type EpisodeInfo
- type MusicTag
- type ScanProgress
- type StrmOptions
- type StrmTarget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchFileReader ¶
func FetchFileReader(ctx context.Context, vfsPath string) io.ReadCloser
FetchFileReader 通过 VFS 路径获取文件内容流(用于刮削器读取文件内容) 优先使用 RangeReader 直接读取(本地存储无需 HTTP),失败时回退到 HTTP URL 返回 nil 表示无法获取(不影响主流程)
func FillMusicFromLocal ¶
FillMusicFromLocal 在刮削前/失败时,使用音乐文件本身的元数据(ID3 / Vorbis Comment) 以及同目录 .lrc 歌词,**只填充 item 中为空的字段**。
适用场景:
- 用户清空刮削后重新刮削,原本由扫描阶段填入的本地数据(封面/歌词等)已丢失
- 在线刮削失败,退而求其次用文件本地信息补全
行为:
- is_folder=true 的合并文件夹模式:使用 episodes 中第一首音乐文件读取
- is_folder=false:使用 folder_path/file_name 直接读取
错误以静默忽略为主——本地兜底失败不应阻塞主流程。
func GenerateStrmForItems ¶
func GenerateStrmForItems(ctx context.Context, items []model.MediaItem, opts StrmOptions) (int, error)
GenerateStrmForItems 为一组条目生成 STRM 文件,返回写入数量
func GenerateStrmForType ¶
func GenerateStrmForType(ctx context.Context, mediaType model.MediaType, scanPathID uint, opts StrmOptions) (int, error)
GenerateStrmForType 按媒体类型(可选扫描路径)批量生成 STRM
func GetProgress ¶
func GetProgress(mediaType model.MediaType) model.MediaScanProgress
GetProgress 获取扫描进度
func GetSupportedExts ¶
GetSupportedExts 获取指定媒体类型支持的扩展名列表
func MatchSubsonicToken ¶
MatchSubsonicToken 校验客户端提交的 t 是否匹配
func NewAppKeyPlain ¶
NewAppKeyPlain 生成一个新的应用密钥明文,格式:olmp_<40 位随机串>
func RenderStrmContent ¶
RenderStrmContent 渲染 .strm 内容(单行 URL)
func SubsonicToken ¶
SubsonicToken 计算 Subsonic 的 t = md5(password + salt)
func TriggerStrmOnScan ¶
TriggerStrmOnScan 扫描结束后按需异步生成 STRM
Types ¶
type MusicTag ¶
type MusicTag struct {
Title string // TIT2
Artist string // TPE1
Album string // TALB
AlbumArtist string // TPE2
TrackNumber int // TRCK
Year string // TYER / TDRC
Genre string // TCON
CoverData []byte // 封面图片原始字节(APIC / PICTURE)
CoverMIME string // 封面图片 MIME 类型(如 image/jpeg)
Lyrics string // 歌词内容(LRC 文本或纯文本):来自 USLT / SYLT / Vorbis LYRICS
}
MusicTag 音频文件标签信息
func ParseFLACVorbisComment ¶
ParseFLACVorbisComment 从 io.Reader 中解析 FLAC 文件的 Vorbis Comment 元数据 FLAC 格式:4字节魔数 "fLaC" + 若干 METADATA_BLOCK METADATA_BLOCK:1字节(最高位=是否最后块, 低7位=块类型) + 3字节长度 + 数据 块类型 4 = VORBIS_COMMENT
type ScanProgress ¶
type ScanProgress struct {
Running bool
Total int
Done int
// Skipped 入库被跳过的条目数(典型原因:目录/文件名超过唯一索引列长度上限)。
// 以前只在日志里打一条 Warn,用户完全看不到漏扫了多少条。
Skipped int
Message string
Error string
// contains filtered or unexported fields
}
ScanProgress 扫描进度(全局,按媒体类型维护)
type StrmOptions ¶
type StrmOptions struct {
APIRoot string // 站点地址前缀,例如 https://example.com
Template string // 内容模板
Overwrite bool // 是否覆盖已存在文件
SameDir bool // 是否与媒体文件同目录(同名 .strm)
OutputPath string // 输出目录(VFS 路径,仅 SameDir=false 时使用)
}
StrmOptions STRM 生成参数
func DefaultStrmOptions ¶
func DefaultStrmOptions(apiRoot string) StrmOptions
DefaultStrmOptions 从设置中读取 STRM 参数
type StrmTarget ¶
type StrmTarget struct {
RelPath string // 相对输出目录的路径
RawPath string // 对应媒体文件的 VFS 路径
SameDirPath string // 与媒体文件同目录时的 .strm 路径
}
StrmTarget 一个待生成的 .strm 目标
func StrmTargets ¶
func StrmTargets(item *model.MediaItem) []StrmTarget
StrmTargets 计算条目对应的 STRM 目标列表。 图片/书籍返回空列表(不生成 STRM)。