From feb8f7929fd1f66c4eb16ffe34d61be159b2aed0 Mon Sep 17 00:00:00 2001 From: Tyler W <19383474+leftl@users.noreply.github.com> Date: Wed, 1 Sep 2021 05:02:23 -0700 Subject: [PATCH] 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 --- src/es/lectormanga/build.gradle | 2 +- .../extension/es/lectormanga/LectorManga.kt | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/es/lectormanga/build.gradle b/src/es/lectormanga/build.gradle index a67b79b8d..1b2383f22 100755 --- a/src/es/lectormanga/build.gradle +++ b/src/es/lectormanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'LectorManga' pkgNameSuffix = 'es.lectormanga' extClass = '.LectorManga' - extVersionCode = 20 + extVersionCode = 21 libVersion = '1.2' } diff --git a/src/es/lectormanga/src/eu/kanade/tachiyomi/extension/es/lectormanga/LectorManga.kt b/src/es/lectormanga/src/eu/kanade/tachiyomi/extension/es/lectormanga/LectorManga.kt index 347d8b933..94031635a 100755 --- a/src/es/lectormanga/src/eu/kanade/tachiyomi/extension/es/lectormanga/LectorManga.kt +++ b/src/es/lectormanga/src/eu/kanade/tachiyomi/extension/es/lectormanga/LectorManga.kt @@ -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().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)) + } } }