mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-11 15:56:37 +08:00
feat: Emby 兼容层完整实现 + 多模块功能增强
## Emby/Jellyfin 兼容层 (emby_compat.go / emby.go) - 新增 SystemInfoPublic、FindUser、Items、Item、LatestItems、ResumeItems - 新增 SetFavorite、MarkPlayed、RecordProgress 用户播放状态同步 - 新增 itemPayload、mediaSource、mediaStreams 媒体信息组装 - 双前缀路由 /emby/* 和 / 根路径,兼容 Infuse/Yamby/Senplayer/Kodi - 新增 Ping、SystemEndpoint、AuthByName 端点 - emby.go 扩展对应 handler 函数 ## 站点适配器 (site_adapter.go / site.go) - SiteConfig 扩展 UserAgent/Timeout/Extra/FlareSolverrURL 字段 - doRequest() GET 请求支持 FlareSolverr 代理绕过 Cloudflare/WAF - MTeam api_key 认证改为 Authorization: Bearer 格式 - Search() 重构为 sync.WaitGroup 并发执行,提升多站搜索性能 - siteModelToConfig() 改为 SiteService 方法,按 BrowserEmulation 填充 FlareSolverrURL ## 图片代理 (image_proxy.go) - 重构图片代理服务,支持更多来源和缓存策略 ## 下载管理 (downloads.go / download_clients.go / qbittorrent.go) - 下载任务增强:状态管理、进度追踪优化 - qBittorrent 客户端连接稳定性改进 ## 刮削与数据库 (scraper.go / tmdb.go / repository.go) - 刮削器增强 TMDB 集成,补全元数据字段 - repository 扩展查询方法 ## 前端 (web/src/) - HomePage: 首页布局重构,按媒体库分组展示,系列聚合优化 - DiscoverPage: 发现页增强,错误处理改进(API key 缺失/网络错误分离) - PosterWallPage: 海报墙优化,系列聚合展示 - MediaCard: 媒体卡片优化 - PlayerPage: 播放器改进 - 新增 utils/groupSeries.ts: 系列聚合工具函数 - .gitignore: 添加 .tmp_* 临时文件排除规则
This commit is contained in:
@@ -18,6 +18,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -67,19 +68,41 @@ func (d *DownloadService) Stop() {
|
||||
close(d.stopCh)
|
||||
}
|
||||
|
||||
// ReloadConfig rebuilds the qBittorrent client from the system settings.
|
||||
// ReloadConfig rebuilds the qBittorrent client from the configured
|
||||
// download clients (preferred) or the legacy Setting table (fallback).
|
||||
//
|
||||
// 配置来源优先级:
|
||||
//
|
||||
// 1. download_clients 表中 type=qbittorrent 且 is_default=true 且 enabled=true
|
||||
// 的行(侧边栏「下载器」页面写入的数据)。
|
||||
// 2. system Setting 表中的 qbittorrent.url / username / password
|
||||
// (旧版「系统设置」表单写入的数据;保留作向后兼容)。
|
||||
//
|
||||
// 这避免了两套配置各跑各的:之前操作员明明已经在「下载器」页面填好
|
||||
// 默认 qb,但实际下载链路读的还是 Setting 表,导致一直连不上。
|
||||
func (d *DownloadService) ReloadConfig(ctx context.Context) error {
|
||||
cfg := QBitConfig{}
|
||||
for _, key := range []struct{ from, into *string }{} {
|
||||
_ = key
|
||||
|
||||
// Path 1: download_clients 表
|
||||
if d.repo.DownloadClient != nil {
|
||||
if c, err := d.repo.DownloadClient.FindDefault(ctx); err == nil && c != nil && c.Type == "qbittorrent" {
|
||||
cfg.BaseURL = strings.TrimRight(c.Host, "/")
|
||||
cfg.Username = c.Username
|
||||
cfg.Password = c.Password
|
||||
}
|
||||
}
|
||||
get := func(k string) string {
|
||||
v, _ := d.repo.Setting.Get(ctx, k)
|
||||
return v
|
||||
|
||||
// Path 2: legacy Setting 表(仅在 client 表未配置时回退)
|
||||
if cfg.BaseURL == "" {
|
||||
get := func(k string) string {
|
||||
v, _ := d.repo.Setting.Get(ctx, k)
|
||||
return v
|
||||
}
|
||||
cfg.BaseURL = get("qbittorrent.url")
|
||||
cfg.Username = get("qbittorrent.username")
|
||||
cfg.Password = get("qbittorrent.password")
|
||||
}
|
||||
cfg.BaseURL = get("qbittorrent.url")
|
||||
cfg.Username = get("qbittorrent.username")
|
||||
cfg.Password = get("qbittorrent.password")
|
||||
|
||||
d.qb.Configure(cfg)
|
||||
return nil
|
||||
}
|
||||
@@ -171,11 +194,12 @@ func (d *DownloadService) onTorrentComplete(ctx context.Context, hash string, sa
|
||||
if d.organizer == nil || savePath == "" {
|
||||
return
|
||||
}
|
||||
// Check if auto-organize after download is enabled
|
||||
autoOrganize := d.organizer.isSmartClassifyEnabled(ctx)
|
||||
// Also check dedicated config key
|
||||
// 仅当显式开启 organizer.auto_after_download 时才在下载完成后整理。
|
||||
// 之前的代码错误地把 organizer.smart_classify 也当成"自动整理"开关,
|
||||
// 让操作员只想启用"分类子目录"就被动触发了文件 move。
|
||||
autoOrganize := false
|
||||
if v, err := d.repo.Setting.Get(ctx, "organizer.auto_after_download"); err == nil {
|
||||
autoOrganize = autoOrganize || v == "true" || v == "1" || v == "on"
|
||||
autoOrganize = v == "true" || v == "1" || v == "on"
|
||||
}
|
||||
if !autoOrganize {
|
||||
d.log.Info("download completed, auto-organize disabled", zap.String("hash", hash))
|
||||
|
||||
Reference in New Issue
Block a user