|
|
|
@ -1,7 +1,7 @@
|
|
|
|
package org.koitharu.kotatsu.parsers.site.en
|
|
|
|
package org.koitharu.kotatsu.parsers.site.en
|
|
|
|
|
|
|
|
|
|
|
|
import org.jsoup.nodes.Document
|
|
|
|
import org.json.JSONObject
|
|
|
|
import org.jsoup.nodes.Element
|
|
|
|
import org.koitharu.kotatsu.parsers.Broken
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
|
|
import org.koitharu.kotatsu.parsers.config.ConfigKey
|
|
|
|
@ -9,14 +9,13 @@ import org.koitharu.kotatsu.parsers.core.LegacyPagedMangaParser
|
|
|
|
import org.koitharu.kotatsu.parsers.exception.ParseException
|
|
|
|
import org.koitharu.kotatsu.parsers.exception.ParseException
|
|
|
|
import org.koitharu.kotatsu.parsers.model.*
|
|
|
|
import org.koitharu.kotatsu.parsers.model.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.getFloatOrDefault
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.suspendlazy.getOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.suspendlazy.getOrNull
|
|
|
|
import org.koitharu.kotatsu.parsers.util.suspendlazy.suspendLazy
|
|
|
|
import org.koitharu.kotatsu.parsers.util.suspendlazy.suspendLazy
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
import java.util.*
|
|
|
|
import java.util.*
|
|
|
|
import org.json.JSONObject
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.Broken
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Broken("Need fix tags in getDetails")
|
|
|
|
|
|
|
|
@MangaSourceParser("BATCAVE", "BatCave", "en")
|
|
|
|
@MangaSourceParser("BATCAVE", "BatCave", "en")
|
|
|
|
internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
LegacyPagedMangaParser(context, MangaParserSource.BATCAVE, 20) {
|
|
|
|
LegacyPagedMangaParser(context, MangaParserSource.BATCAVE, 20) {
|
|
|
|
@ -36,12 +35,11 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
get() = MangaListFilterCapabilities(
|
|
|
|
get() = MangaListFilterCapabilities(
|
|
|
|
isSearchSupported = true,
|
|
|
|
isSearchSupported = true,
|
|
|
|
isMultipleTagsSupported = true,
|
|
|
|
isMultipleTagsSupported = true,
|
|
|
|
isSearchWithFiltersSupported = false,
|
|
|
|
isYearRangeSupported = true,
|
|
|
|
isYearRangeSupported = true
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getFilterOptions() = MangaListFilterOptions(
|
|
|
|
override suspend fun getFilterOptions() = MangaListFilterOptions(
|
|
|
|
availableTags = availableTags.get()
|
|
|
|
availableTags = availableTags.get(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getListPage(page: Int, order: SortOrder, filter: MangaListFilter): List<Manga> {
|
|
|
|
override suspend fun getListPage(page: Int, order: SortOrder, filter: MangaListFilter): List<Manga> {
|
|
|
|
@ -52,6 +50,7 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
urlBuilder.append(filter.query.urlEncoded())
|
|
|
|
urlBuilder.append(filter.query.urlEncoded())
|
|
|
|
if (page > 1) urlBuilder.append("/page/$page/")
|
|
|
|
if (page > 1) urlBuilder.append("/page/$page/")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else -> {
|
|
|
|
else -> {
|
|
|
|
urlBuilder.append("/ComicList")
|
|
|
|
urlBuilder.append("/ComicList")
|
|
|
|
if (filter.yearFrom != YEAR_UNKNOWN) {
|
|
|
|
if (filter.yearFrom != YEAR_UNKNOWN) {
|
|
|
|
@ -65,20 +64,22 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
urlBuilder.append(filter.tags.joinToString(",") { it.key })
|
|
|
|
urlBuilder.append(filter.tags.joinToString(",") { it.key })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
urlBuilder.append("/sort")
|
|
|
|
urlBuilder.append("/sort")
|
|
|
|
if (page > 1) { urlBuilder.append("/page/$page/") }
|
|
|
|
if (page > 1) {
|
|
|
|
|
|
|
|
urlBuilder.append("/page/$page/")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val fullUrl = urlBuilder.toString().toAbsoluteUrl(domain)
|
|
|
|
val fullUrl = urlBuilder.toString().toAbsoluteUrl(domain)
|
|
|
|
val doc = webClient.httpGet(fullUrl).parseHtml()
|
|
|
|
val doc = webClient.httpGet(fullUrl).parseHtml()
|
|
|
|
return doc.select("div.readed.d-flex.short").map { item ->
|
|
|
|
return doc.select("div.readed.d-flex.short").map { item ->
|
|
|
|
val a = item.selectFirst("a.readed__img.img-fit-cover.anim")
|
|
|
|
val a = item.selectFirstOrThrow("a.readed__img.img-fit-cover.anim")
|
|
|
|
?: throw ParseException("Link element not found!", fullUrl)
|
|
|
|
val titleElement = item.selectFirstOrThrow("h2.readed__title a")
|
|
|
|
val img = item.selectFirst("img[data-src]")
|
|
|
|
val img = item.selectFirst("img[data-src]")
|
|
|
|
val titleElement = item.selectFirst("h2.readed__title a")
|
|
|
|
val href = a.attrAsRelativeUrl("href")
|
|
|
|
Manga(
|
|
|
|
Manga(
|
|
|
|
id = generateUid(a.attr("href")),
|
|
|
|
id = generateUid(href),
|
|
|
|
url = a.attr("href"),
|
|
|
|
url = href,
|
|
|
|
publicUrl = a.attr("href"),
|
|
|
|
publicUrl = a.attr("href"),
|
|
|
|
title = titleElement.text(),
|
|
|
|
title = titleElement.text(),
|
|
|
|
altTitles = emptySet(),
|
|
|
|
altTitles = emptySet(),
|
|
|
|
@ -87,7 +88,7 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
tags = emptySet(),
|
|
|
|
tags = emptySet(),
|
|
|
|
rating = RATING_UNKNOWN,
|
|
|
|
rating = RATING_UNKNOWN,
|
|
|
|
state = null,
|
|
|
|
state = null,
|
|
|
|
coverUrl = img.attr("data-src")?.toAbsoluteUrl(domain),
|
|
|
|
coverUrl = img?.attrAsAbsoluteUrlOrNull("data-src"),
|
|
|
|
contentRating = if (isNsfwSource) ContentRating.ADULT else null,
|
|
|
|
contentRating = if (isNsfwSource) ContentRating.ADULT else null,
|
|
|
|
source = source,
|
|
|
|
source = source,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -102,24 +103,22 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
val scriptData = doc.selectFirst("script:containsData(__DATA__)")?.data()
|
|
|
|
val scriptData = doc.selectFirst("script:containsData(__DATA__)")?.data()
|
|
|
|
?.substringAfter("window.__DATA__ = ")
|
|
|
|
?.substringAfter("window.__DATA__ = ")
|
|
|
|
?.substringBefore(";")
|
|
|
|
?.substringBefore(";")
|
|
|
|
?: throw ParseException("Script data not found", manga.url)
|
|
|
|
?: doc.parseFailed("Script data not found")
|
|
|
|
|
|
|
|
|
|
|
|
val jsonData = JSONObject(scriptData)
|
|
|
|
val jsonData = JSONObject(scriptData)
|
|
|
|
val newsId = jsonData.getInt("news_id")
|
|
|
|
val newsId = jsonData.getLong("news_id")
|
|
|
|
val chaptersJson = jsonData.getJSONArray("chapters")
|
|
|
|
val chaptersJson = jsonData.getJSONArray("chapters")
|
|
|
|
|
|
|
|
|
|
|
|
val chapters = (0 until chaptersJson.length()).map { i ->
|
|
|
|
val chapters = List(chaptersJson.length()) { i ->
|
|
|
|
val chapter = chaptersJson.getJSONObject(i)
|
|
|
|
val chapter = chaptersJson.getJSONObject(i)
|
|
|
|
val chapterId = chapter.getInt("id")
|
|
|
|
val chapterId = chapter.getLong("id")
|
|
|
|
|
|
|
|
|
|
|
|
MangaChapter(
|
|
|
|
MangaChapter(
|
|
|
|
id = generateUid("/reader/$newsId/$chapterId"),
|
|
|
|
id = generateUid("$newsId/$chapterId"),
|
|
|
|
url = "/reader/$newsId/$chapterId",
|
|
|
|
url = "/reader/$newsId/$chapterId",
|
|
|
|
number = chapter.getInt("posi").toFloat(),
|
|
|
|
number = chapter.getFloatOrDefault("posi", 0f),
|
|
|
|
title = chapter.getString("title"),
|
|
|
|
title = chapter.getStringOrNull("title"),
|
|
|
|
uploadDate = runCatching {
|
|
|
|
uploadDate = dateFormat.tryParse(chapter.getStringOrNull("date")),
|
|
|
|
dateFormat.parse(chapter.getString("date"))?.time
|
|
|
|
|
|
|
|
}.getOrNull() ?: 0L,
|
|
|
|
|
|
|
|
source = source,
|
|
|
|
source = source,
|
|
|
|
scanlator = null,
|
|
|
|
scanlator = null,
|
|
|
|
branch = null,
|
|
|
|
branch = null,
|
|
|
|
@ -127,24 +126,36 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val author = doc.selectFirst("li:contains(Publisher:)")?.text()?.substringAfter("Publisher:")?.trim()
|
|
|
|
val author = doc.selectFirst("li:contains(Publisher:)")
|
|
|
|
val state = when (doc.selectFirst("li:contains(Release type:)")?.text()?.substringAfter("Release type:")?.trim()) {
|
|
|
|
?.textOrNull()
|
|
|
|
|
|
|
|
?.substringAfter("Publisher:")
|
|
|
|
|
|
|
|
?.trim()
|
|
|
|
|
|
|
|
?.nullIfEmpty()
|
|
|
|
|
|
|
|
val state = when (
|
|
|
|
|
|
|
|
doc.selectFirst("li:contains(Release type:)")?.text()?.substringAfter("Release type:")?.trim()
|
|
|
|
|
|
|
|
) {
|
|
|
|
"Ongoing" -> MangaState.ONGOING
|
|
|
|
"Ongoing" -> MangaState.ONGOING
|
|
|
|
else -> MangaState.FINISHED
|
|
|
|
else -> MangaState.FINISHED
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val allTags = availableTags.get()
|
|
|
|
val tagLinks = doc.getElementsByAttributeValueContaining("href", "/genres/")
|
|
|
|
val tags = doc.select("div.page__tags.d-flex a").mapNotNullToSet { a ->
|
|
|
|
val tags = if (tagLinks.isNotEmpty()) {
|
|
|
|
|
|
|
|
availableTags.getOrNull()?.let { allTags ->
|
|
|
|
|
|
|
|
tagLinks.mapNotNullToSet { a ->
|
|
|
|
val tagName = a.text()
|
|
|
|
val tagName = a.text()
|
|
|
|
allTags.find { it.title.equals(tagName, ignoreCase = true) }
|
|
|
|
allTags.find { it.title.equals(tagName, ignoreCase = true) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return manga.copy(
|
|
|
|
return manga.copy(
|
|
|
|
authors = setOfNotNull(author),
|
|
|
|
authors = setOfNotNull(author),
|
|
|
|
state = state,
|
|
|
|
state = state,
|
|
|
|
chapters = chapters,
|
|
|
|
chapters = chapters,
|
|
|
|
description = doc.select("div.page__text.full-text.clearfix").text(),
|
|
|
|
description = doc.select("div.page__text.full-text.clearfix").textOrNull(),
|
|
|
|
tags = tags
|
|
|
|
tags = tags ?: manga.tags,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -165,15 +176,14 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
id = generateUid(imageUrl),
|
|
|
|
id = generateUid(imageUrl),
|
|
|
|
url = imageUrl,
|
|
|
|
url = imageUrl,
|
|
|
|
preview = null,
|
|
|
|
preview = null,
|
|
|
|
source = source
|
|
|
|
source = source,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun fetchTags(): Set<MangaTag> {
|
|
|
|
private suspend fun fetchTags(): Set<MangaTag> {
|
|
|
|
val doc = webClient.httpGet("https://$domain/comix/").parseHtml()
|
|
|
|
val doc = webClient.httpGet("https://$domain/comix/").parseHtml()
|
|
|
|
val scriptData = doc.selectFirst("script:containsData(__XFILTER__)")?.data()
|
|
|
|
val scriptData = doc.selectFirstOrThrow("script:containsData(__XFILTER__)").data()
|
|
|
|
?: throw ParseException("Script data not found", "$domain/genres")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val genresJson = scriptData
|
|
|
|
val genresJson = scriptData
|
|
|
|
.substringAfter("\"g\":{")
|
|
|
|
.substringAfter("\"g\":{")
|
|
|
|
@ -182,13 +192,13 @@ internal class BatCave(context: MangaLoaderContext) :
|
|
|
|
val genresObj = JSONObject("{$genresJson}")
|
|
|
|
val genresObj = JSONObject("{$genresJson}")
|
|
|
|
val valuesArray = genresObj.getJSONArray("values")
|
|
|
|
val valuesArray = genresObj.getJSONArray("values")
|
|
|
|
|
|
|
|
|
|
|
|
return (0 until valuesArray.length()).map { i ->
|
|
|
|
return Set(valuesArray.length()) { i ->
|
|
|
|
val genre = valuesArray.getJSONObject(i)
|
|
|
|
val genre = valuesArray.getJSONObject(i)
|
|
|
|
MangaTag(
|
|
|
|
MangaTag(
|
|
|
|
key = genre.getInt("id").toString(),
|
|
|
|
key = genre.getInt("id").toString(),
|
|
|
|
title = genre.getString("value"),
|
|
|
|
title = genre.getString("value").toTitleCase(sourceLocale),
|
|
|
|
source = source
|
|
|
|
source = source,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}.toSet()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|