[NepNep] Fixes

Koitharu 3 years ago
parent 5035c90c73
commit 3a76504380
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -25,7 +25,6 @@ internal abstract class NepnepParser(
override val sortOrders: Set<SortOrder> = EnumSet.of(SortOrder.ALPHABETICAL) override val sortOrders: Set<SortOrder> = EnumSet.of(SortOrder.ALPHABETICAL)
override val headers: Headers = Headers.Builder() override val headers: Headers = Headers.Builder()
.add("User-Agent", UserAgents.CHROME_DESKTOP) .add("User-Agent", UserAgents.CHROME_DESKTOP)
.build() .build()
@ -37,7 +36,9 @@ internal abstract class NepnepParser(
val doc = webClient.httpGet("https://$domain/search/").parseHtml() val doc = webClient.httpGet("https://$domain/search/").parseHtml()
val json = JSONArray( val json = JSONArray(
doc.selectFirstOrThrow("script:containsData(MainFunction)").data() doc.selectFirstOrThrow("script:containsData(MainFunction)").data()
.substringAfter("vm.Directory = ").substringBefore("vm.GetIntValue").trim() .substringAfter("vm.Directory = ")
.substringBefore("vm.GetIntValue")
.trim()
.replace(';', ' '), .replace(';', ' '),
) )
@ -48,36 +49,58 @@ internal abstract class NepnepParser(
val m = json.getJSONObject(i) val m = json.getJSONObject(i)
val href = "/manga/" + m.getString("i") val href = "/manga/" + m.getString("i")
val imgUrl = "https://temp.compsci88.com/cover/" + m.getString("i") + ".jpg" val imgUrl = "https://temp.compsci88.com/cover/" + m.getString("i") + ".jpg"
if (!query.isNullOrEmpty()) { when {
if (m.getString("i").contains(query.urlEncoded(), ignoreCase = true)) { !query.isNullOrEmpty() -> {
manga.add( if (m.getString("i").contains(query.urlEncoded(), ignoreCase = true)) {
Manga( manga.add(
id = generateUid(href), Manga(
title = m.getString("i").replace('-', ' '), id = generateUid(href),
altTitle = null, title = m.getString("i").replace('-', ' '),
url = href, altTitle = null,
publicUrl = href.toAbsoluteUrl(domain), url = href,
rating = RATING_UNKNOWN, publicUrl = href.toAbsoluteUrl(domain),
isNsfw = false, rating = RATING_UNKNOWN,
coverUrl = imgUrl, isNsfw = false,
tags = emptySet(), coverUrl = imgUrl,
state = null, tags = emptySet(),
author = null, state = null,
source = source, author = null,
), source = source,
) ),
} )
}
} else if (!tags.isNullOrEmpty()) { }
val a = m.getJSONArray("g").toString() !tags.isNullOrEmpty() -> {
var found = true val a = m.getJSONArray("g").toString()
tags.forEach { var found = true
if (!a.contains(it.key, ignoreCase = true)) { tags.forEach {
found = false if (!a.contains(it.key, ignoreCase = true)) {
found = false
}
}
if (found) {
manga.add(
Manga(
id = generateUid(href),
title = m.getString("i").replace('-', ' '),
altTitle = null,
url = href,
publicUrl = href.toAbsoluteUrl(domain),
rating = RATING_UNKNOWN,
isNsfw = false,
coverUrl = imgUrl,
tags = emptySet(),
state = null,
author = null,
source = source,
),
)
} }
} }
if (found) {
else -> {
manga.add( manga.add(
Manga( Manga(
id = generateUid(href), id = generateUid(href),
@ -95,23 +118,6 @@ internal abstract class NepnepParser(
), ),
) )
} }
} else {
manga.add(
Manga(
id = generateUid(href),
title = m.getString("i").replace('-', ' '),
altTitle = null,
url = href,
publicUrl = href.toAbsoluteUrl(domain),
rating = RATING_UNKNOWN,
isNsfw = false,
coverUrl = imgUrl,
tags = emptySet(),
state = null,
author = null,
source = source,
),
)
} }
@ -123,7 +129,8 @@ internal abstract class NepnepParser(
override suspend fun getTags(): Set<MangaTag> { override suspend fun getTags(): Set<MangaTag> {
val doc = webClient.httpGet("https://$domain/search/").parseHtml() val doc = webClient.httpGet("https://$domain/search/").parseHtml()
val tags = doc.selectFirstOrThrow("script:containsData(vm.AvailableFilters)").data() val tags = doc.selectFirstOrThrow("script:containsData(vm.AvailableFilters)").data()
.substringAfter("\"Genre\" \t\t: [") .substringAfter("\"Genre\"")
.substringAfter('[')
.substringBefore(']') .substringBefore(']')
.replace("'", "") .replace("'", "")
.split(',') .split(',')
@ -143,7 +150,8 @@ internal abstract class NepnepParser(
val chapter = JSONArray( val chapter = JSONArray(
JSONArray( JSONArray(
doc.selectFirstOrThrow("script:containsData(MainFunction)").data() doc.selectFirstOrThrow("script:containsData(MainFunction)").data()
.substringAfter("vm.Chapters = ").substringBefore(';'), .substringAfter("vm.Chapters = ")
.substringBefore(';'),
).toJSONList().reversed(), ).toJSONList().reversed(),
) )
@ -243,18 +251,14 @@ internal abstract class NepnepParser(
.substringBefore(';'), .substringBefore(';'),
) )
val pageTotal = curChapter.getString("Page")!!.toInt() val pageTotal = curChapter.getString("Page")!!.toInt()
val host = "https://" + val host = "https://" + script
script .substringAfter("vm.CurPathName = \"", "")
.substringAfter("vm.CurPathName = \"", "") .substringBefore('"')
.substringBefore('"') check(host.isNotEmpty()) {
.also { "Manga4Life is overloaded and blocking Kotatsu right now. Wait for unblock."
if (it.isEmpty()) { }
throw Exception("Manga4Life is overloaded and blocking kotatsu right now. Wait for unblock.")
}
}
val titleURI = script.substringAfter("vm.IndexName = \"").substringBefore("\"") val titleURI = script.substringAfter("vm.IndexName = \"").substringBefore("\"")
val seasonURI = curChapter.getString("Directory")!! val seasonURI = curChapter.getString("Directory")!!.let { if (it.isEmpty()) "" else "$it/" }
.let { if (it.isEmpty()) "" else "$it/" }
val path = "$host/manga/$titleURI/$seasonURI" val path = "$host/manga/$titleURI/$seasonURI"
val chNum = chapterImage(curChapter.getString("Chapter")!!) val chNum = chapterImage(curChapter.getString("Chapter")!!)

Loading…
Cancel
Save