From 59a91b7f5693123d00545e35d10b8f577d61a400 Mon Sep 17 00:00:00 2001 From: Rolando Lecca <90949336+bapeey@users.noreply.github.com> Date: Sun, 18 Feb 2024 22:09:19 -0500 Subject: [PATCH] MNS: Fix popular and latest tabs again (#1368) bruh --- src/es/mangasnosekai/build.gradle | 2 +- .../es/mangasnosekai/MangasNoSekai.kt | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/es/mangasnosekai/build.gradle b/src/es/mangasnosekai/build.gradle index 6444ffc0d..2fba11078 100644 --- a/src/es/mangasnosekai/build.gradle +++ b/src/es/mangasnosekai/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.MangasNoSekai' themePkg = 'madara' baseUrl = 'https://mangasnosekai.com' - overrideVersionCode = 4 + overrideVersionCode = 5 } apply from: "$rootDir/common.gradle" diff --git a/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt b/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt index f5404ca4a..982c520af 100644 --- a/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt +++ b/src/es/mangasnosekai/src/eu/kanade/tachiyomi/extension/es/mangasnosekai/MangasNoSekai.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.es.mangasnosekai import eu.kanade.tachiyomi.multisrc.madara.Madara +import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.model.SChapter @@ -21,16 +22,43 @@ class MangasNoSekai : Madara( "es", SimpleDateFormat("MMMM dd, yyyy", Locale("es")), ) { + + override val useLoadMoreRequest = LoadMoreStrategy.Never + override val client = super.client.newBuilder() .rateLimitHost(baseUrl.toHttpUrl(), 2, 1) .build() override val useNewChapterEndpoint = true - override val mangaSubString = "manganewo" + private var libraryPath = "" + + private fun getLibraryPath() { + libraryPath = try { + val document = client.newCall(GET(baseUrl, headers)).execute().asJsoup() + val libraryUrl = document.selectFirst("li#menu-item-3116.menu-item > a[href]") + + libraryUrl?.attr("href")?.removeSuffix("/")?.substringAfterLast("/") + ?: "manganewos" + } catch (e: Exception) { + "manganewos" + } + } + + override fun popularMangaRequest(page: Int): Request { + if (libraryPath.isBlank()) getLibraryPath() + return GET("$baseUrl/$libraryPath/${searchPage(page)}?m_orderby=views", headers) + } + + override fun latestUpdatesRequest(page: Int): Request { + if (libraryPath.isBlank()) getLibraryPath() + return GET("$baseUrl/$libraryPath/${searchPage(page)}?m_orderby=latest", headers) + } override fun popularMangaSelector() = "div.page-listing-item > div.row > div" + override fun popularMangaNextPageSelector() = "a.next.page-numbers" + override val popularMangaUrlSelector = "a[href]" override fun popularMangaFromElement(element: Element): SManga {