[TruyenHentai18] Fix attempt 1
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
package org.koitharu.kotatsu.parsers.site.all
|
||||
|
||||
import androidx.collection.ArraySet
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
||||
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
||||
import org.koitharu.kotatsu.parsers.core.PagedMangaParser
|
||||
import org.koitharu.kotatsu.parsers.exception.ParseException
|
||||
import org.koitharu.kotatsu.parsers.model.*
|
||||
import org.koitharu.kotatsu.parsers.util.*
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
@@ -83,11 +83,10 @@ internal class TruyenHentai18(context: MangaLoaderContext):
|
||||
}
|
||||
}
|
||||
|
||||
val fullUrl = "https://" + url
|
||||
return when {
|
||||
filter.tags.isNotEmpty() -> parseNextList(webClient.httpGet(fullUrl).parseHtml())
|
||||
filter.tags.isNotEmpty() -> parseNextList(webClient.httpGet("https://$url").parseHtml())
|
||||
else -> {
|
||||
val doc = webClient.httpGet(fullUrl).parseJson()
|
||||
val doc = webClient.httpGet("https://$url").parseJson()
|
||||
parseJSONList(doc)
|
||||
}
|
||||
}
|
||||
@@ -234,25 +233,19 @@ internal class TruyenHentai18(context: MangaLoaderContext):
|
||||
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
|
||||
val doc = webClient.httpGet(chapter.url.toAbsoluteUrl(domain)).parseHtml()
|
||||
val scriptContent = doc.select("script")
|
||||
.firstOrNull { it.data().startsWith("self.__next_f.push([1,\"\\u003cp\\u003e\\u003c") }
|
||||
.firstOrNull { it.data().contains("img src") }
|
||||
?.data()
|
||||
?: return emptyList()
|
||||
|
||||
if (scriptContent != null) {
|
||||
val regex = Regex("""self\.__next_f\.push\(\[1,\"(.*)\"\]\)""")
|
||||
val htmlEncoded = regex.find(scriptContent)?.groupValues?.getOrNull(1)
|
||||
if (!htmlEncoded.isNullOrEmpty()) {
|
||||
val html = try {
|
||||
JSONArray("[\"$htmlEncoded\"]").getString(0)
|
||||
} catch (e: Exception) {
|
||||
htmlEncoded
|
||||
val decoded = scriptContent
|
||||
.replace("\\u003c", "<")
|
||||
.replace("\\u003e", ">")
|
||||
.replace("\\\"", "\"")
|
||||
.replace("\\/", "/")
|
||||
}
|
||||
|
||||
val imageUrls = Jsoup.parse(html).select("img").mapNotNull { it.attr("src") }
|
||||
if (imageUrls.isNotEmpty()) {
|
||||
val regex = Regex("""img\s+src=["'](https?://[^"']+)["']""")
|
||||
val imageUrls = regex.findAll(decoded).map { it.groupValues[1] }.toList()
|
||||
|
||||
return imageUrls.map { url ->
|
||||
MangaPage(
|
||||
id = generateUid(url),
|
||||
@@ -261,10 +254,6 @@ internal class TruyenHentai18(context: MangaLoaderContext):
|
||||
source = source,
|
||||
)
|
||||
}
|
||||
} else return emptyList()
|
||||
}
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
private fun parseChapterDate(date: String?): Long {
|
||||
|
||||
Reference in New Issue
Block a user