diff --git a/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt b/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt index 87f23619c..a8aafa6ce 100644 --- a/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt +++ b/lib-multisrc/zeistmanga/src/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt @@ -114,7 +114,7 @@ abstract class ZeistManga( val result = json.decodeFromString(jsonString) val mangas = result.feed?.entry.orEmpty() - .filter { it.category.orEmpty().any { category -> category.term == "Series" } } // Default category for all series + .filter { it.category.orEmpty().any { category -> category.term == mangaCategory } } .filterNot { it.category.orEmpty().any { category -> excludedCategories.contains(category.term) } } .map { it.toSManga(baseUrl) } diff --git a/src/pt/traducoesdolipe/build.gradle b/src/pt/traducoesdolipe/build.gradle new file mode 100644 index 000000000..85333b6d0 --- /dev/null +++ b/src/pt/traducoesdolipe/build.gradle @@ -0,0 +1,9 @@ +ext { + extName = 'Traduções do Lipe' + extClass = '.TraducoesDoLipe' + themePkg = 'zeistmanga' + baseUrl = 'https://traducoesdolipe.blogspot.com' + overrideVersionCode = 0 +} + +apply from: "$rootDir/common.gradle" diff --git a/src/pt/traducoesdolipe/res/mipmap-hdpi/ic_launcher.png b/src/pt/traducoesdolipe/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..1eb5af2f4 Binary files /dev/null and b/src/pt/traducoesdolipe/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/pt/traducoesdolipe/res/mipmap-mdpi/ic_launcher.png b/src/pt/traducoesdolipe/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..b34715539 Binary files /dev/null and b/src/pt/traducoesdolipe/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/pt/traducoesdolipe/res/mipmap-xhdpi/ic_launcher.png b/src/pt/traducoesdolipe/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..dd85dd62f Binary files /dev/null and b/src/pt/traducoesdolipe/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/pt/traducoesdolipe/res/mipmap-xxhdpi/ic_launcher.png b/src/pt/traducoesdolipe/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..89a65295a Binary files /dev/null and b/src/pt/traducoesdolipe/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/pt/traducoesdolipe/res/mipmap-xxxhdpi/ic_launcher.png b/src/pt/traducoesdolipe/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..1b5fab773 Binary files /dev/null and b/src/pt/traducoesdolipe/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/pt/traducoesdolipe/src/eu/kanade/tachiyomi/extension/pt/traducoesdolipe/TraducoesDoLipe.kt b/src/pt/traducoesdolipe/src/eu/kanade/tachiyomi/extension/pt/traducoesdolipe/TraducoesDoLipe.kt new file mode 100644 index 000000000..d2fb37275 --- /dev/null +++ b/src/pt/traducoesdolipe/src/eu/kanade/tachiyomi/extension/pt/traducoesdolipe/TraducoesDoLipe.kt @@ -0,0 +1,89 @@ +package eu.kanade.tachiyomi.extension.pt.traducoesdolipe + +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistManga +import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistMangaDto +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess +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.Request +import okhttp3.Response +import org.jsoup.nodes.Element +import rx.Observable + +class TraducoesDoLipe : ZeistManga( + "Traduções do Lipe", + "https://traducoesdolipe.blogspot.com", + "pt-BR", +) { + override val supportsLatest = false + override val mangaCategory = "Projeto" + override val chapterCategory = "Capítulo" + override val hasFilters = true + override val hasStatusFilter = false + override val hasTypeFilter = false + override val hasLanguageFilter = false + override val hasGenreFilter = true + + 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("meta[property='og:description']")!!.attr("content").trim() + description = document.selectFirst(".synopsis")?.text() + thumbnail_url = document.selectFirst("meta[property='og:image']")?.attr("content") + genre = document.select(".genres a").joinToString { it.text() } + status = parseStatus(document.selectFirst(".status")!!.ownText().trim()) + setUrlWithoutDomain(document.location()) + } + + override fun chapterListRequest(manga: SManga): Request { + val projectName = manga.url.substringAfterLast("#") + val url = apiUrl(chapterCategory) + .addPathSegments(projectName) + .addQueryParameter("max-results", maxChapterResults.toString()) + .build() + return GET(url, headers) + } + + override fun fetchChapterList(manga: SManga): Observable> { + val project = client.newCall(mangaDetailsRequest(manga)).execute().let { + it.asJsoup().select("script").map(Element::html) + .firstOrNull { script -> script.contains("catNameProject") } + ?.let { script -> PROJECT_NAME_REGEX.find(script)?.groups?.get("project")?.value } + } + + return client.newCall(chapterListRequest(manga.apply { url = "$url#$project" })) + .asObservableSuccess() + .map(::chapterListParse) + } + + 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) } + ?: throw Exception("Failed to parse from chapter API") + } + + override fun pageListParse(response: Response): List { + val document = response.asJsoup() + val pages = document.selectFirst(".chapter script")!!.html().let { + val list = PAGES_REGEX.find(it)?.groups?.get("pages")?.value + json.decodeFromString>(list!!) + } + + return pages.mapIndexed { index, imageUrl -> + Page(index, imageUrl = imageUrl) + } + } + + companion object { + val PROJECT_NAME_REGEX = """=\s+?\('(?[^']+)""".toRegex() + val PAGES_REGEX = """=(?\[[^]]+])""".toRegex() + } +}