Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.219 #138

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading