From 10ec3a9b0c12e1469cd71fb2c8999a98c86c4639 Mon Sep 17 00:00:00 2001 From: NoodleMage Date: Thu, 2 Jun 2016 16:39:19 +0200 Subject: [PATCH] Added chapter recognition for "season" case --- .../eu/kanade/tachiyomi/util/ChapterRecognition.kt | 6 +++++- .../eu/kanade/tachiyomi/ChapterRecognitionTest.kt | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.kt index 57a806f61..5330978ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.kt @@ -29,8 +29,12 @@ object ChapterRecognition { * Regex used to remove unwanted tags * Example Prison School 12 v.1 vol004 version1243 volume64 -R> Prison School 12 */ - private val unwanted = Regex("""(?:(v|ver|vol|version|volume).?[0-9]+)""") + private val unwanted = Regex("""(?:(v|ver|vol|version|volume|season).?[0-9]+)""") + /** + * Regex used to remove unwanted whitespace + * Example One Piece 12 special -R> One Piece 12special + */ private val unwantedWhiteSpace = Regex("""(\s)(extra|special|omake)""") fun parseChapterNumber(chapter: Chapter, manga: Manga) { diff --git a/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.kt b/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.kt index ef4dc35da..5d80daa52 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/ChapterRecognitionTest.kt @@ -418,4 +418,15 @@ class ChapterRecognitionTest { assertThat(chapter.chapter_number).isEqualTo(24.005f) } + /** + * Test for chapters containing season + */ + @Test fun chapterContainingSeasonCase() { + createManga("D.I.C.E") + + createChapter("D.I.C.E[Season 001] Ep. 007") + ChapterRecognition.parseChapterNumber(chapter, manga) + assertThat(chapter.chapter_number).isEqualTo(7f) + } + }