From 2a5edf4547c10fc6bb9c3c019e71bcc0bf5d7cea Mon Sep 17 00:00:00 2001 From: Taumer Date: Tue, 30 Aug 2016 14:23:47 +0300 Subject: [PATCH] Implement genre filter for Readmanga --- .../data/source/online/russian/Readmanga.kt | 59 ++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/russian/Readmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/russian/Readmanga.kt index b645db2d76..a874ba09f2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/russian/Readmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/russian/Readmanga.kt @@ -24,7 +24,8 @@ class Readmanga(context: Context, override val id: Int) : ParsedOnlineSource(con override fun popularMangaInitialUrl() = "$baseUrl/list?sortType=rate" - override fun searchMangaInitialUrl(query: String, filters: List) = "$baseUrl/search?q=$query" + override fun searchMangaInitialUrl(query: String, filters: List) = + "$baseUrl/search?q=$query&${filters.map { it.id + "=in" }.joinToString("&")}" override fun popularMangaSelector() = "div.desc" @@ -40,10 +41,14 @@ class Readmanga(context: Context, override val id: Int) : ParsedOnlineSource(con override fun searchMangaSelector() = popularMangaSelector() override fun searchMangaFromElement(element: Element, manga: Manga) { - popularMangaFromElement(element, manga) + element.select("h3 > a").first().let { + manga.setUrlWithoutDomain(it.attr("href")) + manga.title = it.attr("title") + } } - override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() + // max 200 results + override fun searchMangaNextPageSelector() = null override fun mangaDetailsParse(document: Document, manga: Manga) { val infoElement = document.select("div.leftContent").first() @@ -99,4 +104,52 @@ class Readmanga(context: Context, override val id: Int) : ParsedOnlineSource(con override fun pageListParse(document: Document, pages: MutableList) { } override fun imageUrlParse(document: Document) = "" + + /* [...document.querySelectorAll("tr.advanced_option:nth-child(1) > td:nth-child(3) span.js-link")].map((el,i) => { + * const onClick=el.getAttribute('onclick');const id=onClick.substr(31,onClick.length-33); + * return `Filter("${id}", "${el.textContent.trim()}")` }).join(',\n') + * on http://readmanga.me/search + */ + override fun getFilterList(): List = listOf( + Filter("el_5685", "арт"), + Filter("el_2155", "боевик"), + Filter("el_2143", "боевые искусства"), + Filter("el_2148", "вампиры"), + Filter("el_2142", "гарем"), + Filter("el_2156", "гендерная интрига"), + Filter("el_2146", "героическое фэнтези"), + Filter("el_2152", "детектив"), + Filter("el_2158", "дзёсэй"), + Filter("el_2141", "додзинси"), + Filter("el_2118", "драма"), + Filter("el_2154", "игра"), + Filter("el_2119", "история"), + Filter("el_2137", "кодомо"), + Filter("el_2136", "комедия"), + Filter("el_2147", "махо-сёдзё"), + Filter("el_2126", "меха"), + Filter("el_2132", "мистика"), + Filter("el_2133", "научная фантастика"), + Filter("el_2135", "повседневность"), + Filter("el_2151", "постапокалиптика"), + Filter("el_2130", "приключения"), + Filter("el_2144", "психология"), + Filter("el_2121", "романтика"), + Filter("el_2124", "самурайский боевик"), + Filter("el_2159", "сверхъестественное"), + Filter("el_2122", "сёдзё"), + Filter("el_2128", "сёдзё-ай"), + Filter("el_2134", "сёнэн"), + Filter("el_2139", "сёнэн-ай"), + Filter("el_2129", "спорт"), + Filter("el_2138", "сэйнэн"), + Filter("el_2153", "трагедия"), + Filter("el_2150", "триллер"), + Filter("el_2125", "ужасы"), + Filter("el_2140", "фантастика"), + Filter("el_2131", "фэнтези"), + Filter("el_2127", "школа"), + Filter("el_2149", "этти"), + Filter("el_2123", "юри") + ) } \ No newline at end of file