new extension for the site https://waymanga.ru/ (#9331)

* new extension for the site https://waymanga.ru/

* Update src/ru/waymanga/src/eu/kanade/tachiyomi/extension/ru/waymanga/WayManga.kt

Co-authored-by: ObserverOfTime <chronobserver@disroot.org>

* fixed bugs

Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
This commit is contained in:
Станислав Сухоруков 2021-10-04 14:30:44 +03:00 committed by GitHub
parent 5c484b8256
commit ea64267f83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 135 additions and 0 deletions

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="eu.kanade.tachiyomi.extension" />

View File

@ -0,0 +1,11 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
ext {
extName = 'WayManga'
pkgNameSuffix = 'ru.waymanga'
extClass = '.WayManga'
extVersionCode = 1
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -0,0 +1,122 @@
package eu.kanade.tachiyomi.extension.ru.waymanga
import eu.kanade.tachiyomi.network.GET
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.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale
class WayManga : ParsedHttpSource() {
override val name = "WayManga"
override val baseUrl = "https://waymanga.ru"
override val lang = "ru"
override val supportsLatest = true
override fun popularMangaRequest(page: Int): Request =
GET("$baseUrl/manga?page=$page", headers)
override fun latestUpdatesRequest(page: Int): Request =
GET(baseUrl, headers)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return GET("$baseUrl/search?query=$query")
}
override fun popularMangaSelector() = "div.p-2"
override fun latestUpdatesSelector() = "div.row"
override fun searchMangaSelector() = "div.col-12 > div"
override fun popularMangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.thumbnail_url = element.select("img").first().attr("src")
element.select("a").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text()
}
return manga
}
override fun latestUpdatesFromElement(element: Element): SManga {
val manga = SManga.create()
manga.thumbnail_url = element.select("img").first().attr("src")
element.select("a").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
}
element.select("div.col-6").first().let {
manga.title = it.text()
}
return manga
}
override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.thumbnail_url = element.select("img").first().attr("src")
element.select("a").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text()
}
return manga
}
override fun popularMangaNextPageSelector() = "a.page-link[rel=next]"
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
setUrlWithoutDomain(document.location())
title = document.selectFirst("title").text()
thumbnail_url = document.selectFirst("img.object-0").attr("src")
}
override fun chapterListSelector() = "div.chapters-list > div"
override fun chapterFromElement(element: Element): SChapter {
val urlElement = element.select("a").first()
val chapter = SChapter.create()
element.select("div.col-5").first().let {
chapter.name = it.text()
}
chapter.setUrlWithoutDomain(urlElement.attr("href"))
chapter.date_upload = element.select("div.col-4").text().toDate()
return chapter
}
override fun pageListParse(document: Document): List<Page> {
return document.select("div.ch-show > img").mapIndexed { index, element ->
Page(index, "", getImage(element))
}
}
private fun getImage(first: Element): String? {
val image = first.attr("data-src")
if (image.isNotEmpty()) {
return image
}
return first.attr("src")
}
override fun imageUrlParse(document: Document) = ""
private fun String.toDate(): Long {
return runCatching { DATE_FORMATTER.parse(trim())?. time }
.getOrNull() ?: 0L
}
companion object {
private val DATE_FORMATTER by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.US) }
}
}