From 033168afb8cf232f89e0ba4f0a86cc11013a62a5 Mon Sep 17 00:00:00 2001 From: Davide <49226282+pizidavi@users.noreply.github.com> Date: Mon, 25 Apr 2022 18:56:10 +0200 Subject: [PATCH] Manga-Raw.club: Improvements (#11607) --- src/en/mangarawclub/build.gradle | 2 +- .../extension/en/mangarawclub/MangaRawClub.kt | 38 ++++++------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/en/mangarawclub/build.gradle b/src/en/mangarawclub/build.gradle index 0197a964e..4262e59a6 100644 --- a/src/en/mangarawclub/build.gradle +++ b/src/en/mangarawclub/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'manga-raw.club' pkgNameSuffix = 'en.mangarawclub' extClass = '.MangaRawClub' - extVersionCode = 10 + extVersionCode = 11 isNsfw = true } diff --git a/src/en/mangarawclub/src/eu/kanade/tachiyomi/extension/en/mangarawclub/MangaRawClub.kt b/src/en/mangarawclub/src/eu/kanade/tachiyomi/extension/en/mangarawclub/MangaRawClub.kt index bf2ccb3cd..34d939b74 100644 --- a/src/en/mangarawclub/src/eu/kanade/tachiyomi/extension/en/mangarawclub/MangaRawClub.kt +++ b/src/en/mangarawclub/src/eu/kanade/tachiyomi/extension/en/mangarawclub/MangaRawClub.kt @@ -1,22 +1,18 @@ package eu.kanade.tachiyomi.extension.en.mangarawclub import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList -import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource -import eu.kanade.tachiyomi.util.asJsoup import okhttp3.FormBody import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.OkHttpClient import okhttp3.Request import org.jsoup.nodes.Document import org.jsoup.nodes.Element -import rx.Observable import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit @@ -66,24 +62,25 @@ class MangaRawClub : ParsedHttpSource() { override fun latestUpdatesNextPageSelector() = searchMangaNextPageSelector() override fun mangaDetailsParse(document: Document): SManga { + if (document.select(".novel-header").first() == null) + throw Exception("Page not found") + val manga = SManga.create() - val author = document.select(".author a").first()?.attr("title") ?: "" - manga.author = if (author != "Updating") author else null + val author = document.select(".author a").first()?.attr("title")?.trim() ?: "" + if (author.toLowerCase(Locale.ROOT) != "updating") + manga.author = author var description = document.select(".description").first()?.text() ?: "" description = description.substringAfter("The Summary is").trim() - val otherTitle = document.select(".alternative-title").first()?.text() ?: "" - if (otherTitle != "Updating") + val otherTitle = document.select(".alternative-title").first()?.text()?.trim() ?: "" + if (otherTitle.isNotEmpty() && otherTitle.toLowerCase(Locale.ROOT) != "updating") description += "\n\n$altName $otherTitle" manga.description = description.trim() - val genres = mutableListOf() - document.select(".categories a[href*=genre]").forEach { element -> - val genre = element.attr("title").removeSuffix("Genre").trim() - genres.add(genre) + manga.genre = document.select(".categories a[href*=genre]").joinToString(", ") { + it.attr("title").removeSuffix("Genre").trim() } - manga.genre = genres.joinToString(", ") val statusElement = document.select("div.header-stats") manga.status = when { @@ -103,7 +100,7 @@ class MangaRawClub : ParsedHttpSource() { override fun chapterListSelector() = "ul.chapter-list > li" override fun chapterListRequest(manga: SManga): Request { - val url = baseUrl + manga.url + "all-chapters" + val url = baseUrl + manga.url + "all-chapters/" return GET(url, headers) } @@ -145,19 +142,6 @@ class MangaRawClub : ParsedHttpSource() { override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used.") - override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { - val request = searchMangaRequest(page, query, filters) - return client.newCall(request).asObservableSuccess().map { response -> - val mangas = mutableListOf() - val document = response.asJsoup() - document.select(searchMangaSelector()).forEach { element -> - mangas.add(searchMangaFromElement(element)) - } - val nextPage = document.select(searchMangaNextPageSelector()).isNotEmpty() - MangasPage(mangas, nextPage) - } - } - override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (query.isNotEmpty()) // Query search return GET("$baseUrl/search/?search=$query", headers)