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