Comicpunch - fix chapters and pages not loading (#3828)

* Fix comicpunch chapters/pages.

* Be a bit safer when grabbing urls

* Fix placeholder checking on last chapter

* Simplify and fix pages

Previous commit was broken, should work now.

* Remove useless override/import
This commit is contained in:
Kelvin Porter 2020-07-18 13:39:08 -04:00 committed by GitHub
parent d06f46db7f
commit 3db7d26574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Comicpunch'
pkgNameSuffix = 'en.comicpunch'
extClass = '.Comicpunch'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -116,7 +116,7 @@ class Comicpunch : ParsedHttpSource() {
var elements = response.asJsoup().select(chapterListSelector()).toList()
// Check if latest chapter is just a placeholder, drop it if it is
client.newCall(GET(elements[0].attr("abs:href"), headers)).execute().asJsoup().select("img.picture").attr("src").let { img ->
client.newCall(GET(elements[0].attr("abs:href"), headers)).execute().asJsoup().select("img").last().attr("src").let { img ->
if (img.contains("placeholder", ignoreCase = true)) elements = elements.drop(1)
}
elements.map { chapters.add(chapterFromElement(it)) }
@ -124,7 +124,7 @@ class Comicpunch : ParsedHttpSource() {
return chapters
}
override fun chapterListSelector() = "div#chapterlist li.chapter a"
override fun chapterListSelector() = "li.chapter a"
override fun chapterFromElement(element: Element): SChapter {
val chapter = SChapter.create()
@ -137,15 +137,14 @@ class Comicpunch : ParsedHttpSource() {
// Pages
override fun pageListRequest(chapter: SChapter): Request {
return GET(baseUrl + chapter.url + "/?q=fullchapter", headers)
}
override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>()
document.select("img.picture").forEachIndexed { i, img ->
pages.add(Page(i, "", img.attr("abs:src")))
val pageUrls = document.select("div#code_contain > script")
.eq(1).first().data()
.substringAfter("= [").substringBefore("]").split(",")
pageUrls.forEachIndexed { i, img ->
pages.add(Page(i, "", img.removeSurrounding("\"")))
}
return pages