parent
99ace81459
commit
de8b5212d0
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Mangahub'
|
||||
pkgNameSuffix = 'ru.mangahub'
|
||||
extClass = '.Mangahub'
|
||||
extVersionCode = 2
|
||||
extVersionCode = 3
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package eu.kanade.tachiyomi.extension.ru.mangahub
|
||||
|
||||
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 okhttp3.Headers
|
||||
import okhttp3.Request
|
||||
|
@ -14,36 +17,36 @@ open class Mangahub : ParsedHttpSource() {
|
|||
|
||||
override val name = "Mangahub"
|
||||
|
||||
override val baseUrl = "http://mangahub.ru"
|
||||
override val baseUrl = "https://mangahub.ru"
|
||||
|
||||
override val lang = "ru"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request =
|
||||
GET("$baseUrl/explore?search[sort]=rating&search[dateStart][left_number]=1972&search[dateStart][right_number]=2018&page=$page", headers)
|
||||
GET("$baseUrl/explore?filter[sort]=rating&filter[dateStart][left_number]=1900&filter[dateStart][right_number]=2099&page=$page", headers)
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request =
|
||||
GET("$baseUrl/explore?search[sort]=update&search[dateStart][left_number]=1972&search[dateStart][right_number]=2018&page=$page", headers)
|
||||
GET("$baseUrl/explore?filter[sort]=update&filter[dateStart][left_number]=1900&filter[dateStart][right_number]=2099&page=$page", headers)
|
||||
|
||||
override fun popularMangaSelector() = "div.list-element"
|
||||
override fun popularMangaSelector() = "div.align-items-start"
|
||||
|
||||
override fun latestUpdatesSelector() = "div.list-element"
|
||||
override fun latestUpdatesSelector() = "div.align-items-start"
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
manga.thumbnail_url = element.select("div.list-element__image-back").attr("style").removeSuffix("')").removePrefix("background-image:url('")
|
||||
manga.title = element.select("div.list-element__name").text()
|
||||
manga.setUrlWithoutDomain(element.select("div.list-element__name > a").attr("href"))
|
||||
manga.thumbnail_url = element.select("div.cover-list").attr("style").removeSurrounding(prefix = "background-image: url(", suffix = ");")
|
||||
manga.title = element.select("div.d-flex > a").text()
|
||||
manga.setUrlWithoutDomain(element.select("div.d-flex > a").attr("href"))
|
||||
return manga
|
||||
}
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga =
|
||||
popularMangaFromElement(element)
|
||||
popularMangaFromElement(element)
|
||||
|
||||
override fun popularMangaNextPageSelector() = ".next"
|
||||
override fun popularMangaNextPageSelector() = "li.next > a"
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = ".next"
|
||||
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return GET("$baseUrl/search/manga?query=$query&sort=score&page=$page")
|
||||
|
@ -53,57 +56,53 @@ open class Mangahub : ParsedHttpSource() {
|
|||
|
||||
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
|
||||
|
||||
override fun searchMangaNextPageSelector(): String? = ".next"
|
||||
override fun searchMangaNextPageSelector(): String? = popularMangaNextPageSelector()
|
||||
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
val manga = SManga.create()
|
||||
manga.author = document.select("[itemprop=\"author\"]")?.text()
|
||||
manga.genre = document.select("div.b-dtl-desc__labels")[0].text().replace(" ", ", ")
|
||||
manga.description = if (document.select("div.b-dtl-desc__desc-info > p").last() != null) document.select("div.b-dtl-desc__desc-info > p").last().text() else null
|
||||
manga.status = parseStatus(document)
|
||||
manga.thumbnail_url = document.select("div.manga-section-image__img > [itemprop=\"image\"]").attr("src")
|
||||
manga.author = document.select("a[itemprop]")?.text()
|
||||
manga.genre = document.select("div.tag").text().replace(" ", ", ")
|
||||
manga.description = document.select("div.markdown-style").text()
|
||||
manga.status = parseStatus(document.select("div.sticky-top span.status-label").toString())
|
||||
manga.thumbnail_url = document.select("img.cover-detail-img").attr("src")
|
||||
return manga
|
||||
}
|
||||
|
||||
private fun parseStatus(element: Document): Int = when {
|
||||
element.select("div.b-status-label__one > span.b-status-label__name.b-status-label__name-completed").size != 0 -> SManga.COMPLETED
|
||||
element.select("div.b-status-label__one > span.b-status-label__name.b-status-label__name-translated").size != 0
|
||||
&& element.select("div.b-status-label__one > span.b-status-label__name.b-status-label__name-updated").size == 0 -> SManga.COMPLETED
|
||||
element.select("div.b-status-label__one > span.b-status-label__name.b-status-label__name-updated").size != 0 -> SManga.ONGOING
|
||||
else -> SManga.UNKNOWN
|
||||
private fun parseStatus(elements: String): Int = when {
|
||||
elements.contains("Переведена") or elements.contains("Выпуск завершен") -> SManga.COMPLETED
|
||||
else -> SManga.ONGOING
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = "div.b-catalog-list__elem"
|
||||
override fun chapterListSelector() = "div.py-2.px-3"
|
||||
|
||||
override fun chapterFromElement(element: Element): SChapter {
|
||||
val urlElement = element.select("div.b-ovf-table__elem > a").first()
|
||||
val urlElement = element.select("div.align-items-center > a").first()
|
||||
val chapter = SChapter.create()
|
||||
chapter.name = urlElement.text()
|
||||
chapter.date_upload = element.select("div.b-catalog-el__date-val").text()?.let {
|
||||
chapter.date_upload = element.select("div.text-muted").text()?.let {
|
||||
SimpleDateFormat("dd.MM.yyyy", Locale.US).parse(it).time
|
||||
} ?: 0
|
||||
val url = element.select("div.b-ovf-table__elem a").first().attr("href")
|
||||
chapter.setUrlWithoutDomain(url)
|
||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||
return chapter
|
||||
}
|
||||
|
||||
override fun prepareNewChapter(chapter: SChapter, manga: SManga) {
|
||||
val basic = Regex("""Глава\s([0-9]+)""")
|
||||
val basic = Regex("(Глава\\s)((\\d|\\.)+)")
|
||||
when {
|
||||
basic.containsMatchIn(chapter.name) -> {
|
||||
basic.find(chapter.name)?.let {
|
||||
chapter.chapter_number = it.groups[1]?.value!!.toFloat()
|
||||
chapter.chapter_number = it.groups[2]?.value!!.toFloat()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val pictures = document.select("div.b-reader.b-reader__full").attr("data-js-scans").replace(""", "\"").replace("\\/", "/")
|
||||
val pictures = document.select("div.row > div > div.mb-4").attr("data-js-scans").replace(""", "\"").replace("\\/", "/")
|
||||
val r = Regex("""\/\/([\w\.\/])+""")
|
||||
val pages = mutableListOf<Page>()
|
||||
for((index, value) in r.findAll(pictures).withIndex()) {
|
||||
pages.add(Page(index=index, imageUrl="http:${value.value}"))
|
||||
for ((index, value) in r.findAll(pictures).withIndex()) {
|
||||
pages.add(Page(index = index, imageUrl = "http:${value.value}"))
|
||||
}
|
||||
|
||||
return pages
|
||||
|
@ -118,4 +117,4 @@ open class Mangahub : ParsedHttpSource() {
|
|||
}.build()
|
||||
return GET(page.imageUrl!!, imgHeader)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue