parent
a383626ae6
commit
d89120eb49
|
@ -46,6 +46,8 @@ abstract class MangaEsp(
|
|||
|
||||
protected open val seriesPath = "/ver"
|
||||
|
||||
protected open val useApiSearch = false
|
||||
|
||||
override val client: OkHttpClient = network.client.newBuilder()
|
||||
.rateLimitHost(baseUrl.toHttpUrl(), 2)
|
||||
.build()
|
||||
|
@ -62,7 +64,9 @@ abstract class MangaEsp(
|
|||
val topWeekly = responseData.response.topWeekly.flatten().map { it.data }
|
||||
val topMonthly = responseData.response.topMonthly.flatten().map { it.data }
|
||||
|
||||
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }.map { it.toSManga(seriesPath) }
|
||||
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }
|
||||
.additionalParse()
|
||||
.map { it.toSManga(seriesPath) }
|
||||
|
||||
return MangasPage(mangas, false)
|
||||
}
|
||||
|
@ -72,7 +76,9 @@ abstract class MangaEsp(
|
|||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val responseData = json.decodeFromString<LastUpdatesDto>(response.body.string())
|
||||
|
||||
val mangas = responseData.response.map { it.toSManga(seriesPath) }
|
||||
val mangas = responseData.response
|
||||
.additionalParse()
|
||||
.map { it.toSManga(seriesPath) }
|
||||
|
||||
return MangasPage(mangas, false)
|
||||
}
|
||||
|
@ -93,20 +99,33 @@ abstract class MangaEsp(
|
|||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl/comics", headers)
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return if (useApiSearch) {
|
||||
GET("$apiBaseUrl$apiPath/comics", headers)
|
||||
} else {
|
||||
GET("$baseUrl/comics", headers)
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaParse(response: Response): MangasPage = throw UnsupportedOperationException()
|
||||
|
||||
protected open fun searchMangaParse(response: Response, page: Int, query: String, filters: FilterList): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
val script = document.select("script:containsData(self.__next_f.push)").joinToString { it.data() }
|
||||
val jsonString = MANGA_LIST_REGEX.find(script)?.groupValues?.get(1)
|
||||
?: throw Exception(intl["comics_list_error"])
|
||||
val unescapedJson = jsonString.unescape()
|
||||
comicsList = json.decodeFromString<List<SeriesDto>>(unescapedJson).toMutableList()
|
||||
comicsList = if (useApiSearch) {
|
||||
json.decodeFromString<List<SeriesDto>>(response.body.string()).toMutableList()
|
||||
} else {
|
||||
val script = response.asJsoup().select("script:containsData(self.__next_f.push)").joinToString { it.data() }
|
||||
val jsonString = MANGA_LIST_REGEX.find(script)?.groupValues?.get(1)
|
||||
?: throw Exception(intl["comics_list_error"])
|
||||
val unescapedJson = jsonString.unescape()
|
||||
json.decodeFromString<List<SeriesDto>>(unescapedJson).toMutableList()
|
||||
}.additionalParse().toMutableList()
|
||||
return parseComicsList(page, query, filters)
|
||||
}
|
||||
|
||||
protected open fun List<SeriesDto>.additionalParse(): List<SeriesDto> {
|
||||
return this
|
||||
}
|
||||
|
||||
private var filteredList = mutableListOf<SeriesDto>()
|
||||
|
||||
protected open fun parseComicsList(page: Int, query: String, filterList: FilterList): MangasPage {
|
||||
|
|
|
@ -3,7 +3,7 @@ ext {
|
|||
extClass = '.EternalMangasFactory'
|
||||
themePkg = 'mangaesp'
|
||||
baseUrl = 'https://eternalmangas.com'
|
||||
overrideVersionCode = 1
|
||||
overrideVersionCode = 2
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,11 @@ package eu.kanade.tachiyomi.extension.all.eternalmangas
|
|||
|
||||
import eu.kanade.tachiyomi.multisrc.mangaesp.MangaEsp
|
||||
import eu.kanade.tachiyomi.multisrc.mangaesp.SeriesDto
|
||||
import eu.kanade.tachiyomi.multisrc.mangaesp.TopSeriesDto
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import okhttp3.FormBody
|
||||
|
@ -27,21 +24,7 @@ open class EternalMangas(
|
|||
"https://eternalmangas.com",
|
||||
lang,
|
||||
) {
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val body = response.body.string()
|
||||
val responseData = json.decodeFromString<TopSeriesDto>(body)
|
||||
|
||||
val topDaily = responseData.response.topDaily.flatten().map { it.data }
|
||||
val topWeekly = responseData.response.topWeekly.flatten().map { it.data }
|
||||
val topMonthly = responseData.response.topMonthly.flatten().map { it.data }
|
||||
|
||||
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }
|
||||
.filter { it.language == internalLang }
|
||||
.map { it.toSManga(seriesPath) }
|
||||
|
||||
return MangasPage(mangas, false)
|
||||
}
|
||||
override val useApiSearch = true
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val responseData = json.decodeFromString<LatestUpdatesDto>(response.body.string())
|
||||
|
@ -49,16 +32,8 @@ open class EternalMangas(
|
|||
return MangasPage(mangas, false)
|
||||
}
|
||||
|
||||
override fun searchMangaParse(response: Response, page: Int, query: String, filters: FilterList): MangasPage {
|
||||
val document = response.asJsoup()
|
||||
val script = document.select("script:containsData(self.__next_f.push)").joinToString { it.data() }
|
||||
val jsonString = MANGA_LIST_REGEX.find(script)?.groupValues?.get(1)
|
||||
?: throw Exception(intl["comics_list_error"])
|
||||
val unescapedJson = jsonString.unescape()
|
||||
comicsList = json.decodeFromString<List<SeriesDto>>(unescapedJson)
|
||||
.filter { it.language == internalLang }
|
||||
.toMutableList()
|
||||
return parseComicsList(page, query, filters)
|
||||
override fun List<SeriesDto>.additionalParse(): List<SeriesDto> {
|
||||
return this.filter { it.language == internalLang }.toMutableList()
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
||||
|
|
Loading…
Reference in New Issue