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