Fix covers url on Mangachan. (#1045)

Fix some warnings.
This commit is contained in:
Taumer 2017-10-29 17:22:04 +03:00 committed by inorichi
parent 4ae00c80ca
commit 6b1a3a20e5
3 changed files with 21 additions and 32 deletions

View file

@ -23,9 +23,8 @@ class Mangachan : ParsedHttpSource() {
override val supportsLatest = true override val supportsLatest = true
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request =
return GET("$baseUrl/mostfavorites?offset=${20 * (page - 1)}", headers) GET("$baseUrl/mostfavorites?offset=${20 * (page - 1)}", headers)
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
var pageNum = 1 var pageNum = 1
@ -48,9 +47,7 @@ class Mangachan : ParsedHttpSource() {
return GET(url, headers) return GET(url, headers)
} }
override fun latestUpdatesRequest(page: Int): Request { override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/newestch?page=$page")
return GET("$baseUrl/newestch?page=$page")
}
override fun popularMangaSelector() = "div.content_row" override fun popularMangaSelector() = "div.content_row"
@ -76,9 +73,7 @@ class Mangachan : ParsedHttpSource() {
return manga return manga
} }
override fun searchMangaFromElement(element: Element): SManga { override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
return popularMangaFromElement(element)
}
override fun popularMangaNextPageSelector() = "a:contains(Вперед)" override fun popularMangaNextPageSelector() = "a:contains(Вперед)"
@ -125,16 +120,14 @@ class Mangachan : ParsedHttpSource() {
manga.genre = infoElement.select("tr:eq(5) > td:eq(1)").text() manga.genre = infoElement.select("tr:eq(5) > td:eq(1)").text()
manga.status = parseStatus(infoElement.select("tr:eq(4) > td:eq(1)").text()) manga.status = parseStatus(infoElement.select("tr:eq(4) > td:eq(1)").text())
manga.description = descElement.textNodes().first().text() manga.description = descElement.textNodes().first().text()
manga.thumbnail_url = baseUrl + imgElement.attr("src") manga.thumbnail_url = imgElement.attr("src")
return manga return manga
} }
private fun parseStatus(element: String): Int { private fun parseStatus(element: String): Int = when {
when { element.contains("перевод завершен") -> SManga.COMPLETED
element.contains("перевод завершен") -> return SManga.COMPLETED element.contains("перевод продолжается") -> SManga.ONGOING
element.contains("перевод продолжается") -> return SManga.ONGOING else -> SManga.UNKNOWN
else -> return SManga.UNKNOWN
}
} }
override fun chapterListSelector() = "table.table_cha tr:gt(1)" override fun chapterListSelector() = "table.table_cha tr:gt(1)"

View file

@ -50,7 +50,7 @@ class Mintmanga : ParsedHttpSource() {
override fun latestUpdatesNextPageSelector() = "a.nextLink" override fun latestUpdatesNextPageSelector() = "a.nextLink"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val genres = filters.filterIsInstance<Genre>().map { it.id + arrayOf("=", "=in", "=ex")[it.state] }.joinToString("&") val genres = filters.filterIsInstance<Genre>().joinToString("&") { it.id + arrayOf("=", "=in", "=ex")[it.state] }
return GET("$baseUrl/search/advanced?q=$query&$genres", headers) return GET("$baseUrl/search/advanced?q=$query&$genres", headers)
} }
@ -73,13 +73,11 @@ class Mintmanga : ParsedHttpSource() {
return manga return manga
} }
private fun parseStatus(element: String): Int { private fun parseStatus(element: String): Int = when {
when { element.contains("<h3>Запрещена публикация произведения по копирайту</h3>") -> SManga.LICENSED
element.contains("<h3>Запрещена публикация произведения по копирайту</h3>") -> return SManga.LICENSED element.contains("<h1 class=\"names\"> Сингл") || element.contains("<b>Перевод:</b> завершен") -> SManga.COMPLETED
element.contains("<h1 class=\"names\"> Сингл") || element.contains("<b>Перевод:</b> завершен") -> return SManga.COMPLETED element.contains("<b>Перевод:</b> продолжается") -> SManga.ONGOING
element.contains("<b>Перевод:</b> продолжается") -> return SManga.ONGOING else -> SManga.UNKNOWN
else -> return SManga.UNKNOWN
}
} }
override fun chapterListSelector() = "div.chapters-link tbody tr" override fun chapterListSelector() = "div.chapters-link tbody tr"

View file

@ -50,7 +50,7 @@ class Readmanga : ParsedHttpSource() {
override fun latestUpdatesNextPageSelector() = "a.nextLink" override fun latestUpdatesNextPageSelector() = "a.nextLink"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val genres = filters.filterIsInstance<Genre>().map { it.id + arrayOf("=", "=in", "=ex")[it.state] }.joinToString("&") val genres = filters.filterIsInstance<Genre>().joinToString("&") { it.id + arrayOf("=", "=in", "=ex")[it.state] }
return GET("$baseUrl/search/advanced?q=$query&$genres", headers) return GET("$baseUrl/search/advanced?q=$query&$genres", headers)
} }
@ -73,13 +73,11 @@ class Readmanga : ParsedHttpSource() {
return manga return manga
} }
private fun parseStatus(element: String): Int { private fun parseStatus(element: String): Int = when {
when { element.contains("<h3>Запрещена публикация произведения по копирайту</h3>") -> SManga.LICENSED
element.contains("<h3>Запрещена публикация произведения по копирайту</h3>") -> return SManga.LICENSED element.contains("<h1 class=\"names\"> Сингл") || element.contains("<b>Перевод:</b> завершен") -> SManga.COMPLETED
element.contains("<h1 class=\"names\"> Сингл") || element.contains("<b>Перевод:</b> завершен") -> return SManga.COMPLETED element.contains("<b>Перевод:</b> продолжается") -> SManga.ONGOING
element.contains("<b>Перевод:</b> продолжается") -> return SManga.ONGOING else -> SManga.UNKNOWN
else -> return SManga.UNKNOWN
}
} }
override fun chapterListSelector() = "div.chapters-link tbody tr" override fun chapterListSelector() = "div.chapters-link tbody tr"