From bb723076ee7e3f20f637a539cbb111f538d836d8 Mon Sep 17 00:00:00 2001 From: Taumer Date: Sun, 12 Feb 2017 21:43:00 +0300 Subject: [PATCH] Chapter Recognition for Read/Mintmanga (#682) --- .../tachiyomi/source/online/russian/Mintmanga.kt | 16 +++++++++++++++- .../tachiyomi/source/online/russian/Readmanga.kt | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt index 1ea8269917..6097859fad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt @@ -102,7 +102,21 @@ class Mintmanga : ParsedHttpSource() { } override fun prepareNewChapter(chapter: SChapter, manga: SManga) { - chapter.chapter_number = -2f + val basic = Regex("""\s([0-9]+)(\s-\s)([0-9]+)\s*""") + val extra = Regex("""\s([0-9]+\sЭкстра)\s*""") + val single = Regex("""\sСингл\s*""") + when { + basic.containsMatchIn(chapter.name) -> { + basic.find(chapter.name)?.let { + val number = it.groups[3]?.value!! + chapter.chapter_number = number.toFloat() + } + } + extra.containsMatchIn(chapter.name) -> // Extra chapters doesn't contain chapter number + chapter.chapter_number = -2f + single.containsMatchIn(chapter.name) -> // Oneshoots, doujinshi and other mangas with one chapter + chapter.chapter_number = 1f + } } override fun pageListParse(response: Response): List { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt index d8ec69e56c..6ac6e9c28e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt @@ -102,7 +102,21 @@ class Readmanga : ParsedHttpSource() { } override fun prepareNewChapter(chapter: SChapter, manga: SManga) { - chapter.chapter_number = -2f + val basic = Regex("""\s([0-9]+)(\s-\s)([0-9]+)\s*""") + val extra = Regex("""\s([0-9]+\sЭкстра)\s*""") + val single = Regex("""\sСингл\s*""") + when { + basic.containsMatchIn(chapter.name) -> { + basic.find(chapter.name)?.let { + val number = it.groups[3]?.value!! + chapter.chapter_number = number.toFloat() + } + } + extra.containsMatchIn(chapter.name) -> // Extra chapters doesn't contain chapter number + chapter.chapter_number = -2f + single.containsMatchIn(chapter.name) -> // Oneshoots, doujinshi and other mangas with one chapter + chapter.chapter_number = 1f + } } override fun pageListParse(response: Response): List {