Fix Batoto empty results
This commit is contained in:
@@ -62,12 +62,7 @@ class BatoToRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
||||
append("&page=")
|
||||
append(page)
|
||||
}
|
||||
val body = loaderContext.httpGet(url).parseHtml().body()
|
||||
val activePage = getActivePage(body)
|
||||
if (activePage != page) {
|
||||
return emptyList()
|
||||
}
|
||||
return parseList(body.getElementById("series-list") ?: parseFailed("Cannot find root"))
|
||||
return parseList(url, page)
|
||||
}
|
||||
|
||||
override suspend fun getDetails(manga: Manga): Manga {
|
||||
@@ -170,12 +165,7 @@ class BatoToRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
||||
append("&page=")
|
||||
append(page)
|
||||
}
|
||||
val body = loaderContext.httpGet(url).parseHtml().body()
|
||||
val activePage = getActivePage(body)
|
||||
if (activePage != page) {
|
||||
return emptyList()
|
||||
}
|
||||
return parseList(body.getElementById("series-list") ?: parseFailed("Cannot find root"))
|
||||
return parseList(url, page)
|
||||
}
|
||||
|
||||
private fun getActivePage(body: Element): Int = body.select("nav ul.pagination > li.page-item.active")
|
||||
@@ -183,7 +173,17 @@ class BatoToRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
||||
?.text()
|
||||
?.toIntOrNull() ?: parseFailed("Cannot determine current page")
|
||||
|
||||
private fun parseList(root: Element) = root.children().map { div ->
|
||||
private suspend fun parseList(url: String, page: Int): List<Manga> {
|
||||
val body = loaderContext.httpGet(url).parseHtml().body()
|
||||
if (body.selectFirst(".browse-no-matches") != null) {
|
||||
return emptyList()
|
||||
}
|
||||
val activePage = getActivePage(body)
|
||||
if (activePage != page) {
|
||||
return emptyList()
|
||||
}
|
||||
val root = body.getElementById("series-list") ?: parseFailed("Cannot find root")
|
||||
return root.children().map { div ->
|
||||
val a = div.selectFirst("a") ?: parseFailed()
|
||||
val href = a.relUrl("href")
|
||||
val title = div.selectFirst(".item-title")?.text() ?: parseFailed("Title not found")
|
||||
@@ -204,6 +204,7 @@ class BatoToRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
||||
source = source,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element.parseTags() = children().mapToSet { span ->
|
||||
val text = span.ownText()
|
||||
|
||||
Reference in New Issue
Block a user