parent
d100bdca51
commit
d02f152089
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Henchan'
|
||||
pkgNameSuffix = 'ru.henchan'
|
||||
extClass = '.Henchan'
|
||||
extVersionCode = 11
|
||||
extVersionCode = 12
|
||||
libVersion = '1.2'
|
||||
}
|
||||
dependencies {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.salomonbrys.kotson.array
|
|||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.*
|
||||
|
@ -17,7 +18,7 @@ import okhttp3.Response
|
|||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
class Henchan : ParsedHttpSource() {
|
||||
|
@ -92,10 +93,15 @@ class Henchan : ParsedHttpSource() {
|
|||
|
||||
override fun searchMangaSelector() = ".content_row:not(:has(div.item:containsOwn(Тип)))"
|
||||
|
||||
private fun String.getHQThumbnail(): String = this
|
||||
.replace("manganew_thumbs", "showfull_retina/manga")
|
||||
.replace("img.", "imgcover.")
|
||||
.replace("_henchan.me", "_hentaichan.ru")
|
||||
private fun String.getHQThumbnail(): String? {
|
||||
return if (this.isNotEmpty()) {
|
||||
this.replace("manganew_thumbs", "showfull_retina/manga")
|
||||
.replace("img.", "imgcover.")
|
||||
.replace("_henchan.me", "_hentaichan.ru")
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
|
@ -120,10 +126,16 @@ class Henchan : ParsedHttpSource() {
|
|||
|
||||
override fun searchMangaNextPageSelector() = "#nextlink, ${popularMangaNextPageSelector()}"
|
||||
|
||||
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
val manga = SManga.create()
|
||||
manga.thumbnail_url = document.select("#cover").first().attr("src")
|
||||
manga.thumbnail_url = document.select("#cover").first().attr("src").let {
|
||||
if (it.isNotEmpty()) {
|
||||
it
|
||||
} else {
|
||||
client.newCall(GET(document.select("div.extaraNavi p:last-child a").attr("abs:href") + "?development_access=true#page=1", headers))
|
||||
.execute().asJsoup().parseJsonArray()[0].string + "#" // # for later so we know where we got it from
|
||||
}
|
||||
}
|
||||
manga.author = document.select(".row .item2 h2")[1].text()
|
||||
manga.genre = document.select(".sidetag > a:eq(2)").joinToString { it.text() }
|
||||
manga.description = document.select("#description").text()
|
||||
|
@ -131,12 +143,12 @@ class Henchan : ParsedHttpSource() {
|
|||
}
|
||||
|
||||
override fun chapterListRequest(manga: SManga): Request {
|
||||
val baseMangaUrl = baseUrl + manga.url
|
||||
if(manga.thumbnail_url?.isBlank() ?: return GET(baseMangaUrl.replace("/manga/", "/related/"), headers)){
|
||||
return GET(baseMangaUrl, headers)
|
||||
}else {
|
||||
return GET(baseMangaUrl.replace("/manga/", "/related/"), headers)
|
||||
val url = baseUrl + if (manga.thumbnail_url?.endsWith("#") == true) {
|
||||
manga.url
|
||||
} else {
|
||||
manga.url.replace("/manga/", "/related/")
|
||||
}
|
||||
return (GET(url, headers))
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = ".related"
|
||||
|
@ -145,9 +157,10 @@ class Henchan : ParsedHttpSource() {
|
|||
val responseUrl = response.request().url().toString()
|
||||
val document = response.asJsoup()
|
||||
|
||||
// exhentai chapter
|
||||
if(responseUrl.contains("/manga/")){
|
||||
val chap = SChapter.create()
|
||||
chap.setUrlWithoutDomain(responseUrl.removePrefix(baseUrl))
|
||||
chap.setUrlWithoutDomain(responseUrl)
|
||||
chap.name = document.select("a.title_top_a").text()
|
||||
chap.chapter_number = 1F
|
||||
|
||||
|
@ -158,6 +171,7 @@ class Henchan : ParsedHttpSource() {
|
|||
return listOf(chap)
|
||||
}
|
||||
|
||||
// one chapter, nothing related
|
||||
if (document.select("#right > div:nth-child(4)").text().contains(" похожий на ")) {
|
||||
val chap = SChapter.create()
|
||||
chap.setUrlWithoutDomain(document.select("#left > div > a").attr("href"))
|
||||
|
@ -167,7 +181,7 @@ class Henchan : ParsedHttpSource() {
|
|||
return listOf(chap)
|
||||
}
|
||||
|
||||
|
||||
// has related chapters
|
||||
val result = mutableListOf<SChapter>()
|
||||
result.addAll(document.select(chapterListSelector()).map {
|
||||
chapterFromElement(it)
|
||||
|
@ -201,22 +215,28 @@ class Henchan : ParsedHttpSource() {
|
|||
}
|
||||
|
||||
override fun pageListRequest(chapter: SChapter): Request {
|
||||
val url = exhentaiBaseUrl + chapter.url.replace("/manga/", "/online/") + "?development_access=true"
|
||||
val url = if (chapter.url.contains("/manga/")) {
|
||||
exhentaiBaseUrl + chapter.url.replace("/manga/", "/online/") + "?development_access=true"
|
||||
} else {
|
||||
baseUrl + chapter.url
|
||||
}
|
||||
return GET(url, Headers.Builder().add("Accept", "image/webp,image/apng").build())
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document) = throw Exception("Not Used")
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val imgScript = document.select("script:containsData(fullimg)").first().toString()
|
||||
val imgString = imgScript.substring(imgScript.indexOf('{'), imgScript.lastIndexOf('}') + 1)
|
||||
val jsonArray = Gson().fromJson<JsonObject>(imgString)["fullimg"].array
|
||||
private val gson = Gson()
|
||||
|
||||
val resPages = mutableListOf<Page>()
|
||||
jsonArray.forEachIndexed { index, imageUrl ->
|
||||
resPages.add(Page(index, imageUrl = imageUrl.string.replace(".gif.webp", ".gif")))
|
||||
private fun Document.parseJsonArray(): JsonArray {
|
||||
val imgScript = this.select("script:containsData(fullimg)").first().toString()
|
||||
val imgString = imgScript.substring(imgScript.indexOf('{'), imgScript.lastIndexOf('}') + 1)
|
||||
return gson.fromJson<JsonObject>(imgString)["fullimg"].array
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
return document.parseJsonArray().mapIndexed { index, imageUrl ->
|
||||
Page(index, imageUrl = imageUrl.string.replace(".gif.webp", ".gif"))
|
||||
}
|
||||
return resPages
|
||||
}
|
||||
|
||||
private class Genre(val id: String, name: String = id.replace('_', ' ').capitalize()) : Filter.TriState(name)
|
||||
|
@ -226,7 +246,7 @@ class Henchan : ParsedHttpSource() {
|
|||
arrayOf("manga/new&n=dateasc" to "manga/new", "manga/new&n=favasc" to "mostfavorites&sort=manga", "manga/new&n=abcdesc" to "manga/new&n=abcasc"))
|
||||
|
||||
private open class UriPartFilter(displayName: String, sortNames: Array<String>, val withGenres: Array<Pair<String, String>>, val withoutGenres: Array<Pair<String, String>>) :
|
||||
Filter.Sort(displayName, sortNames, Filter.Sort.Selection(1, false)) {
|
||||
Filter.Sort(displayName, sortNames, Selection(1, false)) {
|
||||
fun toUriPartWithGenres() = if(state!!.ascending) withGenres[state!!.index].first else withGenres[state!!.index].second
|
||||
fun toUriPartWithoutGenres() = if(state!!.ascending) withoutGenres[state!!.index].first else withoutGenres[state!!.index].second
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue