From 7ae0c27e21c2e7ed6a03f6e81fc081a46724d261 Mon Sep 17 00:00:00 2001 From: happywillow0 <45346080+happywillow0@users.noreply.github.com> Date: Tue, 23 Jan 2024 09:33:02 -0500 Subject: [PATCH] Update MyReadingManga (#511) * Update Filter Parsing Update filter parsing behavior from the okhttp cache to a mutableMap * Bump User Agent Version * Update pageListParse Update pageListParse to select for "entry-content" only * Remove Deprecated cloudflareClient * Bump extVersionCode * Revert "Remove Deprecated cloudflareClient" This reverts commit c97c479dca056b6bdd432291910389579d9962c5. --- src/all/myreadingmanga/build.gradle | 2 +- .../all/myreadingmanga/MyReadingManga.kt | 40 +++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/all/myreadingmanga/build.gradle b/src/all/myreadingmanga/build.gradle index b320ae28a..c6501f261 100644 --- a/src/all/myreadingmanga/build.gradle +++ b/src/all/myreadingmanga/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'MyReadingManga' extClass = '.MyReadingMangaFactory' - extVersionCode = 49 + extVersionCode = 50 isNsfw = true } diff --git a/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt b/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt index 513b5b9a2..dc734c15d 100644 --- a/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt +++ b/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt @@ -13,11 +13,11 @@ 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.CacheControl import okhttp3.Headers import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response +import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.nodes.Element import rx.Observable @@ -219,7 +219,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin // Pages override fun pageListParse(document: Document): List { - return (document.select("div img") + document.select("div.separator img[data-src]")) + return (document.select("div.entry-content img") + document.select("div.separator img[data-src]")) .mapNotNull { getImage(it) } .distinct() .mapIndexed { i, url -> Page(i, "", url) } @@ -229,11 +229,12 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin // Filter Parsing, grabs pages as document and filters out Genres, Popular Tags, and Categories, Parings, and Scan Groups private var filtersCached = false + private val filterMap = mutableMapOf() // Grabs page containing filters and puts it into cache - private fun filterAssist(url: String): String { + private fun filterAssist(url: String) { val response = client.newCall(GET(url, headers)).execute() - return response.body.string() + filterMap[url] = response.body.string() } private fun cacheAssistant() { @@ -243,22 +244,17 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin } } - // Returns page from cache to reduce calls to website - private fun getCache(url: String): Document? { - val response = client.newCall(GET(url, headers, CacheControl.FORCE_CACHE)).execute() - return if (response.isSuccessful) { - filtersCached = true - response.asJsoup() - } else { + // Parses cached page for filters + private fun returnFilter(url: String, css: String): Array { + val document = if (filterMap.isNullOrEmpty()) { filtersCached = false null + } else { + filtersCached = true + Jsoup.parse(filterMap[url]!!) } - } - - // Parses page for filter - private fun returnFilter(document: Document?, css: String): Array { return document?.select(css)?.map { it.text() }?.toTypedArray() - ?: arrayOf("Press 'Reset' to try again") + ?: arrayOf("Press 'Reset' to load filters") } // URLs for the pages we need to cache @@ -275,11 +271,11 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin return FilterList( EnforceLanguageFilter(siteLang), SearchSortTypeList(), - GenreFilter(returnFilter(getCache(cachedPagesUrls["genres"]!!), ".tagcloud a[href*=/genre/]")), - TagFilter(returnFilter(getCache(cachedPagesUrls["tags"]!!), ".tagcloud a[href*=/tag/]")), - CatFilter(returnFilter(getCache(cachedPagesUrls["categories"]!!), ".links a")), - PairingFilter(returnFilter(getCache(cachedPagesUrls["pairings"]!!), ".links a")), - ScanGroupFilter(returnFilter(getCache(cachedPagesUrls["groups"]!!), ".links a")), + GenreFilter(returnFilter(cachedPagesUrls["genres"]!!, ".tagcloud a[href*=/genre/]")), + TagFilter(returnFilter(cachedPagesUrls["tags"]!!, ".tagcloud a[href*=/tag/]")), + CatFilter(returnFilter(cachedPagesUrls["categories"]!!, ".links a")), + PairingFilter(returnFilter(cachedPagesUrls["pairings"]!!, ".links a")), + ScanGroupFilter(returnFilter(cachedPagesUrls["groups"]!!, ".links a")), ) } @@ -325,6 +321,6 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin } companion object { - private const val USER_AGENT = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.115 Mobile Safari/537.36" + private const val USER_AGENT = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.230 Mobile Safari/537.36" } }