From f2367aa4843d13d98c6f685a038e18ca69fcfbbe Mon Sep 17 00:00:00 2001 From: Vetle Ledaal Date: Sun, 6 Aug 2023 16:09:31 +0000 Subject: [PATCH] MangaRawTheme: allow missing titles. Remove mangaraw.ru (#17399) * MangaRawTheme: allow missing titles * nsfw --- .../mangaraw/mangarawru/src/MangaRawRU.kt | 73 ------------------- .../multisrc/mangaraw/MangaRawGenerator.kt | 5 +- .../multisrc/mangaraw/MangaRawTheme.kt | 7 +- 3 files changed, 8 insertions(+), 77 deletions(-) delete mode 100644 multisrc/overrides/mangaraw/mangarawru/src/MangaRawRU.kt diff --git a/multisrc/overrides/mangaraw/mangarawru/src/MangaRawRU.kt b/multisrc/overrides/mangaraw/mangarawru/src/MangaRawRU.kt deleted file mode 100644 index 8cc81ef18..000000000 --- a/multisrc/overrides/mangaraw/mangarawru/src/MangaRawRU.kt +++ /dev/null @@ -1,73 +0,0 @@ -package eu.kanade.tachiyomi.extension.ja.mangarawru - -import eu.kanade.tachiyomi.multisrc.mangaraw.ImageListParser -import eu.kanade.tachiyomi.multisrc.mangaraw.MangaRawTheme -import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.source.model.FilterList -import eu.kanade.tachiyomi.source.model.Page -import eu.kanade.tachiyomi.source.model.SManga -import okhttp3.Request -import org.jsoup.nodes.Document -import org.jsoup.nodes.Element -import org.jsoup.select.Evaluator - -class MangaRawRU : MangaRawTheme("MangaRawRU", "https://mangaraw.ru") { - override fun popularMangaRequest(page: Int): Request = latestUpdatesRequest(page) - override val supportsLatest = false - - override fun String.sanitizeTitle(): String { - val index = lastIndexOf("Raw", ignoreCase = true) - if (index == -1) return this - return substring(0, index) - .trimEnd('(', ' ', ',') - } - - override fun popularMangaSelector() = "#list_videos_videos_items:nth-child(2) .thumb.item>a" - - override fun popularMangaFromElement(element: Element) = SManga.create().apply { - setUrlWithoutDomain(element.attr("href")) - title = element.select("h3").text().sanitizeTitle() - thumbnail_url = element.select("img").attr("abs:src") - } - - override fun popularMangaNextPageSelector() = ".pagination__link" - - override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = - GET("$baseUrl/?s=$query&page=$page") - - override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element) - - override fun searchMangaSelector(): String = ".thumb.item>a" - - override fun mangaDetailsParse(document: Document): SManga { - val manga = SManga.create() - manga.title = document.select("h1").text().sanitizeTitle() - manga.description = document.select(".video-info__box.b-content strong").text() - manga.thumbnail_url = document.select(".player-holder img").attr("abs:src") - - val genres = document.select(".category") - .map { element -> element.text() } - .toMutableSet() - - manga.genre = genres.toList().joinToString(", ") - - return manga - } - - override fun Document.getSanitizedDetails(): Element = this - override fun chapterListSelector() = ".chapter-l a" - override fun String.sanitizeChapter() = substringAfterLast(" – ").substringBeforeLast("漫画") - - override fun pageSelector(): Evaluator { - return Evaluator.Tag("img") - } - - override fun pageListParse(document: Document): List { - val position = 32 - val parser = ImageListParser(document.html(), position) - - return parser.getImageList().orEmpty().mapIndexed { i, imageUrl -> - Page(i, imageUrl = imageUrl) - } - } -} diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawGenerator.kt index 1c7c343ca..afc41109e 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawGenerator.kt @@ -8,12 +8,11 @@ class MangaRawGenerator : ThemeSourceGenerator { override val themePkg = "mangaraw" - override val baseVersionCode = 4 + override val baseVersionCode = 5 override val sources = listOf( SingleLang("SyoSetu", "https://syosetu.top", "ja"), - SingleLang("MangaRaw", "https://manga1001.in", "ja", pkgName = "manga9co", overrideVersionCode = 2), - SingleLang("MangaRawRU", "https://mangaraw.ru", "ja", overrideVersionCode = 1), + SingleLang("MangaRaw", "https://manga1001.in", "ja", pkgName = "manga9co", isNsfw = true, overrideVersionCode = 2), ) companion object { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawTheme.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawTheme.kt index bf463a527..c84d214cb 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawTheme.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangaraw/MangaRawTheme.kt @@ -5,6 +5,7 @@ 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 okhttp3.HttpUrl.Companion.toHttpUrl import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.jsoup.select.Evaluator @@ -23,7 +24,11 @@ abstract class MangaRawTheme( override fun popularMangaFromElement(element: Element) = SManga.create().apply { setUrlWithoutDomain(element.selectFirst(Evaluator.Tag("a"))!!.attr("href")) - title = element.selectFirst(Evaluator.Tag("h3"))!!.text().sanitizeTitle() + + // Title could be missing. Uses URL as a last effort, ex: okaeri-alice-raw + title = element.selectFirst(Evaluator.Tag("h3"))?.text()?.sanitizeTitle() + ?: (baseUrl + url).toHttpUrl().pathSegments.first() + thumbnail_url = element.selectFirst(Evaluator.Tag("img"))?.absUrl("data-src") }