[RU]MangaPoisk new domain and HTML (#18265)

* [RU]MangaPoisk new domain and HTML

* MangasPage and search old
This commit is contained in:
Eshlender 2023-09-30 19:33:34 +05:00 committed by GitHub
parent f8c6f9f350
commit b3f6be4b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 40 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaPoisk' extName = 'MangaPoisk'
pkgNameSuffix = 'ru.mangapoisk' pkgNameSuffix = 'ru.mangapoisk'
extClass = '.MangaPoisk' extClass = '.MangaPoisk'
extVersionCode = 7 extVersionCode = 8
isNsfw = true isNsfw = true
} }

View File

@ -23,16 +23,14 @@ import java.util.Locale
class MangaPoisk : ParsedHttpSource() { class MangaPoisk : ParsedHttpSource() {
override val name = "MangaPoisk" override val name = "MangaPoisk"
override val baseUrl = "https://mangapoisk.net" override val baseUrl = "https://mangapoisk.me"
override val lang = "ru" override val lang = "ru"
override val supportsLatest = true override val supportsLatest = true
private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.3987.163 Safari/537.36"
override fun headersBuilder(): Headers.Builder = Headers.Builder() override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("User-Agent", userAgent) .add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.50")
.add("Referer", baseUrl) .add("Referer", baseUrl)
override fun popularMangaRequest(page: Int): Request = override fun popularMangaRequest(page: Int): Request =
@ -71,23 +69,9 @@ class MangaPoisk : ParsedHttpSource() {
return GET(url, headers) return GET(url, headers)
} }
override fun popularMangaSelector() = "article.card" override fun searchMangaSelector(): String = "article.card"
override fun latestUpdatesSelector() = popularMangaSelector() override fun searchMangaFromElement(element: Element): SManga {
override fun searchMangaParse(response: Response): MangasPage {
return popularMangaParse(response)
}
private fun getImage(first: Element): String? {
val image = first.attr("data-src")
if (image.isNotEmpty()) {
return image
}
return first.attr("src")
}
override fun popularMangaFromElement(element: Element): SManga {
return SManga.create().apply { return SManga.create().apply {
thumbnail_url = getImage(element.select("a > img").first()!!) thumbnail_url = getImage(element.select("a > img").first()!!)
@ -99,30 +83,64 @@ class MangaPoisk : ParsedHttpSource() {
} }
} }
override fun latestUpdatesFromElement(element: Element): SManga = override fun searchMangaParse(response: Response): MangasPage {
popularMangaFromElement(element) val document = response.asJsoup()
val mangas = if (document.location().contains("search?q")) {
document.select(searchMangaSelector()).map { element ->
searchMangaFromElement(element)
}
} else {
document.select(popularMangaSelector()).map { element ->
popularMangaFromElement(element)
}
}
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) return MangasPage(mangas, mangas.isNotEmpty())
}
override fun popularMangaNextPageSelector() = "a.page-link[rel=next]" override fun popularMangaNextPageSelector(): Nothing? = null
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector() override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
override fun mangaDetailsParse(document: Document): SManga { override fun popularMangaSelector() = ".manga-card"
val infoElement = document.select("article div.card-body").first()!!
val manga = SManga.create() override fun popularMangaParse(response: Response) = searchMangaParse(response)
val entitle = infoElement.select(".post-name-en") override fun popularMangaFromElement(element: Element): SManga {
manga.title = if (entitle.isNullOrEmpty()) { infoElement.select(".post-name").text() } else entitle.text().replaceRange(0, 2, "") return SManga.create().apply {
manga.genre = infoElement.select(".post-info > span:eq(10) > a").joinToString { it.text() } thumbnail_url = getImage(element.select("a > img").first()!!)
manga.description = infoElement.select(".post-info > div .manga-description.entry").text()
manga.status = if (document.select(".order-2 h3").text() == "Главы удалены по требованию правообладателя.") { setUrlWithoutDomain(element.select("a").first()!!.attr("href"))
SManga.LICENSED
} else { element.select("a").first()!!.let {
parseStatus(infoElement.select(".post-info > span:eq(7)").text()) title = it.attr("title").split("/").first()
}
} }
manga.thumbnail_url = infoElement.select("img.img-fluid").first()!!.attr("src") }
override fun latestUpdatesSelector() = popularMangaSelector()
override fun latestUpdatesParse(response: Response) = searchMangaParse(response)
override fun latestUpdatesFromElement(element: Element): SManga =
popularMangaFromElement(element)
private fun getImage(first: Element): String? {
val image = first.attr("data-src")
if (image.isNotEmpty()) {
return image
}
return first.attr("src")
}
override fun mangaDetailsParse(document: Document): SManga {
val infoElement = document.select("div.card").first()!!
val manga = SManga.create()
manga.title = infoElement.select(".text-base span").first()!!.text()
manga.genre = infoElement.select("span:contains(Жанр:) a").joinToString { it.text() }
manga.description = infoElement.select(".manga-description").text()
manga.status = parseStatus(infoElement.select("span:contains(Статус:)").text())
manga.thumbnail_url = infoElement.select("img.w-full").first()!!.attr("src")
return manga return manga
} }
@ -186,7 +204,7 @@ class MangaPoisk : ParsedHttpSource() {
return chapter return chapter
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
return document.select(".img-fluid.page-image").mapIndexed { index, element -> return document.select(".page-image").mapIndexed { index, element ->
Page(index, "", getImage(element)) Page(index, "", getImage(element))
} }
} }
@ -260,7 +278,5 @@ class MangaPoisk : ParsedHttpSource() {
override fun imageUrlParse(document: Document) = throw Exception("Not Used") override fun imageUrlParse(document: Document) = throw Exception("Not Used")
override fun searchMangaSelector(): String = throw Exception("Not Used")
override fun chapterFromElement(element: Element): SChapter = throw Exception("Not Used") override fun chapterFromElement(element: Element): SChapter = throw Exception("Not Used")
} }