fix: animePage hasNextPage for popular, search, and latest

This commit is contained in:
hasanpasha 2025-02-22 18:43:37 +03:00
parent b7b46498c7
commit f5ea928758

View file

@ -225,7 +225,7 @@ class ShabakatyCinemana : ConfigurableAnimeSource, AnimeHttpSource() {
override fun latestUpdatesParse(response: Response): AnimesPage {
val animeList = response.asModelList(SAnimeDeserializer)
return AnimesPage(animeList, animeList.size < LATEST_ITEMS_PER_PAGE)
return AnimesPage(animeList, animeList.size == LATEST_ITEMS_PER_PAGE)
}
override fun popularAnimeRequest(page: Int): Request {
@ -239,7 +239,7 @@ class ShabakatyCinemana : ConfigurableAnimeSource, AnimeHttpSource() {
override fun popularAnimeParse(response: Response): AnimesPage {
val animeList = response.asModelList(SAnimeDeserializer)
return AnimesPage(animeList, animeList.size < POPULAR_ITEMS_PER_PAGE)
return AnimesPage(animeList, animeList.size == POPULAR_ITEMS_PER_PAGE)
}
override suspend fun getSearchAnime(
@ -295,10 +295,11 @@ class ShabakatyCinemana : ConfigurableAnimeSource, AnimeHttpSource() {
val resp = client.newCall(GET(url, headers)).execute()
// Todo: remove SAnimeWithInfo data class if no longer needed
val animeListWithInfo = resp.asModel(SAnimeWithInfoDeserializer)
return AnimesPage(animeListWithInfo.animes, animeListWithInfo.animes.isNotEmpty())
return AnimesPage(animeListWithInfo.animes, animeListWithInfo.animes.size == POPULAR_ITEMS_PER_PAGE)
} else {
// star=8&year=1900,2025
url = url.newBuilder()
.addQueryParameter("level", "0")
.addPathSegment("AdvancedSearch")
.addQueryParameter("type", kindName)
.addQueryParameter("page", "${page - 1}")
@ -310,13 +311,17 @@ class ShabakatyCinemana : ConfigurableAnimeSource, AnimeHttpSource() {
}
if (query.isNotBlank()) {
url = url.newBuilder().addQueryParameter("videoTitle", query).build()
url = url.newBuilder()
.addQueryParameter("videoTitle", query)
.addQueryParameter("staffTitle", query)
.build()
}
println(url)
val resp = client.newCall(GET(url, headers)).execute()
val animeList = resp.asModelList(SAnimeDeserializer)
return AnimesPage(animeList, animeList.size < SEARCH_ITEMS_PER_PAGE)
println("search has next page: ${animeList.size} == $SEARCH_ITEMS_PER_PAGE ${animeList.size == SEARCH_ITEMS_PER_PAGE}")
return AnimesPage(animeList, animeList.size == SEARCH_ITEMS_PER_PAGE)
}
}