diff --git a/src/pt/fenixmanhwas/build.gradle b/src/pt/fenixmanhwas/build.gradle new file mode 100644 index 000000000..b933b84d1 --- /dev/null +++ b/src/pt/fenixmanhwas/build.gradle @@ -0,0 +1,9 @@ +ext { + extName = 'Fênix Manhwas' + extClass = '.FenixManhwas' + themePkg = 'zeistmanga' + baseUrl = 'https://fenixleitura.blogspot.com' + overrideVersionCode = 0 +} + +apply from: "$rootDir/common.gradle" diff --git a/src/pt/fenixmanhwas/res/mipmap-hdpi/ic_launcher.png b/src/pt/fenixmanhwas/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..880d6a033 Binary files /dev/null and b/src/pt/fenixmanhwas/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/pt/fenixmanhwas/res/mipmap-mdpi/ic_launcher.png b/src/pt/fenixmanhwas/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..ba2b24e9c Binary files /dev/null and b/src/pt/fenixmanhwas/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/pt/fenixmanhwas/res/mipmap-xhdpi/ic_launcher.png b/src/pt/fenixmanhwas/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..f873f04a0 Binary files /dev/null and b/src/pt/fenixmanhwas/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/pt/fenixmanhwas/res/mipmap-xxhdpi/ic_launcher.png b/src/pt/fenixmanhwas/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..ec53622ea Binary files /dev/null and b/src/pt/fenixmanhwas/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/pt/fenixmanhwas/res/mipmap-xxxhdpi/ic_launcher.png b/src/pt/fenixmanhwas/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..8e5c5473b Binary files /dev/null and b/src/pt/fenixmanhwas/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/pt/fenixmanhwas/src/eu/kanade/tachiyomi/extension/pt/fenixmanhwas/FenixManhwas.kt b/src/pt/fenixmanhwas/src/eu/kanade/tachiyomi/extension/pt/fenixmanhwas/FenixManhwas.kt new file mode 100644 index 000000000..62e0471b0 --- /dev/null +++ b/src/pt/fenixmanhwas/src/eu/kanade/tachiyomi/extension/pt/fenixmanhwas/FenixManhwas.kt @@ -0,0 +1,91 @@ +package eu.kanade.tachiyomi.extension.pt.fenixmanhwas + +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistManga +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistMangaDto +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistMangaEntryDto +import eu.kanade.tachiyomi.network.GET +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.util.asJsoup +import kotlinx.serialization.decodeFromString +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Request +import okhttp3.Response + +class FenixManhwas : ZeistManga( + "Fênix Manhwas", + "https://fenixleitura.blogspot.com", + "pt-BR", +) { + override val supportsLatest = false + + override fun popularMangaRequest(page: Int) = latestUpdatesRequest(page) + + override fun popularMangaParse(response: Response) = latestUpdatesParse(response) + + override fun mangaDetailsParse(response: Response) = SManga.create().apply { + val document = response.asJsoup() + title = document.selectFirst("h1")!!.text() + thumbnail_url = document.selectFirst(".thum")?.attr("style")?.imgAttr() + genre = document.select("a[rel=tag]").joinToString { it.text() } + setUrlWithoutDomain(document.location()) + } + + override fun chapterListRequest(manga: SManga): Request { + val url = "$baseUrl/feeds/posts/default/-/".toHttpUrl().newBuilder() + .addPathSegment(manga.title) + .addQueryParameter("alt", "json") + .addQueryParameter("start-index", "1") + .addQueryParameter("max-results", "99999") + .addQueryParameter("orderby", "updated") + .build() + return GET(url, headers) + } + + override fun chapterListParse(response: Response): List { + val result = json.decodeFromString(response.body.string()) + return result.feed?.entry + ?.filter { it.category.orEmpty().any { category -> category.term == chapterCategory } } + ?.map { it.toSChapter(baseUrl) } + ?.sortedBy { it.name } + ?.reversed() + ?: throw Exception("Failed to parse from chapter API") + } + + override fun pageListRequest(chapter: SChapter): Request { + val url = "$baseUrl/feeds/posts/default/-/Chapter?alt=json" + val chapterHeaders = headers.newBuilder() + .set("Referer", "$baseUrl${chapter.url}") + .build() + return GET(url, chapterHeaders) + } + + override fun pageListParse(response: Response): List { + val chapterUrl = response.request.headers.get("Referer")!! + val chapterRef = chapterUrl + .substringAfterLast("/") + .substringBeforeLast(".") + + val result = json.decodeFromString(response.body.string()) + val mangaEntryDto: ZeistMangaEntryDto = result.feed?.entry + ?.firstOrNull { it.url?.firstOrNull { link -> link.href.contains(chapterRef, true) } != null } + ?: throw Exception("Páginas não encontradas") + + return mangaEntryDto.content!!.t.pagesURL().mapIndexed { index, imageUrl -> + Page(index, imageUrl = imageUrl) + } + } + + private fun String.pagesURL(): List { + val regex = """src="(?[^"]*)"""".toRegex() + val matches = regex.findAll(this) + return matches.map { it.groups["url"]?.value }.toList() + } + + private fun String.imgAttr(): String? { + val regex = """url\("(?[^"]+)"\)""".toRegex() + val matchResult = regex.find(this) + return matchResult?.groups?.get("url")?.value + } +}