diff --git a/src/es/tojimangas/build.gradle b/src/es/tojimangas/build.gradle new file mode 100644 index 000000000..93e458fe9 --- /dev/null +++ b/src/es/tojimangas/build.gradle @@ -0,0 +1,8 @@ +ext { + extName = 'Tojimangas' + extClass = '.Tojimangas' + extVersionCode = 1 + isNsfw = true +} + +apply from: "$rootDir/common.gradle" diff --git a/src/es/tojimangas/res/mipmap-hdpi/ic_launcher.png b/src/es/tojimangas/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..87e0bf5fc Binary files /dev/null and b/src/es/tojimangas/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/es/tojimangas/res/mipmap-mdpi/ic_launcher.png b/src/es/tojimangas/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..b071d1c12 Binary files /dev/null and b/src/es/tojimangas/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/es/tojimangas/res/mipmap-xhdpi/ic_launcher.png b/src/es/tojimangas/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..f3d9d2743 Binary files /dev/null and b/src/es/tojimangas/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/es/tojimangas/res/mipmap-xxhdpi/ic_launcher.png b/src/es/tojimangas/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..496016c0e Binary files /dev/null and b/src/es/tojimangas/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/es/tojimangas/res/mipmap-xxxhdpi/ic_launcher.png b/src/es/tojimangas/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..acd61842a Binary files /dev/null and b/src/es/tojimangas/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/es/tojimangas/src/eu/kanade/tachiyomi/extension/es/tojimangas/Tojimangas.kt b/src/es/tojimangas/src/eu/kanade/tachiyomi/extension/es/tojimangas/Tojimangas.kt new file mode 100644 index 000000000..3fea921d6 --- /dev/null +++ b/src/es/tojimangas/src/eu/kanade/tachiyomi/extension/es/tojimangas/Tojimangas.kt @@ -0,0 +1,112 @@ +package eu.kanade.tachiyomi.extension.es.tojimangas + +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.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Request +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import java.text.SimpleDateFormat +import java.util.Locale + +class Tojimangas : ParsedHttpSource() { + + override val lang = "es" + override val baseUrl = "https://tojimangas.com" + override val name = "Tojimangas" + override val supportsLatest = true + + override fun searchMangaSelector(): String = ".animposx a" + override fun popularMangaSelector(): String = searchMangaSelector() + override fun latestUpdatesSelector(): String = searchMangaSelector() + + override fun searchMangaNextPageSelector(): String = ".arrow_pag" + override fun popularMangaNextPageSelector(): String = searchMangaNextPageSelector() + override fun latestUpdatesNextPageSelector(): String = searchMangaNextPageSelector() + + override fun chapterListSelector(): String = "li .epsleft" + + private fun makeMangaRequest( + page: Int, + addToBuilder: (HttpUrl.Builder) -> HttpUrl.Builder, + ): Request = GET( + addToBuilder( + baseUrl.toHttpUrl().newBuilder().apply { + addPathSegment("biblioteca") + addPathSegment("page") + addPathSegment(page.toString()) + }, + ).build(), + headers, + ) + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = + makeMangaRequest(page) { + it.addQueryParameter("title", query) + } + + override fun popularMangaRequest(page: Int): Request = makeMangaRequest(page) { + it.addQueryParameter("order", "popular") + } + + override fun latestUpdatesRequest(page: Int): Request = makeMangaRequest(page) { + it.addQueryParameter("order", "update") + } + + override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply { + setUrlWithoutDomain(element.absUrl("href")) + title = element.attr("title") + thumbnail_url = element.selectFirst("img")?.absUrl("src") + } + + override fun popularMangaFromElement(element: Element): SManga = searchMangaFromElement(element) + + override fun latestUpdatesFromElement(element: Element): SManga = + searchMangaFromElement(element) + + override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply { + thumbnail_url = document.selectFirst("thumb img")?.absUrl("src") + + description = + document.select(".desc > div > :not(h2, [style='display: none;'], .manga-update-info)") + .filter { p -> p.text() != "" } + .joinToString { p -> p.text() } + + genre = document.select(".genre-info a").joinToString { a -> a.text() } + + val infoGrid = document.selectFirst(".infox .spe") + + author = infoGrid?.selectFirst("span:contains(Autor)")?.text()?.substringAfter("Autor") + + status = + when ( + infoGrid?.selectFirst("span:contains(Estado)")?.text()?.substringAfter("Estado") + ?.trim()?.lowercase() + ) { + "activo" -> SManga.ONGOING + "finalizado" -> SManga.COMPLETED + else -> SManga.UNKNOWN + } + } + + private val dateFormat = SimpleDateFormat("dd MMMM, yyyy", Locale("es")) + + override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply { + val a = element.selectFirst("a") + a?.absUrl("href")?.let { setUrlWithoutDomain(it) } + name = a?.text() ?: "" + date_upload = element.selectFirst(".date")?.text()?.let { dateFormat.parse(it)?.time } ?: 0 + } + + override fun pageListParse(document: Document): List = + document.select(".reader-area img").mapIndexed { idx, img -> + Page(idx, imageUrl = img.absUrl("src")) + } + + override fun imageUrlParse(document: Document): String = "" +}