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.
This commit is contained in:
happywillow0 2024-01-23 09:33:02 -05:00 committed by Draff
parent d631818f99
commit 7ae0c27e21
2 changed files with 19 additions and 23 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'MyReadingManga' extName = 'MyReadingManga'
extClass = '.MyReadingMangaFactory' extClass = '.MyReadingMangaFactory'
extVersionCode = 49 extVersionCode = 50
isNsfw = true isNsfw = true
} }

View File

@ -13,11 +13,11 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.CacheControl
import okhttp3.Headers import okhttp3.Headers
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import rx.Observable import rx.Observable
@ -219,7 +219,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
// Pages // Pages
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
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) } .mapNotNull { getImage(it) }
.distinct() .distinct()
.mapIndexed { i, url -> Page(i, "", url) } .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 // Filter Parsing, grabs pages as document and filters out Genres, Popular Tags, and Categories, Parings, and Scan Groups
private var filtersCached = false private var filtersCached = false
private val filterMap = mutableMapOf<String, String>()
// Grabs page containing filters and puts it into cache // 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() val response = client.newCall(GET(url, headers)).execute()
return response.body.string() filterMap[url] = response.body.string()
} }
private fun cacheAssistant() { 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 // Parses cached page for filters
private fun getCache(url: String): Document? { private fun returnFilter(url: String, css: String): Array<String> {
val response = client.newCall(GET(url, headers, CacheControl.FORCE_CACHE)).execute() val document = if (filterMap.isNullOrEmpty()) {
return if (response.isSuccessful) {
filtersCached = true
response.asJsoup()
} else {
filtersCached = false filtersCached = false
null null
} else {
filtersCached = true
Jsoup.parse(filterMap[url]!!)
} }
}
// Parses page for filter
private fun returnFilter(document: Document?, css: String): Array<String> {
return document?.select(css)?.map { it.text() }?.toTypedArray() 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 // 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( return FilterList(
EnforceLanguageFilter(siteLang), EnforceLanguageFilter(siteLang),
SearchSortTypeList(), SearchSortTypeList(),
GenreFilter(returnFilter(getCache(cachedPagesUrls["genres"]!!), ".tagcloud a[href*=/genre/]")), GenreFilter(returnFilter(cachedPagesUrls["genres"]!!, ".tagcloud a[href*=/genre/]")),
TagFilter(returnFilter(getCache(cachedPagesUrls["tags"]!!), ".tagcloud a[href*=/tag/]")), TagFilter(returnFilter(cachedPagesUrls["tags"]!!, ".tagcloud a[href*=/tag/]")),
CatFilter(returnFilter(getCache(cachedPagesUrls["categories"]!!), ".links a")), CatFilter(returnFilter(cachedPagesUrls["categories"]!!, ".links a")),
PairingFilter(returnFilter(getCache(cachedPagesUrls["pairings"]!!), ".links a")), PairingFilter(returnFilter(cachedPagesUrls["pairings"]!!, ".links a")),
ScanGroupFilter(returnFilter(getCache(cachedPagesUrls["groups"]!!), ".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 { 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"
} }
} }