Skip to content

Commit

Permalink
修复下载完成时webhook裂图问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuo894 committed Oct 11, 2024
1 parent 4c8ab2f commit 3fcfc67
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
4 changes: 1 addition & 3 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
修复mikan界面bug

优化一些ui细节
修复下载完成时webhook裂图问题
Binary file added docs/image/null.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.113</version>
<version>1.1.114</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/ani/rss/msg/WebHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ public Boolean send(Config config, Ani ani, String text) {
webHookUrl = webHookUrl.replace("${message}", text);
webHookBody = webHookBody.replace("${message}", text);

if (Objects.nonNull(ani) &&
(webHookBody.contains("${image}") || webHookUrl.contains("${image}"))) {
String image = ani.getImage();
if (StrUtil.isBlank(image)) {
image = BgmUtil.getBgmInfo(ani).getImage();
}
if (StrUtil.isNotBlank(image)) {
webHookUrl = webHookUrl.replace("${image}", image);
webHookBody = webHookBody.replace("${image}", image);
}
String image = "https://docs.wushuo.top/image/null.png";

if (Objects.nonNull(ani) && StrUtil.isNotBlank(ani.getImage())) {
image = ani.getImage();
}

webHookUrl = webHookUrl.replace("${image}", image);
webHookBody = webHookBody.replace("${image}", image);

HttpRequest httpRequest = HttpReq.get(webHookUrl)
.method(Method.valueOf(webHookMethod));

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/ani/rss/util/MikanUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -37,7 +38,7 @@ public static Mikan list(String text, Mikan.Season season) {
.collect(Collectors.toSet());
String url = getMikanHost();
if (StrUtil.isNotBlank(text)) {
url = url + "/Home/Search?searchstr=" + text;
url = url + "/Home/Search?searchstr=" + URLUtil.encode(text, StandardCharsets.UTF_8);
} else {
Integer year = season.getYear();
String seasonStr = season.getSeason();
Expand Down Expand Up @@ -73,6 +74,9 @@ public static Mikan list(String text, Mikan.Season season) {

Function<Element, List<Ani>> get = (el) -> {
List<Ani> anis = new ArrayList<>();
if (Objects.isNull(el)) {
return anis;
}
Elements lis = el.select("li");
for (Element li : lis) {
String img = getMikanHost() + li.selectFirst("span")
Expand Down
4 changes: 2 additions & 2 deletions ui/src/config/Proxy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let urls = ref([
'https://nyaa.si',
'https://github.com',
'https://www.google.com',
'http://bgm.tv'
'https://bgm.tv'
])
let url = ref('')
Expand Down Expand Up @@ -88,4 +88,4 @@ let props = defineProps(['config'])
display: flex;
}
}
</style>
</style>

0 comments on commit 3fcfc67

Please sign in to comment.