diff --git a/src/ru/waymanga/AndroidManifest.xml b/src/ru/waymanga/AndroidManifest.xml new file mode 100644 index 000000000..30deb7f79 --- /dev/null +++ b/src/ru/waymanga/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/src/ru/waymanga/build.gradle b/src/ru/waymanga/build.gradle new file mode 100644 index 000000000..bfb38d7e1 --- /dev/null +++ b/src/ru/waymanga/build.gradle @@ -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" diff --git a/src/ru/waymanga/res/mipmap-hdpi/ic_launcher.png b/src/ru/waymanga/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..8a9dbd34c Binary files /dev/null and b/src/ru/waymanga/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/ru/waymanga/res/mipmap-mdpi/ic_launcher.png b/src/ru/waymanga/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..e2d4b78d0 Binary files /dev/null and b/src/ru/waymanga/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/ru/waymanga/res/mipmap-xhdpi/ic_launcher.png b/src/ru/waymanga/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..9c9f4bbfe Binary files /dev/null and b/src/ru/waymanga/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/ru/waymanga/res/mipmap-xxhdpi/ic_launcher.png b/src/ru/waymanga/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..2c14b605f Binary files /dev/null and b/src/ru/waymanga/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/ru/waymanga/res/mipmap-xxxhdpi/ic_launcher.png b/src/ru/waymanga/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..7afe0d178 Binary files /dev/null and b/src/ru/waymanga/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/ru/waymanga/res/web_hi_res_512.png b/src/ru/waymanga/res/web_hi_res_512.png new file mode 100644 index 000000000..dad09a7d9 Binary files /dev/null and b/src/ru/waymanga/res/web_hi_res_512.png differ diff --git a/src/ru/waymanga/src/eu/kanade/tachiyomi/extension/ru/waymanga/WayManga.kt b/src/ru/waymanga/src/eu/kanade/tachiyomi/extension/ru/waymanga/WayManga.kt new file mode 100644 index 000000000..26f56b5d1 --- /dev/null +++ b/src/ru/waymanga/src/eu/kanade/tachiyomi/extension/ru/waymanga/WayManga.kt @@ -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 { + 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) } + } +}