mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 11:36:36 +08:00
fix(telegram): 订阅/下载通知补充媒体模板所需字段
合并 #39 媒体通知模板后, formatTelegramMediaNotification 需要事件携带 片名/简介/外链/资源标题等字段才能渲染丰富内容。补充数据源中现成可用的字段: - 订阅命中: title(订阅名)/overview/imdb_url(由 IMDBID 拼)/resource_title(首个命中资源) - 下载完成: title/overview/resource_title(torrent 原始名, 供模板提取季集与版本) 缺失项(年份/评分/tmdb 链接等无现成来源)模板会自动略过, 不影响回退。
This commit is contained in:
@@ -1357,6 +1357,11 @@ func (d *DownloadService) notifyDownloadComplete(ctx context.Context, torrent QB
|
||||
}
|
||||
body := fmt.Sprintf("任务:%s\n保存路径:%s\nHash:%s", name, firstNonEmpty(torrent.ContentPath, torrent.SavePath), torrent.Hash)
|
||||
data := map[string]interface{}{}
|
||||
// resource_title 供 Telegram 模板从发布名提取季集(SxxEyy)与版本(分辨率/编码/
|
||||
// 字幕组等)信息;隐藏不直接展示。优先用 torrent 原始名(信息最全)。
|
||||
if rt := strings.TrimSpace(torrent.Name); rt != "" {
|
||||
data["resource_title"] = rt
|
||||
}
|
||||
if task != nil {
|
||||
if strings.TrimSpace(task.PosterURL) != "" {
|
||||
data["poster_url"] = task.PosterURL
|
||||
@@ -1370,6 +1375,12 @@ func (d *DownloadService) notifyDownloadComplete(ctx context.Context, torrent QB
|
||||
if strings.TrimSpace(task.MediaCategory) != "" {
|
||||
data["media_category"] = task.MediaCategory
|
||||
}
|
||||
if strings.TrimSpace(task.Title) != "" {
|
||||
data["title"] = task.Title
|
||||
}
|
||||
if strings.TrimSpace(task.Overview) != "" {
|
||||
data["overview"] = task.Overview
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
|
||||
@@ -469,6 +469,20 @@ func (s *SubscriptionService) notifySubscriptionHit(sub *model.Subscription, que
|
||||
if strings.TrimSpace(sub.MediaCategory) != "" {
|
||||
data["media_category"] = sub.MediaCategory
|
||||
}
|
||||
// 补充媒体通知模板(formatTelegramMediaNotification)所需字段:片名 / 简介 /
|
||||
// 外链 / 资源标题(供模板提取季集 + 版本)。仅填现成可用的,缺失项模板会自动略过。
|
||||
if strings.TrimSpace(sub.Name) != "" {
|
||||
data["title"] = sub.Name
|
||||
}
|
||||
if strings.TrimSpace(sub.Overview) != "" {
|
||||
data["overview"] = sub.Overview
|
||||
}
|
||||
if id := strings.TrimSpace(sub.IMDBID); id != "" {
|
||||
data["imdb_url"] = "https://www.imdb.com/title/" + id + "/"
|
||||
}
|
||||
if len(resources) > 0 {
|
||||
data["resource_title"] = resources[0]
|
||||
}
|
||||
s.notify.BroadcastEvent(ctx, NotifyEvent{
|
||||
Type: EventSubscriptionHit,
|
||||
Title: "MediaStationGo 订阅命中新资源",
|
||||
|
||||
Reference in New Issue
Block a user