Fix Exhentai
This commit is contained in:
parent
222762b778
commit
f592436d55
@ -1,12 +1,13 @@
|
||||
package eu.kanade.data.source
|
||||
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.model.MetadataMangasPage
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
|
||||
abstract class EHentaiPagingSource(source: CatalogueSource) : SourcePagingSource(source) {
|
||||
abstract class EHentaiPagingSource(override val source: EHentai) : SourcePagingSource(source) {
|
||||
|
||||
private var lastMangaLink: String? = null
|
||||
|
||||
@ -15,7 +16,13 @@ abstract class EHentaiPagingSource(source: CatalogueSource) : SourcePagingSource
|
||||
override suspend fun requestNextPage(currentPage: Int): MangasPage {
|
||||
val lastMangaLink = lastMangaLink
|
||||
|
||||
val mangasPage = fetchNextPage(currentPage)
|
||||
val gid = if (lastMangaLink != null && source.exh) {
|
||||
EHentaiSearchMetadata.galleryId(lastMangaLink).toInt()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val mangasPage = fetchNextPage(gid ?: currentPage)
|
||||
|
||||
mangasPage.mangas.lastOrNull()?.let {
|
||||
this.lastMangaLink = it.url
|
||||
@ -44,19 +51,19 @@ abstract class EHentaiPagingSource(source: CatalogueSource) : SourcePagingSource
|
||||
}
|
||||
}
|
||||
|
||||
class EHentaiSearchPagingSource(source: CatalogueSource, val query: String, val filters: FilterList) : EHentaiPagingSource(source) {
|
||||
class EHentaiSearchPagingSource(source: EHentai, val query: String, val filters: FilterList) : EHentaiPagingSource(source) {
|
||||
override suspend fun fetchNextPage(currentPage: Int): MangasPage {
|
||||
return source.fetchSearchManga(currentPage, query, filters).awaitSingle()
|
||||
}
|
||||
}
|
||||
|
||||
class EHentaiPopularPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) {
|
||||
class EHentaiPopularPagingSource(source: EHentai) : EHentaiPagingSource(source) {
|
||||
override suspend fun fetchNextPage(currentPage: Int): MangasPage {
|
||||
return source.fetchPopularManga(currentPage).awaitSingle()
|
||||
}
|
||||
}
|
||||
|
||||
class EHentaiLatestPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) {
|
||||
class EHentaiLatestPagingSource(source: EHentai) : EHentaiPagingSource(source) {
|
||||
override suspend fun fetchNextPage(currentPage: Int): MangasPage {
|
||||
return source.fetchLatestUpdates(currentPage).awaitSingle()
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
|
||||
abstract class SourcePagingSource(
|
||||
protected val source: CatalogueSource,
|
||||
protected open val source: CatalogueSource,
|
||||
) : SourcePagingSourceType() {
|
||||
|
||||
abstract suspend fun requestNextPage(currentPage: Int): MangasPage
|
||||
|
@ -9,8 +9,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import exh.source.isEhBasedSource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
@ -62,7 +62,7 @@ class SourceRepositoryImpl(
|
||||
): SourcePagingSourceType {
|
||||
val source = sourceManager.get(sourceId) as CatalogueSource
|
||||
// SY -->
|
||||
if (source.isEhBasedSource()) {
|
||||
if (source is EHentai) {
|
||||
return EHentaiSearchPagingSource(source, query, filterList)
|
||||
}
|
||||
// SY <--
|
||||
@ -72,7 +72,7 @@ class SourceRepositoryImpl(
|
||||
override fun getPopular(sourceId: Long): SourcePagingSourceType {
|
||||
val source = sourceManager.get(sourceId) as CatalogueSource
|
||||
// SY -->
|
||||
if (source.isEhBasedSource()) {
|
||||
if (source is EHentai) {
|
||||
return EHentaiPopularPagingSource(source)
|
||||
}
|
||||
// SY <--
|
||||
@ -82,7 +82,7 @@ class SourceRepositoryImpl(
|
||||
override fun getLatest(sourceId: Long): SourcePagingSourceType {
|
||||
val source = sourceManager.get(sourceId) as CatalogueSource
|
||||
// SY -->
|
||||
if (source.isEhBasedSource()) {
|
||||
if (source is EHentai) {
|
||||
return EHentaiLatestPagingSource(source)
|
||||
}
|
||||
// SY <--
|
||||
|
@ -240,9 +240,14 @@ class EHentai(
|
||||
val hasNextPage = if (parsedLocation == null ||
|
||||
!parsedLocation.queryParameterNames.contains(REVERSE_PARAM)
|
||||
) {
|
||||
select("a[onclick=return false]").last()?.let {
|
||||
it.text() == ">"
|
||||
} ?: false
|
||||
select("a[onclick=return false]").last()
|
||||
?.let {
|
||||
it.text() == ">"
|
||||
}
|
||||
?: select(".searchnav >div > a")
|
||||
.find { it.attr("href").contains("next") }
|
||||
?.let { true }
|
||||
?: false
|
||||
} else {
|
||||
parsedLocation.queryParameter(REVERSE_PARAM)!!.toBoolean()
|
||||
}
|
||||
@ -528,10 +533,18 @@ class EHentai(
|
||||
override fun searchMangaParse(response: Response) = genericMangaParse(response)
|
||||
override fun latestUpdatesParse(response: Response) = genericMangaParse(response)
|
||||
|
||||
private fun exGet(url: String, page: Int? = null, additionalHeaders: Headers? = null, cacheControl: CacheControl? = null): Request {
|
||||
private fun exGet(url: String, next: Int? = null, additionalHeaders: Headers? = null, cacheControl: CacheControl? = null): Request {
|
||||
return GET(
|
||||
if (page != null) {
|
||||
addParam(url, "page", (page - 1).toString())
|
||||
if (next != null) {
|
||||
if (exh) {
|
||||
if (next > 1) {
|
||||
addParam(url, "next", next.toString())
|
||||
} else {
|
||||
url
|
||||
}
|
||||
} else {
|
||||
addParam(url, "page", (next - 1).toString())
|
||||
}
|
||||
} else {
|
||||
url
|
||||
},
|
||||
@ -777,7 +790,7 @@ class EHentai(
|
||||
client.newCall(
|
||||
exGet(
|
||||
favoriteUrl,
|
||||
page = page,
|
||||
next = page,
|
||||
cacheControl = CacheControl.FORCE_NETWORK,
|
||||
),
|
||||
).awaitResponse()
|
||||
@ -796,7 +809,7 @@ class EHentai(
|
||||
}
|
||||
// Next page
|
||||
|
||||
page++
|
||||
page = parsed.first.lastOrNull()?.manga?.url?.let { EHentaiSearchMetadata.galleryId(it) }?.toInt() ?: 0
|
||||
} while (parsed.second)
|
||||
|
||||
return Pair(result.toList(), favNames.orEmpty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user