Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pt/animesdigital): Fetch all episodes on multi-page animes #2242

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,22 @@ 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 = emptyList<SEpisode>().toMutableList()
Guaxinim5573 marked this conversation as resolved.
Show resolved Hide resolved
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 = Request.Builder()
.url(response.request.url.toString() + "/page/$i")
.addHeader("Referer", baseUrl)
.build()
Guaxinim5573 marked this conversation as resolved.
Show resolved Hide resolved
val res = client.newCall(request).execute()
val pageDoc = getRealDoc(res.asJsoup())
Guaxinim5573 marked this conversation as resolved.
Show resolved Hide resolved
episodes += pageDoc.select(episodeListSelector()).map(::episodeFromElement)
}
episodes
} else doc.select(episodeListSelector()).map(::episodeFromElement)
}

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