Add "Completed" filter; fix Mangahere; fix Mangafox (#604)

* Add "Compled" filter to all english sources; fix Mangahere manga title extraction; fix Mangafox search.

* update Mangasee

* update Batoto
This commit is contained in:
paronos 2016-12-24 00:08:49 +01:00 committed by inorichi
parent 1f14240251
commit f1d84ccb49
6 changed files with 48 additions and 22 deletions

View File

@ -109,12 +109,17 @@ class Batoto(override val id: Int) : ParsedOnlineSource(), LoginSource {
override fun latestUpdatesNextPageSelector() = "#show_more_row"
override fun searchMangaInitialUrl(query: String, filters: List<Filter>) = "$baseUrl/search_ajax?name=${Uri.encode(query)}&order_cond=views&order=desc&p=1&genre_cond=and&genres=${getFilterParams(filters)}"
override fun searchMangaInitialUrl(query: String, filters: List<Filter>) = "$baseUrl/search_ajax?name=${Uri.encode(query)}&order_cond=views&order=desc&p=1${getFilterParams(filters)}"
private fun getFilterParams(filters: List<Filter>): String = filters
.map {
";i" + it.id
}.joinToString()
private fun getFilterParams(filters: List<Filter>): String {
var genres = ""
var completed = ""
for (filter in filters) {
if (filter.equals(completedFilter)) completed = "&completed=c"
else genres += ";i" + filter.id
}
return if (genres.isEmpty()) completed else "&genres=$genres&genre_cond=and$completed"
}
override fun searchMangaRequest(page: MangasPage, query: String, filters: List<Filter>): Request {
if (page.page == 1) {
@ -133,7 +138,7 @@ class Batoto(override val id: Int) : ParsedOnlineSource(), LoginSource {
}
page.nextPageUrl = document.select(searchMangaNextPageSelector()).first()?.let {
"$baseUrl/search_ajax?name=${Uri.encode(query)}&p=${page.page + 1}&order_cond=views&order=desc&genre_cond=and&genres=" + getFilterParams(filters)
"$baseUrl/search_ajax?name=${Uri.encode(query)}&order_cond=views&order=desc&p=${page.page + 1}${getFilterParams(filters)}"
}
}
@ -301,11 +306,13 @@ class Batoto(override val id: Int) : ParsedOnlineSource(), LoginSource {
}
}
private val completedFilter = Filter("completed", "Completed")
// [...document.querySelectorAll("#advanced_options div.genre_buttons")].map((el,i) => {
// const onClick=el.getAttribute('onclick');const id=onClick.substr(14,onClick.length-16);return `Filter("${id}", "${el.textContent.trim()}")`
// }).join(',\n')
// on https://bato.to/search
override fun getFilterList(): List<Filter> = listOf(
completedFilter,
Filter("40", "4-Koma"),
Filter("1", "Action"),
Filter("2", "Adventure"),

View File

@ -62,10 +62,10 @@ class Kissmanga(override val id: Int) : ParsedOnlineSource() {
val form = FormBody.Builder().apply {
add("authorArtist", "")
add("mangaName", query)
add("status", "")
this@Kissmanga.filters.forEach { filter ->
add("genres", if (filter in filters) "1" else "0")
if (filter.equals(completedFilter)) add("status", if (filter in filters) filter.id else "")
else add("genres", if (filter in filters) "1" else "0")
}
}
@ -131,9 +131,11 @@ class Kissmanga(override val id: Int) : ParsedOnlineSource() {
override fun imageUrlParse(document: Document) = ""
private val completedFilter = Filter("Completed", "Completed")
// $("select[name=\"genres\"]").map((i,el) => `Filter("${i}", "${$(el).next().text().trim()}")`).get().join(',\n')
// on http://kissmanga.com/AdvanceSearch
override fun getFilterList(): List<Filter> = listOf(
completedFilter,
Filter("0", "Action"),
Filter("1", "Adult"),
Filter("2", "Adventure"),

View File

@ -50,10 +50,10 @@ class Mangafox(override val id: Int) : ParsedOnlineSource() {
override fun searchMangaInitialUrl(query: String, filters: List<Filter>) =
"$baseUrl/search.php?name_method=cw&advopts=1&order=za&sort=views&name=$query&page=1&${filters.map { it.id + "=1" }.joinToString("&")}"
override fun searchMangaSelector() = "table#listing > tbody > tr:gt(0)"
override fun searchMangaSelector() = "div#mangalist > ul.list > li"
override fun searchMangaFromElement(element: Element, manga: Manga) {
element.select("a.series_preview").first().let {
element.select("a.title").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text()
}
@ -132,6 +132,7 @@ class Mangafox(override val id: Int) : ParsedOnlineSource() {
// $('select.genres').map((i,el)=>`Filter("${$(el).attr('name')}", "${$(el).next().text().trim()}")`).get().join(',\n')
// on http://kissmanga.com/AdvanceSearch
override fun getFilterList(): List<Filter> = listOf(
Filter("is_completed", "Completed"),
Filter("genres[Action]", "Action"),
Filter("genres[Adult]", "Adult"),
Filter("genres[Adventure]", "Adventure"),

View File

@ -30,13 +30,17 @@ class Mangahere(override val id: Int) : ParsedOnlineSource() {
override fun latestUpdatesSelector() = "div.directory_list > ul > li"
override fun popularMangaFromElement(element: Element, manga: Manga) {
element.select("div.title > a").first().let {
private fun mangaFromElement(query: String, element: Element, manga: Manga) {
element.select(query).first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.attr("title")
manga.title = if (it.hasAttr("title")) it.attr("title") else if (it.hasAttr("rel")) it.attr("rel") else it.text()
}
}
override fun popularMangaFromElement(element: Element, manga: Manga) {
mangaFromElement("div.title > a", element, manga)
}
override fun latestUpdatesFromElement(element: Element, manga: Manga) {
popularMangaFromElement(element, manga)
}
@ -50,10 +54,7 @@ class Mangahere(override val id: Int) : ParsedOnlineSource() {
override fun searchMangaSelector() = "div.result_search > dl:has(dt)"
override fun searchMangaFromElement(element: Element, manga: Manga) {
element.select("a.manga_info").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.attr("title")
}
mangaFromElement("a.manga_info", element, manga)
}
override fun searchMangaNextPageSelector() = "div.next-page > a.next"
@ -135,6 +136,7 @@ class Mangahere(override val id: Int) : ParsedOnlineSource() {
// [...document.querySelectorAll("select[id^='genres'")].map((el,i) => `Filter("${el.getAttribute('name')}", "${el.nextSibling.nextSibling.textContent.trim()}")`).join(',\n')
// http://www.mangahere.co/advsearch.htm
override fun getFilterList(): List<Filter> = listOf(
Filter("is_completed", "Completed"),
Filter("genres[Action]", "Action"),
Filter("genres[Adventure]", "Adventure"),
Filter("genres[Comedy]", "Comedy"),

View File

@ -66,8 +66,16 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
// Not used, overrides parent.
override fun popularMangaNextPageSelector() = ""
override fun searchMangaInitialUrl(query: String, filters: List<Filter>) =
"$baseUrl/search/request.php?sortBy=popularity&sortOrder=descending&keyword=$query&genre=${filters.map { it.id }.joinToString(",")}"
override fun searchMangaInitialUrl(query: String, filters: List<Filter>): String {
var url = "$baseUrl/search/request.php?sortBy=popularity&sortOrder=descending&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
}
return if (genres == null) url else url + "&genre=$genres"
}
override fun searchMangaSelector() = "div.searchResults > div.requested > div.row"
@ -168,9 +176,11 @@ 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")
// [...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"),
@ -250,4 +260,4 @@ class Mangasee(override val id: Int) : ParsedOnlineSource() {
}
}
}
}

View File

@ -72,10 +72,12 @@ class Readmangatoday(override val id: Int) : ParsedOnlineSource() {
val builder = okhttp3.FormBody.Builder()
builder.add("manga-name", query)
builder.add("type", "all")
builder.add("status", "both")
var status = "both"
for (filter in filters) {
builder.add("include[]", filter.id)
if (filter.equals(completedFilter)) status = filter.id
else builder.add("include[]", filter.id)
}
builder.add("status", status)
return POST(page.url, headers, builder.build())
}
@ -154,9 +156,11 @@ class Readmangatoday(override val id: Int) : ParsedOnlineSource() {
override fun imageUrlParse(document: Document) = document.select("img.img-responsive-2").first().attr("src")
private val completedFilter = Filter("completed", "Completed")
// [...document.querySelectorAll("ul.manga-cat span")].map(el => `Filter("${el.getAttribute('data-id')}", "${el.nextSibling.textContent.trim()}")`).join(',\n')
// http://www.readmanga.today/advanced-search
override fun getFilterList(): List<Filter> = listOf(
completedFilter,
Filter("2", "Action"),
Filter("4", "Adventure"),
Filter("5", "Comedy"),