|
|
|
|
@ -1,20 +1,25 @@
|
|
|
|
|
package org.koitharu.kotatsu.parsers.site.liliana.vi
|
|
|
|
|
|
|
|
|
|
import org.jsoup.Jsoup
|
|
|
|
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
|
|
|
|
import org.koitharu.kotatsu.parsers.site.liliana.LilianaParser
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.getBooleanOrDefault
|
|
|
|
|
import org.koitharu.kotatsu.parsers.Broken
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
|
|
|
|
|
|
@Broken // cant fetch pages
|
|
|
|
|
@MangaSourceParser("DOCTRUYEN5S", "DocTruyen5s", "vi")
|
|
|
|
|
internal class DocTruyen5s(context: MangaLoaderContext) :
|
|
|
|
|
LilianaParser(context, MangaParserSource.DOCTRUYEN5S, "manga.io.vn", 42) {
|
|
|
|
|
LilianaParser(context, MangaParserSource.DOCTRUYEN5S, "dongmoe.com", 42) {
|
|
|
|
|
|
|
|
|
|
override val configKeyDomain: ConfigKey.Domain = ConfigKey.Domain("dongmoe.com", "manga.io.vn")
|
|
|
|
|
|
|
|
|
|
override fun getRequestHeaders() = super.getRequestHeaders().newBuilder()
|
|
|
|
|
.add("referer", "no-referrer")
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
|
|
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
|
|
|
|
|
val fullUrl = chapter.url.toAbsoluteUrl(domain)
|
|
|
|
|
@ -35,14 +40,45 @@ internal class DocTruyen5s(context: MangaLoaderContext) :
|
|
|
|
|
|
|
|
|
|
val pageListDoc = Jsoup.parse(responseJson.getString("html"))
|
|
|
|
|
|
|
|
|
|
return pageListDoc.selectOrThrow("div.separator a").map { element ->
|
|
|
|
|
val url = element.attr("href")
|
|
|
|
|
MangaPage(
|
|
|
|
|
id = generateUid(url),
|
|
|
|
|
url = url,
|
|
|
|
|
preview = null,
|
|
|
|
|
source = source,
|
|
|
|
|
)
|
|
|
|
|
return pageListDoc.selectOrThrow("div.separator a").mapNotNull { element ->
|
|
|
|
|
val originalUrl = element.attr("href").takeIf { it.isNotEmpty() } ?: element.attr("src")
|
|
|
|
|
if (originalUrl.isEmpty()) return@mapNotNull null
|
|
|
|
|
|
|
|
|
|
val workingUrl = addCdnServers(originalUrl).firstOrNull { url ->
|
|
|
|
|
checkMangaImgs(url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workingUrl?.let { url ->
|
|
|
|
|
MangaPage(
|
|
|
|
|
id = generateUid(url),
|
|
|
|
|
url = url,
|
|
|
|
|
preview = null,
|
|
|
|
|
source = source,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun addCdnServers(url: String): List<String> {
|
|
|
|
|
if (!url.startsWith("http")) return emptyList()
|
|
|
|
|
|
|
|
|
|
val urlFinal = url.replace("https://", "")
|
|
|
|
|
return listOf(
|
|
|
|
|
url,
|
|
|
|
|
"https://proxy.luce.workers.dev/$url",
|
|
|
|
|
"https://images2-focus-opensocial.googleusercontent.com/gadgets/proxy?url=$url&container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image/*",
|
|
|
|
|
"https://i0.wp.com/$urlFinal",
|
|
|
|
|
"https://cdn.statically.io/img/$urlFinal"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private suspend fun checkMangaImgs(url: String): Boolean {
|
|
|
|
|
return try {
|
|
|
|
|
val response = webClient.httpHead(url)
|
|
|
|
|
val contentType = response.header("Content-Type") ?: ""
|
|
|
|
|
contentType.startsWith("image/")
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|