From 6d0724a1508935efd5c81049a9429858d6e48c45 Mon Sep 17 00:00:00 2001 From: E3FxGaming <8276268+E3FxGaming@users.noreply.github.com> Date: Fri, 12 Mar 2021 12:49:16 +0100 Subject: [PATCH] Manga mutiny: chapter number fix + closing responses (#6159) * MangaMutiny: Chapter tracking fix - Chapter numbers were previously incorrectly determined, leading to incorrect tracking information. Fixed with the changes of this commit. * MangaMutiny: closing some response bodies Closing the bodies of some responses. --- src/en/mangamutiny/build.gradle | 2 +- .../extension/en/mangamutiny/MangaMutiny.kt | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/en/mangamutiny/build.gradle b/src/en/mangamutiny/build.gradle index 7bd2e1ebe..6e4c4b14a 100644 --- a/src/en/mangamutiny/build.gradle +++ b/src/en/mangamutiny/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Manga Mutiny' pkgNameSuffix = "en.mangamutiny" extClass = '.MangaMutiny' - extVersionCode = 5 + extVersionCode = 6 libVersion = '1.2' containsNsfw = true } diff --git a/src/en/mangamutiny/src/eu/kanade/tachiyomi/extension/en/mangamutiny/MangaMutiny.kt b/src/en/mangamutiny/src/eu/kanade/tachiyomi/extension/en/mangamutiny/MangaMutiny.kt index 929b43bea..34d9853fb 100644 --- a/src/en/mangamutiny/src/eu/kanade/tachiyomi/extension/en/mangamutiny/MangaMutiny.kt +++ b/src/en/mangamutiny/src/eu/kanade/tachiyomi/extension/en/mangamutiny/MangaMutiny.kt @@ -75,7 +75,7 @@ class MangaMutiny : HttpSource() { mangaDetailsRequestCommon(manga, false) override fun chapterListParse(response: Response): List { - val chapterList = ArrayList() + val chapterList = mutableListOf() val responseBody = response.body() if (responseBody != null) { @@ -89,18 +89,27 @@ class MangaMutiny : HttpSource() { name = chapterTitleBuilder(singleChapterJsonObject) url = singleChapterJsonObject.get("slug").asString date_upload = parseDate(singleChapterJsonObject.get("releasedAt").asString) + + chapterNumberBuilder(singleChapterJsonObject)?.let { chapterNumber -> + chapter_number = chapterNumber + } } ) } + + responseBody.close() } return chapterList } + private fun chapterNumberBuilder(rootNode: JsonObject): Float? = + rootNode.getNullable("chapter")?.asFloat + private fun chapterTitleBuilder(rootNode: JsonObject): String { val volume = rootNode.getNullable("volume")?.asInt - val chapter = rootNode.getNullable("chapter")?.asInt + val chapter = rootNode.getNullable("chapter")?.asFloat val textTitle = rootNode.getNullable("title")?.asString @@ -172,6 +181,8 @@ class MangaMutiny : HttpSource() { genre = rootNode.get("tags").asJsonArray .joinToString { singleGenre -> singleGenre.asString } } + + responseBody.close() } return manga @@ -206,6 +217,8 @@ class MangaMutiny : HttpSource() { for (i in 0 until images.size()) { pageList.add(Page(i, "", chapterUrl + images[i].asString)) } + + responseBody.close() } return pageList