From a62e82e143f65cdb542486f6e47f5729260a4013 Mon Sep 17 00:00:00 2001 From: wushuo Date: Sun, 27 Oct 2024 13:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=94=AF=E6=8C=81=E5=AD=97?= =?UTF-8?q?=E5=B9=95=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UPDATE.md | 4 ++-- docs/docs.md | 3 ++- pom.xml | 2 +- src/main/java/ani/rss/msg/Message.java | 3 ++- src/main/java/ani/rss/util/TorrentUtil.java | 16 +++++++++++++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/UPDATE.md b/UPDATE.md index 22d0531e..db94024e 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -1,3 +1,3 @@ -修复开启剔除后下载完成通知异常的问题 +修复 tg 用户未设置 username 时的 NPE 问题 @akiakise -优化遗漏通知, 如果遗漏过多将会合并为一个通知 \ No newline at end of file +通知支持字幕组 \ No newline at end of file diff --git a/docs/docs.md b/docs/docs.md index cd60e290..6d5a5c16 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -314,8 +314,9 @@ qbittorrent: BGM: ${bgmUrl} 季: ${season} 集: ${episode} + 字幕组: ${subgroup} 进度: ${currentEpisodeNumber}/${totalEpisodeNumber} - 首播: ${year}年${month}月${date}日 + 首播: ${year}年${month}月${date}日 事件: ${text} webhook diff --git a/pom.xml b/pom.xml index fafd6fc8..5313b39f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ani.rss ani-rss - 1.1.159 + 1.1.160 11 diff --git a/src/main/java/ani/rss/msg/Message.java b/src/main/java/ani/rss/msg/Message.java index 1b4c9b28..d88d705c 100644 --- a/src/main/java/ani/rss/msg/Message.java +++ b/src/main/java/ani/rss/msg/Message.java @@ -45,7 +45,8 @@ default String replaceMessageTemplate(Ani ani, String messageTemplate, String te Ani::getThemoviedbName, Ani::getBgmUrl, Ani::getCurrentEpisodeNumber, - Ani::getTotalEpisodeNumber + Ani::getTotalEpisodeNumber, + Ani::getSubgroup ); for (Func1 func1 : list) { diff --git a/src/main/java/ani/rss/util/TorrentUtil.java b/src/main/java/ani/rss/util/TorrentUtil.java index a950349b..dc788dc5 100644 --- a/src/main/java/ani/rss/util/TorrentUtil.java +++ b/src/main/java/ani/rss/util/TorrentUtil.java @@ -636,8 +636,8 @@ public static synchronized void notification(TorrentsInfo torrentsInfo) { } // 添加下载完成标签,防止重复通知 String tags = torrentsInfo.getTags(); - if (StrUtil.split(tags, ",", true, true) - .contains("下载完成")) { + List tagList = StrUtil.split(tags, ",", true, true); + if (tagList.contains("下载完成")) { return; } Boolean b = TorrentUtil.addTags(torrentsInfo, "下载完成"); @@ -647,6 +647,16 @@ public static synchronized void notification(TorrentsInfo torrentsInfo) { Ani ani = null; try { ani = findAniByName(name); + String subgroup = tagList + .stream() + .filter(s -> !BaseDownload.tag.equals(s)) + .filter(s -> !"RENAME".equals(s)) + .findFirst() + .orElse(""); + subgroup = StrUtil.blankToDefault(subgroup, "未知字幕组"); + if (Objects.nonNull(ani)) { + ani.setSubgroup(subgroup); + } } catch (Exception e) { log.error(e.getMessage(), e); } @@ -720,7 +730,7 @@ public static synchronized Ani findAniByName(String name) { if (season != ani.getSeason()) { continue; } - return ani; + return ObjectUtil.clone(ani); } return null;