From 5977e9f47f77819707b9ad91aac590233982511c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Feb 2016 20:26:51 +0100 Subject: [PATCH] handle chapter versions which are attached to the chapter number --- .../java/eu/kanade/tachiyomi/util/ChapterRecognition.java | 4 ++-- .../java/eu/kanade/tachiyomi/ChapterRecognitionTest.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java index 287c288edc..26d505f699 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java @@ -15,7 +15,7 @@ public class ChapterRecognition { private static final Pattern p3 = Pattern.compile("(\\d+[\\.,]?\\d*\\s*:)"); private static final Pattern pUnwanted = - Pattern.compile("\\b(v|ver|vol|version|volume)\\.?\\s*\\d+\\b"); + Pattern.compile("(\\b|\\d)(v|ver|vol|version|volume)\\.?\\s*\\d+\\b"); public static void parseChapterNumber(Chapter chapter, Manga manga) { if (chapter.chapter_number != -1) @@ -32,7 +32,7 @@ public class ChapterRecognition { } // Remove anything related to the volume or version - name = pUnwanted.matcher(name).replaceAll(""); + name = pUnwanted.matcher(name).replaceAll("$1"); List occurrences; diff --git a/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.java b/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.java index 8ff1b06d7c..8626d8bb60 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.java +++ b/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.java @@ -135,4 +135,10 @@ public class ChapterRecognitionTest { assertThat(c.chapter_number).isEqualTo(28f); } + @Test + public void testWithVolumeAttachedToChapter() { + Chapter c = createChapter("Ansatsu Kyoushitsu 011v002: Assembly Time"); + ChapterRecognition.parseChapterNumber(c, randomManga); + assertThat(c.chapter_number).isEqualTo(11f); + } }