Skip to content

Commit

Permalink
fix(pt/animesdigital): Fetch all episodes on multi-page animes (#2242)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guaxinim5573 authored Sep 25, 2023
1 parent b936938 commit 4470008
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pt/animesdigital/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
extName = 'Animes Digital'
pkgNameSuffix = 'pt.animesdigital'
extClass = '.AnimesDigital'
extVersionCode = 1
extVersionCode = 2
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ class AnimesDigital : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
// ============================== Episodes ==============================
override fun episodeListParse(response: Response): List<SEpisode> {
val doc = getRealDoc(response.asJsoup())
return doc.select(episodeListSelector()).map(::episodeFromElement)
val pagination = doc.selectFirst("ul.content-pagination")
return if (pagination != null) {
val episodes = mutableListOf<SEpisode>()
episodes += doc.select(episodeListSelector()).map(::episodeFromElement)
val lastPage = doc.selectFirst("ul.content-pagination > li:nth-last-child(2) > span")!!.text().toInt()
for (i in 2..lastPage) {
val request = GET(doc.location() + "/page/$i", headers)
val res = client.newCall(request).execute()
val pageDoc = res.use { it.asJsoup() }
episodes += pageDoc.select(episodeListSelector()).map(::episodeFromElement)
}
episodes
} else doc.select(episodeListSelector()).map(::episodeFromElement)
}

override fun episodeFromElement(element: Element) = SEpisode.create().apply {
Expand Down

0 comments on commit 4470008

Please sign in to comment.