MangaKakalot: Add comics filtering (#1471)
MangaKakalot: Add comics filtering
This commit is contained in:
		
							parent
							
								
									e8426d112c
								
							
						
					
					
						commit
						3df4976fed
					
				| @ -5,7 +5,7 @@ ext { | |||||||
|     appName = 'Tachiyomi: MangaKakalot' |     appName = 'Tachiyomi: MangaKakalot' | ||||||
|     pkgNameSuffix = 'en.mangakakalot' |     pkgNameSuffix = 'en.mangakakalot' | ||||||
|     extClass = '.Mangakakalot' |     extClass = '.Mangakakalot' | ||||||
|     extVersionCode = 6 |     extVersionCode = 7 | ||||||
|     libVersion = '1.2' |     libVersion = '1.2' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,13 +1,13 @@ | |||||||
| package eu.kanade.tachiyomi.extension.en.mangakakalot | package eu.kanade.tachiyomi.extension.en.mangakakalot | ||||||
| 
 | 
 | ||||||
| import eu.kanade.tachiyomi.network.GET | import eu.kanade.tachiyomi.network.GET | ||||||
| import eu.kanade.tachiyomi.source.model.FilterList | import eu.kanade.tachiyomi.source.model.* | ||||||
| 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 eu.kanade.tachiyomi.source.online.ParsedHttpSource | ||||||
|  | import eu.kanade.tachiyomi.util.asJsoup | ||||||
|  | import okhttp3.HttpUrl | ||||||
| import okhttp3.OkHttpClient | import okhttp3.OkHttpClient | ||||||
| import okhttp3.Request | import okhttp3.Request | ||||||
|  | import okhttp3.Response | ||||||
| import org.jsoup.nodes.Document | import org.jsoup.nodes.Document | ||||||
| import org.jsoup.nodes.Element | import org.jsoup.nodes.Element | ||||||
| import java.text.ParseException | import java.text.ParseException | ||||||
| @ -58,9 +58,24 @@ class Mangakakalot : ParsedHttpSource() { | |||||||
|     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { |     override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { | ||||||
|         // Site ignores everything after the first word |         // Site ignores everything after the first word | ||||||
|         val substringBefore = query.replace(" ", "_").replace(",", "_").replace(":", "_") |         val substringBefore = query.replace(" ", "_").replace(",", "_").replace(":", "_") | ||||||
|         val url = "$baseUrl/search/$substringBefore?page=$page" |         val url = HttpUrl.parse("$baseUrl/manga_list")!!.newBuilder() | ||||||
|         return GET(url, headers) |         url.addQueryParameter("page", page.toString()) | ||||||
|  |         filters.forEach { filter -> | ||||||
|  |             when (filter) { | ||||||
|  |                 is SortFilter -> { | ||||||
|  |                     url.addQueryParameter("type", filter.toUriPart()) | ||||||
|                 } |                 } | ||||||
|  |                 is StatusFilter -> { | ||||||
|  |                     url.addQueryParameter("state", filter.toUriPart()) | ||||||
|  |                 } | ||||||
|  |                 is GenreFilter -> { | ||||||
|  |                     url.addQueryParameter("category", filter.toUriPart()) | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return if(query.isNotBlank()) { | ||||||
|  |             GET("$baseUrl/search/$substringBefore?page=$page") | ||||||
|  |         } else GET(url.build().toString(), headers)    } | ||||||
| 
 | 
 | ||||||
|     override fun searchMangaSelector() = ".panel_story_list .story_item" |     override fun searchMangaSelector() = ".panel_story_list .story_item" | ||||||
| 
 | 
 | ||||||
| @ -68,6 +83,22 @@ class Mangakakalot : ParsedHttpSource() { | |||||||
| 
 | 
 | ||||||
|     override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() |     override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() | ||||||
| 
 | 
 | ||||||
|  |     override fun searchMangaParse(response: Response): MangasPage { | ||||||
|  |         val document = response.asJsoup() | ||||||
|  |         val mangaSelector = if (document.select(searchMangaSelector()).isNotEmpty()) { | ||||||
|  |             searchMangaSelector() | ||||||
|  |         } else { | ||||||
|  |             popularMangaSelector() | ||||||
|  |         } | ||||||
|  |         val mangas = document.select(mangaSelector).map { element -> | ||||||
|  |             searchMangaFromElement(element) | ||||||
|  |         } | ||||||
|  |         val hasNextPage = searchMangaNextPageSelector().let { selector -> | ||||||
|  |             document.select(selector).first() | ||||||
|  |         } != null | ||||||
|  |         return MangasPage(mangas, hasNextPage) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     override fun mangaDetailsRequest(manga: SManga): Request { |     override fun mangaDetailsRequest(manga: SManga): Request { | ||||||
|         if (manga.url.startsWith("http")) { |         if (manga.url.startsWith("http")) { | ||||||
|             return GET(manga.url, headers) |             return GET(manga.url, headers) | ||||||
| @ -168,6 +199,73 @@ class Mangakakalot : ParsedHttpSource() { | |||||||
| 
 | 
 | ||||||
|     override fun imageUrlParse(document: Document): String = throw  UnsupportedOperationException("No used") |     override fun imageUrlParse(document: Document): String = throw  UnsupportedOperationException("No used") | ||||||
| 
 | 
 | ||||||
|     override fun getFilterList() = FilterList() |     override fun getFilterList() = FilterList( | ||||||
|  |             Filter.Header("NOTE: Ignored if using text search!"), | ||||||
|  |             Filter.Separator(), | ||||||
|  |             SortFilter(), | ||||||
|  |             StatusFilter(), | ||||||
|  |             GenreFilter() | ||||||
|  |     ) | ||||||
| 
 | 
 | ||||||
|  |     private class SortFilter : UriPartFilter("Sort", arrayOf( | ||||||
|  |             Pair("latest", "Latest"), | ||||||
|  |             Pair("newest", "Newest"), | ||||||
|  |             Pair("topview", "Top read") | ||||||
|  |     )) | ||||||
|  | 
 | ||||||
|  |     private class StatusFilter : UriPartFilter("Status", arrayOf( | ||||||
|  |             Pair("all", "ALL"), | ||||||
|  |             Pair("completed", "Completed"), | ||||||
|  |             Pair("ongoing", "Ongoing"), | ||||||
|  |             Pair("drop", "Dropped") | ||||||
|  |     )) | ||||||
|  | 
 | ||||||
|  |     private class GenreFilter : UriPartFilter("Category", arrayOf( | ||||||
|  |             Pair("all", "ALL"), | ||||||
|  |             Pair("2", "Action"), | ||||||
|  |             Pair("3", "Adult"), | ||||||
|  |             Pair("4", "Adventure"), | ||||||
|  |             Pair("6", "Comedy"), | ||||||
|  |             Pair("7", "Cooking"), | ||||||
|  |             Pair("9", "Doujinshi"), | ||||||
|  |             Pair("10", "Drama"), | ||||||
|  |             Pair("11", "Ecchi"), | ||||||
|  |             Pair("12", "Fantasy"), | ||||||
|  |             Pair("13", "Gender bender"), | ||||||
|  |             Pair("14", "Harem"), | ||||||
|  |             Pair("15", "Historical"), | ||||||
|  |             Pair("16", "Horror"), | ||||||
|  |             Pair("45", "Isekai"), | ||||||
|  |             Pair("17", "Josei"), | ||||||
|  |             Pair("44", "Manhua"), | ||||||
|  |             Pair("43", "Manhwa"), | ||||||
|  |             Pair("19", "Martial arts"), | ||||||
|  |             Pair("20", "Mature"), | ||||||
|  |             Pair("21", "Mecha"), | ||||||
|  |             Pair("22", "Medical"), | ||||||
|  |             Pair("24", "Mystery"), | ||||||
|  |             Pair("25", "One shot"), | ||||||
|  |             Pair("26", "Psychological"), | ||||||
|  |             Pair("27", "Romance"), | ||||||
|  |             Pair("28", "School life"), | ||||||
|  |             Pair("29", "Sci fi"), | ||||||
|  |             Pair("30", "Seinen"), | ||||||
|  |             Pair("31", "Shoujo"), | ||||||
|  |             Pair("32", "Shoujo ai"), | ||||||
|  |             Pair("33", "Shounen"), | ||||||
|  |             Pair("34", "Shounen ai"), | ||||||
|  |             Pair("35", "Slice of life"), | ||||||
|  |             Pair("36", "Smut"), | ||||||
|  |             Pair("37", "Sports"), | ||||||
|  |             Pair("38", "Supernatural"), | ||||||
|  |             Pair("39", "Tragedy"), | ||||||
|  |             Pair("40", "Webtoons"), | ||||||
|  |             Pair("41", "Yaoi"), | ||||||
|  |             Pair("42", "Yuri") | ||||||
|  |     )) | ||||||
|  | 
 | ||||||
|  |     private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) : | ||||||
|  |         Filter.Select<String>(displayName, vals.map { it.second }.toTypedArray()) { | ||||||
|  |         fun toUriPart() = vals[state].first | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Rama Bondan Prakoso
						Rama Bondan Prakoso