MangaBox - redirect check, selectors (#2866)
MangaBox - redirect check, selectors
This commit is contained in:
parent
2251a97868
commit
32be7b2f11
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: MangaBox (Mangakakalot and others)'
|
appName = 'Tachiyomi: MangaBox (Mangakakalot and others)'
|
||||||
pkgNameSuffix = 'all.mangabox'
|
pkgNameSuffix = 'all.mangabox'
|
||||||
extClass = '.MangaBoxFactory'
|
extClass = '.MangaBoxFactory'
|
||||||
extVersionCode = 19
|
extVersionCode = 20
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
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 java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
@ -15,6 +16,7 @@ import java.util.concurrent.TimeUnit
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
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
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ abstract class MangaBox(
|
||||||
|
|
||||||
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
|
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
|
||||||
|
|
||||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
override fun searchMangaNextPageSelector() = "a.page_select + a:not(.page_last), a.page-select + a:not(.page-last)"
|
||||||
|
|
||||||
open val mangaDetailsMainSelector = "div.manga-info-top, div.panel-story-info"
|
open val mangaDetailsMainSelector = "div.manga-info-top, div.panel-story-info"
|
||||||
|
|
||||||
|
@ -111,17 +113,22 @@ abstract class MangaBox(
|
||||||
return super.mangaDetailsRequest(manga)
|
return super.mangaDetailsRequest(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
private fun checkForRedirectMessage(document: Document) {
|
||||||
val infoElement = document.select(mangaDetailsMainSelector)
|
if (document.select("body").text().startsWith("REDIRECT :"))
|
||||||
|
throw Exception("Source URL has changed")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mangaDetailsParse(document: Document): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
title = infoElement.select("h1, h2").first().text()
|
document.select(mangaDetailsMainSelector).firstOrNull()?.let { infoElement ->
|
||||||
author = infoElement.select("li:contains(author) a, td:containsOwn(author) + td").text()
|
title = infoElement.select("h1, h2").first().text()
|
||||||
status = parseStatus(infoElement.select("li:contains(status), td:containsOwn(status) + td").text())
|
author = infoElement.select("li:contains(author) a, td:containsOwn(author) + td").text()
|
||||||
genre = infoElement.select("div.manga-info-top li:contains(genres)").firstOrNull()
|
status = parseStatus(infoElement.select("li:contains(status), td:containsOwn(status) + td").text())
|
||||||
?.select("a")?.joinToString { it.text() } // kakalot
|
genre = infoElement.select("div.manga-info-top li:contains(genres)").firstOrNull()
|
||||||
?: infoElement.select("td:containsOwn(genres) + td a").joinToString { it.text() } // nelo
|
?.select("a")?.joinToString { it.text() } // kakalot
|
||||||
description = document.select(descriptionSelector)?.first()?.ownText()
|
?: infoElement.select("td:containsOwn(genres) + td a").joinToString { it.text() } // nelo
|
||||||
|
} ?: checkForRedirectMessage(document)
|
||||||
|
description = document.select(descriptionSelector)?.firstOrNull()?.ownText()
|
||||||
?.replace("""^$title summary:\s""".toRegex(), "")
|
?.replace("""^$title summary:\s""".toRegex(), "")
|
||||||
?.replace("""<\s*br\s*\/?>""".toRegex(), "\n")
|
?.replace("""<\s*br\s*\/?>""".toRegex(), "\n")
|
||||||
?.replace("<[^>]*>".toRegex(), "")
|
?.replace("<[^>]*>".toRegex(), "")
|
||||||
|
@ -143,6 +150,14 @@ abstract class MangaBox(
|
||||||
return super.chapterListRequest(manga)
|
return super.chapterListRequest(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
return document.select(chapterListSelector())
|
||||||
|
.map { chapterFromElement(it) }
|
||||||
|
.also { if (it.isEmpty()) checkForRedirectMessage(document) }
|
||||||
|
}
|
||||||
|
|
||||||
override fun chapterListSelector() = "div.chapter-list div.row, ul.row-content-chapter li"
|
override fun chapterListSelector() = "div.chapter-list div.row, ul.row-content-chapter li"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
|
|
Loading…
Reference in New Issue