diff --git a/UPDATE.md b/UPDATE.md index e5229b1..d26407e 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -1,3 +1 @@ -修复无法匹配tmdb某些nfsw标题的问题 - -fix #132 +重命名模版增加 分辨率 ${resolution} diff --git a/pom.xml b/pom.xml index 0dac07e..7f3b6f5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ani.rss ani-rss - 1.1.218 + 1.1.219 11 diff --git a/src/main/java/ani/rss/util/RenameUtil.java b/src/main/java/ani/rss/util/RenameUtil.java index 964ea75..8b8e8fa 100644 --- a/src/main/java/ani/rss/util/RenameUtil.java +++ b/src/main/java/ani/rss/util/RenameUtil.java @@ -114,6 +114,8 @@ 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); @@ -121,6 +123,7 @@ public static Boolean rename(Ani ani, Item item) { renameTemplate = renameTemplate.replace("${episode}", episodeStr); renameTemplate = renameTemplate.replace("${subgroup}", subgroup); renameTemplate = renameTemplate.replace("${itemTitle}", itemTitle); + renameTemplate = renameTemplate.replace("${resolution}", resolution); String reName = renameTemplate.trim(); @@ -129,6 +132,30 @@ public static Boolean rename(Ani ani, Item item) { return true; } + /** + * 获取分辨率 + * + * @param itemTitle + * @return + */ + private static String getResolution(String itemTitle) { + Map 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", "½");