LectorManga - Fix page parsing and rate limiting (#8917)

* LectorManga - fix paginated page parsing

Fix issue where the first image of a chapter is displayed n times when `paginated` is the current page preference.
Also, add another image CDN URL for rate limiting.

* LectorManga - bump ver
This commit is contained in:
Tyler W 2021-09-01 05:02:23 -07:00 committed by GitHub
parent ebbd2a3c44
commit feb8f7929f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'LectorManga'
pkgNameSuffix = 'es.lectormanga'
extClass = '.LectorManga'
extVersionCode = 20
extVersionCode = 21
libVersion = '1.2'
}

View File

@ -46,7 +46,7 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
.add("Referer", "$baseUrl/")
}
private val imageCDNUrls = arrayOf("https://img1.followmanga.com", "https://img1.biggestchef.com", "https://img1.indalchef.com")
private val imageCDNUrls = arrayOf("https://img1.followmanga.com", "https://img1.biggestchef.com", "https://img1.indalchef.com", "https://img1.recipesandcook.com")
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
@ -71,12 +71,18 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
imageCDNUrls[2].toHttpUrlOrNull()!!,
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(), 60
)
private val imageCDNRateLimitInterceptor3 = SpecificHostRateLimitInterceptor(
imageCDNUrls[3].toHttpUrlOrNull()!!,
preferences.getString(IMAGE_CDN_RATELIMIT_PREF, IMAGE_CDN_RATELIMIT_PREF_DEFAULT_VALUE)!!.toInt(), 60
)
override val client: OkHttpClient = network.client.newBuilder()
.addNetworkInterceptor(webRateLimitInterceptor)
.addNetworkInterceptor(imageCDNRateLimitInterceptor)
.addNetworkInterceptor(imageCDNRateLimitInterceptor1)
.addNetworkInterceptor(imageCDNRateLimitInterceptor2)
.addNetworkInterceptor(imageCDNRateLimitInterceptor3)
.build()
override fun popularMangaRequest(page: Int) = GET("$baseUrl/library?order_item=likes_count&order_dir=desc&type=&filter_by=title&page=$page", headers)
@ -278,11 +284,16 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
)
}
} else {
val pageList = document.select("#viewer-pages-select").first().select("option").map { it.attr("value").toInt() }
val url = document.baseUri().substringBefore("/paginated") // Accounts for url ending in number "/paginated/1"
pageList.forEach {
add(Page(it, "$url/paginated/$it"))
}
val body = document.select("script:containsData(var dirPath)").first().data()
val path = body.substringAfter("var dirPath = '").substringBefore("'")
body.substringAfter("var images = JSON.parse('[")
.substringBefore("]')")
.replace("\"", "")
.split(",")
.forEach {
add(Page(size, document.baseUri(), path + it))
}
}
}