Skip to content

Commit

Permalink
Merge pull request #138 from wushuo894/test
Browse files Browse the repository at this point in the history
1.1.219
  • Loading branch information
wushuo894 authored Jan 11, 2025
2 parents a948434 + cb6fbd3 commit 319d720
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
4 changes: 1 addition & 3 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
修复无法匹配tmdb某些nfsw标题的问题

fix #132
重命名模版增加 分辨率 ${resolution}
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.218</version>
<version>1.1.219</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/ani/rss/util/RenameUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,16 @@ public static Boolean rename(Ani ani, Item item) {
title = getName(title);
itemTitle = getName(itemTitle);

String resolution = getResolution(itemTitle);

renameTemplate = renameTemplate.replace("${title}", title);
renameTemplate = renameTemplate.replace("${seasonFormat}", seasonFormat);
renameTemplate = renameTemplate.replace("${episodeFormat}", episodeFormat);
renameTemplate = renameTemplate.replace("${season}", String.valueOf(season));
renameTemplate = renameTemplate.replace("${episode}", episodeStr);
renameTemplate = renameTemplate.replace("${subgroup}", subgroup);
renameTemplate = renameTemplate.replace("${itemTitle}", itemTitle);
renameTemplate = renameTemplate.replace("${resolution}", resolution);

String reName = renameTemplate.trim();

Expand All @@ -129,6 +132,30 @@ public static Boolean rename(Ani ani, Item item) {
return true;
}

/**
* 获取分辨率
*
* @param itemTitle
* @return
*/
private static String getResolution(String itemTitle) {
Map<String, String> stringStringMap = Map.of(
"1920x1080", "1080p",
"3840x2160", "2160p",
"1280x720", "720p"
);
for (String s : stringStringMap.keySet()) {
itemTitle = itemTitle.replace(s, stringStringMap.get(s));
}

String resolutionReg = "(720|1080|2160)[Pp]";
String resolution = "none";
if (ReUtil.contains(resolutionReg, itemTitle)) {
resolution = ReUtil.get(resolutionReg, itemTitle, 0).toLowerCase();
}
return resolution;
}

public static String getName(String s) {
s = s.replace("1/2", "½");

Expand Down

0 comments on commit 319d720

Please sign in to comment.