|
@@ -30,7 +30,7 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
|
|
|
|
|
|
private val indexPattern = Pattern.compile("-index-(.*?)-")
|
|
|
|
|
|
- override fun popularMangaInitialUrl() = "$baseUrl/search/request.php?sortBy=popularity&sortOrder=descending"
|
|
|
+ override fun popularMangaInitialUrl() = "$baseUrl/search/request.php?sortBy=popularity&sortOrder=descending&todo=1"
|
|
|
|
|
|
override fun popularMangaSelector() = "div.requested > div.row"
|
|
|
|
|
@@ -64,20 +64,32 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
|
|
|
// Not used, overrides parent.
|
|
|
override fun popularMangaNextPageSelector() = ""
|
|
|
|
|
|
- override fun searchMangaInitialUrl(query: String, filters: List<Filter>): String {
|
|
|
- var url = "$baseUrl/search/request.php?sortBy=popularity&sortOrder=descending&keyword=$query"
|
|
|
+ override fun searchMangaInitialUrl(query: String, filters: List<Filter<*>>): String {
|
|
|
+ val url = HttpUrl.parse("$baseUrl/search/request.php").newBuilder()
|
|
|
+ if (!query.isEmpty()) url.addQueryParameter("keyword", query)
|
|
|
var genres: String? = null
|
|
|
- for (filter in filters) {
|
|
|
- if (filter.equals(completedFilter)) url += "&status=Complete"
|
|
|
- else if (genres == null) genres = filter.id
|
|
|
- else genres += "," + filter.id
|
|
|
+ var genresNo: String? = null
|
|
|
+ for (filter in if (filters.isEmpty()) [email protected] else filters) {
|
|
|
+ when (filter) {
|
|
|
+ is Sort -> filter.values[filter.state].keys.forEachIndexed { i, s ->
|
|
|
+ url.addQueryParameter(s, filter.values[filter.state].values[i])
|
|
|
+ }
|
|
|
+ is ListField -> if (filter.state != 0) url.addQueryParameter(filter.key, filter.values[filter.state])
|
|
|
+ is TextField -> if (!filter.state.isEmpty()) url.addQueryParameter(filter.key, filter.state)
|
|
|
+ is Genre -> when (filter.state) {
|
|
|
+ Filter.TriState.STATE_INCLUDE -> genres = if (genres == null) filter.id else genres + "," + filter.id
|
|
|
+ Filter.TriState.STATE_EXCLUDE -> genresNo = if (genresNo == null) filter.id else genresNo + "," + filter.id
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return if (genres == null) url else url + "&genre=$genres"
|
|
|
+ if (genres != null) url.addQueryParameter("genre", genres)
|
|
|
+ if (genresNo != null) url.addQueryParameter("genreNo", genresNo)
|
|
|
+ return url.toString()
|
|
|
}
|
|
|
|
|
|
override fun searchMangaSelector() = "div.searchResults > div.requested > div.row"
|
|
|
|
|
|
- override fun searchMangaRequest(page: MangasPage, query: String, filters: List<Filter>): Request {
|
|
|
+ override fun searchMangaRequest(page: MangasPage, query: String, filters: List<Filter<*>>): Request {
|
|
|
if (page.page == 1) {
|
|
|
page.url = searchMangaInitialUrl(query, filters)
|
|
|
}
|
|
@@ -95,7 +107,7 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
|
|
|
return Pair(body, requestUrl)
|
|
|
}
|
|
|
|
|
|
- override fun searchMangaParse(response: Response, page: MangasPage, query: String, filters: List<Filter>) {
|
|
|
+ override fun searchMangaParse(response: Response, page: MangasPage, query: String, filters: List<Filter<*>>) {
|
|
|
val document = response.asJsoup()
|
|
|
for (element in document.select(popularMangaSelector())) {
|
|
|
Manga.create(id).apply {
|
|
@@ -174,47 +186,67 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
|
|
|
|
|
|
override fun imageUrlParse(document: Document): String = document.select("img.CurImage").attr("src")
|
|
|
|
|
|
- private val completedFilter = Filter("Complete", "Completed")
|
|
|
+ private data class SortOption(val name: String, val keys: Array<String>, val values: Array<String>) {
|
|
|
+ override fun toString(): String = name
|
|
|
+ }
|
|
|
+
|
|
|
+ private class Sort(name: String, values: Array<SortOption>, state: Int = 0) : Filter.List<SortOption>(name, values, state)
|
|
|
+ private class Genre(name: String, val id: String = name.replace(' ', '_')) : Filter.TriState(name)
|
|
|
+ private class TextField(name: String, val key: String) : Filter.Text(name)
|
|
|
+ private class ListField(name: String, val key: String, values: Array<String>, state: Int = 0) : Filter.List<String>(name, values, state)
|
|
|
+
|
|
|
// [...document.querySelectorAll("label.triStateCheckBox input")].map(el => `Filter("${el.getAttribute('name')}", "${el.nextSibling.textContent.trim()}")`).join(',\n')
|
|
|
// http://mangasee.co/advanced-search/
|
|
|
- override fun getFilterList(): List<Filter> = listOf(
|
|
|
- completedFilter,
|
|
|
- Filter("Action", "Action"),
|
|
|
- Filter("Adult", "Adult"),
|
|
|
- Filter("Adventure", "Adventure"),
|
|
|
- Filter("Comedy", "Comedy"),
|
|
|
- Filter("Doujinshi", "Doujinshi"),
|
|
|
- Filter("Drama", "Drama"),
|
|
|
- Filter("Ecchi", "Ecchi"),
|
|
|
- Filter("Fantasy", "Fantasy"),
|
|
|
- Filter("Gender_Bender", "Gender Bender"),
|
|
|
- Filter("Harem", "Harem"),
|
|
|
- Filter("Hentai", "Hentai"),
|
|
|
- Filter("Historical", "Historical"),
|
|
|
- Filter("Horror", "Horror"),
|
|
|
- Filter("Josei", "Josei"),
|
|
|
- Filter("Lolicon", "Lolicon"),
|
|
|
- Filter("Martial_Arts", "Martial Arts"),
|
|
|
- Filter("Mature", "Mature"),
|
|
|
- Filter("Mecha", "Mecha"),
|
|
|
- Filter("Mystery", "Mystery"),
|
|
|
- Filter("Psychological", "Psychological"),
|
|
|
- Filter("Romance", "Romance"),
|
|
|
- Filter("School_Life", "School Life"),
|
|
|
- Filter("Sci-fi", "Sci-fi"),
|
|
|
- Filter("Seinen", "Seinen"),
|
|
|
- Filter("Shotacon", "Shotacon"),
|
|
|
- Filter("Shoujo", "Shoujo"),
|
|
|
- Filter("Shoujo_Ai", "Shoujo Ai"),
|
|
|
- Filter("Shounen", "Shounen"),
|
|
|
- Filter("Shounen_Ai", "Shounen Ai"),
|
|
|
- Filter("Slice_of_Life", "Slice of Life"),
|
|
|
- Filter("Smut", "Smut"),
|
|
|
- Filter("Sports", "Sports"),
|
|
|
- Filter("Supernatural", "Supernatural"),
|
|
|
- Filter("Tragedy", "Tragedy"),
|
|
|
- Filter("Yaoi", "Yaoi"),
|
|
|
- Filter("Yuri", "Yuri")
|
|
|
+ override fun getFilterList(): List<Filter<*>> = listOf(
|
|
|
+ TextField("Years", "year"),
|
|
|
+ TextField("Author", "author"),
|
|
|
+ Sort("Sort By", arrayOf(SortOption("Alphabetical A-Z", emptyArray(), emptyArray()),
|
|
|
+ SortOption("Alphabetical Z-A", arrayOf("sortOrder"), arrayOf("descending")),
|
|
|
+ SortOption("Newest", arrayOf("sortBy", "sortOrder"), arrayOf("dateUpdated", "descending")),
|
|
|
+ SortOption("Oldest", arrayOf("sortBy"), arrayOf("dateUpdated")),
|
|
|
+ SortOption("Most Popular", arrayOf("sortBy", "sortOrder"), arrayOf("popularity", "descending")),
|
|
|
+ SortOption("Least Popular", arrayOf("sortBy"), arrayOf("popularity"))
|
|
|
+ ), 4),
|
|
|
+ ListField("Scan Status", "status", arrayOf("Any", "Complete", "Discontinued", "Hiatus", "Incomplete", "Ongoing")),
|
|
|
+ ListField("Publish Status", "pstatus", arrayOf("Any", "Cancelled", "Complete", "Discontinued", "Hiatus", "Incomplete", "Ongoing", "Unfinished")),
|
|
|
+ ListField("Type", "type", arrayOf("Any", "Doujinshi", "Manga", "Manhua", "Manhwa", "OEL", "One-shot")),
|
|
|
+ Filter.Header("Genres"),
|
|
|
+ Genre("Action"),
|
|
|
+ Genre("Adult"),
|
|
|
+ Genre("Adventure"),
|
|
|
+ Genre("Comedy"),
|
|
|
+ Genre("Doujinshi"),
|
|
|
+ Genre("Drama"),
|
|
|
+ Genre("Ecchi"),
|
|
|
+ Genre("Fantasy"),
|
|
|
+ Genre("Gender Bender"),
|
|
|
+ Genre("Harem"),
|
|
|
+ Genre("Hentai"),
|
|
|
+ Genre("Historical"),
|
|
|
+ Genre("Horror"),
|
|
|
+ Genre("Josei"),
|
|
|
+ Genre("Lolicon"),
|
|
|
+ Genre("Martial Arts"),
|
|
|
+ Genre("Mature"),
|
|
|
+ Genre("Mecha"),
|
|
|
+ Genre("Mystery"),
|
|
|
+ Genre("Psychological"),
|
|
|
+ Genre("Romance"),
|
|
|
+ Genre("School Life"),
|
|
|
+ Genre("Sci-fi"),
|
|
|
+ Genre("Seinen"),
|
|
|
+ Genre("Shotacon"),
|
|
|
+ Genre("Shoujo"),
|
|
|
+ Genre("Shoujo Ai"),
|
|
|
+ Genre("Shounen"),
|
|
|
+ Genre("Shounen Ai"),
|
|
|
+ Genre("Slice of Life"),
|
|
|
+ Genre("Smut"),
|
|
|
+ Genre("Sports"),
|
|
|
+ Genre("Supernatural"),
|
|
|
+ Genre("Tragedy"),
|
|
|
+ Genre("Yaoi"),
|
|
|
+ Genre("Yuri")
|
|
|
)
|
|
|
|
|
|
override fun latestUpdatesInitialUrl(): String = "http://mangaseeonline.net/home/latest.request.php"
|