Skip to content

Commit 4b4b4b2

Browse files
authored
fix mail cover img url issue (#189)
* fix mail cover img url issue * skip file episode matching when file type is not video * update changelog for pr #189
1 parent ee70d0f commit 4b4b4b2

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

CHANGELOG.MD

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
- 用户信息更新页面,支持用户邮箱更新
1111

1212
## Bugfix
13-
- 修复解析蜜柑计划RSS失败的问题
14-
- 修复通知邮件无法包含日文内容的问题
15-
- 修复通知邮件内容无法显示封面URL的问题
13+
- 解析蜜柑计划RSS失败的问题
14+
- 通知邮件无法包含日文内容的问题
15+
- 通知邮件内容无法显示封面URL的问题
16+
- 邮件URL的斜杠重复,导致无法访问资源 #188
17+
- 邮件剧集文件名称不是视频类型的也进行更新了 #188
1618

1719
## Improvements
1820
- 优化剧集URL更新时通知的代码逻辑,目前在拉取qbittorrent已完成下载的文件任务里,创建服务端对应的文件后,当匹配到对应的剧集URL时,会给用户发送通知邮件

src/main/java/run/ikaros/server/listener/EpisodeUrlUpdateEventListener.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public void onApplicationEvent(@NonNull EpisodeUrlUpdateEvent event) {
5252
final String newUrl = event.getNewUrl();
5353
final String newUrlFileName = event.getNewUrlFileName();
5454
final Boolean isNotify = event.getIsNotify();
55-
final String appUrlPrefix = ikarosProperties.getAppUrlPrefix();
5655
EpisodeEntity episodeEntity = episodeService.getById(episodeId);
5756
if (episodeEntity == null) {
5857
log.warn("skip, not found episode for id={}", episodeId);
@@ -108,7 +107,18 @@ public void onApplicationEvent(@NonNull EpisodeUrlUpdateEvent event) {
108107
vars.put("epSeq", episodeEntity.getSeq());
109108
vars.put("epIntroduction", episodeEntity.getOverview());
110109
vars.put("introduction", animeEntity.getOverview());
111-
vars.put("coverImgUrl", appUrlPrefix + "/" + animeEntity.getCoverUrl());
110+
String coverUrl = animeEntity.getCoverUrl();
111+
if (StringUtils.isNotBlank(coverUrl) && coverUrl.startsWith("/")) {
112+
coverUrl = coverUrl.substring(1);
113+
if (coverUrl.startsWith("/")) {
114+
coverUrl = coverUrl.substring(1);
115+
}
116+
}
117+
String appUrlPrefix = ikarosProperties.getAppUrlPrefix();
118+
if (StringUtils.isNotBlank(appUrlPrefix) && appUrlPrefix.endsWith("/")) {
119+
appUrlPrefix = appUrlPrefix.substring(0, appUrlPrefix.length() - 1);
120+
}
121+
vars.put("coverImgUrl", appUrlPrefix + "/" + coverUrl);
112122
vars.put("epUrlFileName", newUrlFileName);
113123
context.setVariables(vars);
114124

src/main/java/run/ikaros/server/service/SeasonServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import run.ikaros.server.entity.EpisodeEntity;
1515
import run.ikaros.server.entity.FileEntity;
1616
import run.ikaros.server.entity.SeasonEntity;
17+
import run.ikaros.server.enums.FileType;
1718
import run.ikaros.server.enums.SeasonType;
1819
import run.ikaros.server.event.EpisodeUrlUpdateEvent;
1920
import run.ikaros.server.exceptions.RecordNotFoundException;
@@ -25,6 +26,7 @@
2526
import run.ikaros.server.params.SeasonMatchingEpParams;
2627
import run.ikaros.server.utils.AssertUtils;
2728
import run.ikaros.server.utils.BeanUtils;
29+
import run.ikaros.server.utils.FileUtils;
2830
import run.ikaros.server.utils.RegexUtils;
2931
import run.ikaros.server.utils.StringUtils;
3032

@@ -109,6 +111,11 @@ public SeasonDTO matchingEpisodesUrlByFileIds(
109111
continue;
110112
}
111113
final String fileName = fileEntity.getName();
114+
FileType fileType = FileUtils.parseTypeByPostfix(FileUtils.parseFileName(fileName));
115+
if (fileType != FileType.VIDEO) {
116+
continue;
117+
}
118+
112119
Long episodeSeq = null;
113120
try {
114121
episodeSeq = RegexUtils.getFileNameTagEpSeq(fileName);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package run.ikaros.server.lang;
2+
3+
public class StringTest {
4+
public static void main(String[] args) {
5+
String str = "hello/";
6+
System.out.println(str.substring(0, str.length() - 1));
7+
String str2 = "/hello2";
8+
System.out.println(str2.substring(1));
9+
}
10+
}

0 commit comments

Comments
 (0)