Skip to content

Commit

Permalink
通知支持字幕组
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuo894 committed Oct 27, 2024
1 parent a342493 commit a62e82e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
修复开启剔除后下载完成通知异常的问题
修复 tg 用户未设置 username 时的 NPE 问题 @akiakise

优化遗漏通知, 如果遗漏过多将会合并为一个通知
通知支持字幕组
3 changes: 2 additions & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ qbittorrent:
BGM: ${bgmUrl}
季: ${season}
集: ${episode}
字幕组: ${subgroup}
进度: ${currentEpisodeNumber}/${totalEpisodeNumber}
首播: ${year}年${month}月${date}日
首播: ${year}年${month}月${date}日
事件: ${text}

webhook
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ani.rss</groupId>
<artifactId>ani-rss</artifactId>
<version>1.1.159</version>
<version>1.1.160</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ani/rss/msg/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ani, Object> func1 : list) {
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/ani/rss/util/TorrentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@ public static synchronized void notification(TorrentsInfo torrentsInfo) {
}
// 添加下载完成标签,防止重复通知
String tags = torrentsInfo.getTags();
if (StrUtil.split(tags, ",", true, true)
.contains("下载完成")) {
List<String> tagList = StrUtil.split(tags, ",", true, true);
if (tagList.contains("下载完成")) {
return;
}
Boolean b = TorrentUtil.addTags(torrentsInfo, "下载完成");
Expand All @@ -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);
}
Expand Down Expand Up @@ -720,7 +730,7 @@ public static synchronized Ani findAniByName(String name) {
if (season != ani.getSeason()) {
continue;
}
return ani;
return ObjectUtil.clone(ani);
}

return null;
Expand Down

0 comments on commit a62e82e

Please sign in to comment.