parent
18407b4702
commit
2229e912f8
|
@ -5,8 +5,15 @@ ext {
|
||||||
appName = 'Tachiyomi: LibManga'
|
appName = 'Tachiyomi: LibManga'
|
||||||
pkgNameSuffix = 'ru.libmanga'
|
pkgNameSuffix = 'ru.libmanga'
|
||||||
extClass = '.LibMangaFactory'
|
extClass = '.LibMangaFactory'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly project(':preference-stub')
|
||||||
|
compileOnly 'com.google.code.gson:gson:2.8.5'
|
||||||
|
compileOnly 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
||||||
|
compileOnly 'com.github.inorichi.injekt:injekt-core:65b0440'
|
||||||
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
package eu.kanade.tachiyomi.extension.ru.libmanga
|
package eu.kanade.tachiyomi.extension.ru.libmanga
|
||||||
|
|
||||||
|
import com.github.salomonbrys.kotson.*
|
||||||
|
import com.google.gson.JsonParser
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.*
|
import eu.kanade.tachiyomi.source.model.*
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import org.json.JSONObject
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
open class LibManga(override val name: String, override val baseUrl: String, private val staticUrl: String) : ParsedHttpSource() {
|
open class LibManga(override val name: String, override val baseUrl: String, private val staticUrl: String) : ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -136,6 +141,55 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||||
return GET(url.toString(), headers)
|
return GET(url.toString(), headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Hack search method to add some results from search popup
|
||||||
|
override fun searchMangaParse(response: Response): MangasPage {
|
||||||
|
val searchRequest = response.request().url().queryParameter("name")
|
||||||
|
val mangas = mutableListOf<SManga>()
|
||||||
|
if (!searchRequest.isNullOrEmpty()) {
|
||||||
|
val popupSearchHeaders = headers
|
||||||
|
.newBuilder()
|
||||||
|
.add("Accept", "application/json, text/plain, */*")
|
||||||
|
.add("X-Requested-With", "XMLHttpRequest")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// +200ms
|
||||||
|
val popup = client.newCall(
|
||||||
|
GET("https://mangalib.me/search?query=$searchRequest", headers = popupSearchHeaders)
|
||||||
|
).execute().body()!!.string()
|
||||||
|
val jsonList = JsonParser().parse(popup).asJsonArray
|
||||||
|
jsonList.forEach {
|
||||||
|
val element = it.asJsonObject
|
||||||
|
val manga = SManga.create()
|
||||||
|
manga.setUrlWithoutDomain("/" + element.get("slug").string)
|
||||||
|
manga.description = element.get("summary").nullString
|
||||||
|
manga.author = element.get("author").nullString
|
||||||
|
manga.title = element.get("name").string
|
||||||
|
val status = element.get("status_id").int
|
||||||
|
manga.status = if (status > 2) 2 else status
|
||||||
|
mangas.add(manga)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
val searchedMangas = document.select(searchMangaSelector()).map { element ->
|
||||||
|
searchMangaFromElement(element)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtered out what find in popup search
|
||||||
|
mangas.addAll(searchedMangas.filter { search ->
|
||||||
|
mangas.find { search.title == it.title } == null
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
val hasNextPage = searchMangaNextPageSelector().let { selector ->
|
||||||
|
document.select(selector).first()
|
||||||
|
} != null
|
||||||
|
|
||||||
|
return MangasPage(mangas, hasNextPage)
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
||||||
|
|
||||||
private class SearchFilter(name: String, val id: String) : Filter.TriState(name)
|
private class SearchFilter(name: String, val id: String) : Filter.TriState(name)
|
||||||
|
@ -153,7 +207,7 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||||
|
|
||||||
private class OrderBy : Filter.Sort("Сортировка",
|
private class OrderBy : Filter.Sort("Сортировка",
|
||||||
arrayOf("Рейтинг", "Имя", "Просмотры", "Дата"),
|
arrayOf("Рейтинг", "Имя", "Просмотры", "Дата"),
|
||||||
Filter.Sort.Selection(1, false))
|
Filter.Sort.Selection(0, false))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use console
|
* Use console
|
||||||
|
@ -176,9 +230,9 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||||
* on /manga-list
|
* on /manga-list
|
||||||
*/
|
*/
|
||||||
private fun getStatusList() = listOf(
|
private fun getStatusList() = listOf(
|
||||||
SearchFilter("продолжается", "1"),
|
SearchFilter("Продолжается", "1"),
|
||||||
SearchFilter("завершен", "2"),
|
SearchFilter("Завершен", "2"),
|
||||||
SearchFilter("заморожен", "3")
|
SearchFilter("Заморожен", "3")
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue