From 450c58a2990c265b3bfb027b6d3e1870a879c549 Mon Sep 17 00:00:00 2001 From: AbdullahM0hamed <25087116+AbdullahM0hamed@users.noreply.github.com> Date: Sat, 14 Nov 2020 17:57:18 +0000 Subject: [PATCH] deduplicate emerald search results --- .../kanade/tachiyomi/extension/all/emerald/Emerald.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/all/emerald/src/eu/kanade/tachiyomi/extension/all/emerald/Emerald.kt b/src/all/emerald/src/eu/kanade/tachiyomi/extension/all/emerald/Emerald.kt index 581b1f7a4..6a05e4d21 100644 --- a/src/all/emerald/src/eu/kanade/tachiyomi/extension/all/emerald/Emerald.kt +++ b/src/all/emerald/src/eu/kanade/tachiyomi/extension/all/emerald/Emerald.kt @@ -7,10 +7,12 @@ 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.model.MangasPage import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.HttpUrl import okhttp3.OkHttpClient import okhttp3.Request +import okhttp3.Response import org.json.JSONArray import org.json.JSONObject import org.jsoup.nodes.Document @@ -153,6 +155,15 @@ open class Emerald( override fun searchMangaNextPageSelector() = latestUpdatesNextPageSelector() + private val searchMangaTitles = HashSet() + + override fun searchMangaParse(response: Response): MangasPage { + val mp = super.searchMangaParse(response) + val manga = mp.mangas.distinctBy { it.title.toLowerCase() }.filterNot { searchMangaTitles.contains(it.title.toLowerCase()) } + searchMangaTitles.addAll(manga.map { it.title.toLowerCase() }) + return MangasPage(manga, mp.hasNextPage) + } + override fun mangaDetailsRequest(manga: SManga): Request { if (manga.url.startsWith("http")) { return GET(manga.url, headers)