Fix MangaKakalot (closes #882) (#883)

Fix MangaKakalot (closes #882)
This commit is contained in:
Eugene 2019-03-09 10:15:30 -05:00 committed by Carlos
parent 9698fd0711
commit 547338119d
2 changed files with 15 additions and 64 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaKakalot' appName = 'Tachiyomi: MangaKakalot'
pkgNameSuffix = 'en.mangakakalot' pkgNameSuffix = 'en.mangakakalot'
extClass = '.Mangakakalot' extClass = '.Mangakakalot'
extVersionCode = 3 extVersionCode = 4
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -1,12 +1,13 @@
package eu.kanade.tachiyomi.extension.en.mangakakalot package eu.kanade.tachiyomi.extension.en.mangakakalot
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -25,7 +26,6 @@ class Mangakakalot : ParsedHttpSource() {
override fun popularMangaSelector() = "div.truyen-list > div.list-truyen-item-wrap" override fun popularMangaSelector() = "div.truyen-list > div.list-truyen-item-wrap"
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
return GET("$baseUrl/manga_list?type=topview&category=all&state=all&page=$page") return GET("$baseUrl/manga_list?type=topview&category=all&state=all&page=$page")
} }
@ -35,16 +35,6 @@ class Mangakakalot : ParsedHttpSource() {
return GET("$baseUrl/manga_list?type=latest&category=all&state=all&page=$page") return GET("$baseUrl/manga_list?type=latest&category=all&state=all&page=$page")
} }
override fun latestUpdatesParse(response: Response): MangasPage {
val document = response.asJsoup()
val mangas = document.select(latestUpdatesSelector()).map { element ->
latestUpdatesFromElement(element)
}
return MangasPage(mangas, hasNextPage(document))
}
override fun popularMangaFromElement(element: Element): SManga { override fun popularMangaFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
element.select("h3 a").first().let { element.select("h3 a").first().let {
@ -55,74 +45,36 @@ class Mangakakalot : ParsedHttpSource() {
return manga return manga
} }
override fun popularMangaParse(response: Response): MangasPage {
val document = response.asJsoup()
val mangas = document.select(popularMangaSelector()).map { element ->
popularMangaFromElement(element)
}
return MangasPage(mangas, hasNextPage(document))
}
override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element) override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun popularMangaNextPageSelector() = throw UnsupportedOperationException("Not used") override fun popularMangaNextPageSelector() = "a.page_select + a:not(.page_last)"
override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException("Not used") override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
//site ignore everything after the first word // Site ignores everything after the first word
val substringBefore = query.replace(" ", "_").replace(",", "_").replace(":", "_") val substringBefore = query.replace(" ", "_").replace(",", "_").replace(":", "_")
val url = "$baseUrl/search/$substringBefore/$page" val url = "$baseUrl/search/$substringBefore?page=$page"
return GET(url, headers) return GET(url, headers)
} }
override fun searchMangaParse(response: Response): MangasPage { override fun searchMangaSelector() = ".panel_story_list .story_item"
val document = response.asJsoup()
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
val mangas = document.select(searchMangaSelector()).map { element -> override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
searchMangaFromElement(element)
}
return MangasPage(mangas, false)
}
private fun hasNextPage(document: Document): Boolean {
val currentPage = document.select("div.group-page a.pageselect").first().text()
val lastPage = document.select("div.group-page a.page.page-blue")[1].text().substringAfter("Last(").substringBefore(")")
return currentPage != lastPage
}
override fun searchMangaSelector() = "div.daily-update-item"
override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create()
element.select("a").first()?.let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text()
}
return manga
}
override fun searchMangaNextPageSelector() = throw UnsupportedOperationException("Not used")
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
val infoElement = document.select("div.manga-info-top").first() val infoElement = document.select("div.manga-info-top").first()
val manga = SManga.create() val manga = SManga.create()
manga.title = infoElement.select("h1").first().text() manga.title = infoElement.select("h1").first().text()
manga.author = infoElement.select("div.manga-info-top li").find { it -> it.text().startsWith("Author") }?.text()?.substringAfter(") :") manga.author = infoElement.select("div.manga-info-top li").find { it.text().startsWith("Author") }?.text()?.substringAfter(") :")
val status = infoElement.select("div.manga-info-top li").find { it -> it.text().startsWith("Status") }?.text()?.substringAfter("Status :") val status = infoElement.select("div.manga-info-top li").find { it.text().startsWith("Status") }?.text()?.substringAfter("Status :")
manga.status = parseStatus(status) manga.status = parseStatus(status)
val genres = mutableListOf<String>() val genres = mutableListOf<String>()
infoElement.select("div.manga-info-top li").find { it -> it.text().startsWith("Genres :") }?.select("a")?.forEach { it -> genres.add(it.text()) } infoElement.select("div.manga-info-top li").find { it.text().startsWith("Genres :") }?.select("a")?.forEach { genres.add(it.text()) }
manga.genre = genres.joinToString() manga.genre = genres.joinToString()
manga.description = document.select("div#noidungm").text() manga.description = document.select("div#noidungm").text()
manga.thumbnail_url = document.select("div.manga-info-pic").first().select("img").first().attr("src") manga.thumbnail_url = document.select("div.manga-info-pic").first().select("img").first().attr("src")
@ -148,7 +100,6 @@ class Mangakakalot : ParsedHttpSource() {
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
document.select("div#vungdoc img")?.forEach { document.select("div#vungdoc img")?.forEach {