Mangadexwip (#445)

* update Mangadex icon

* fixed html encoding on groups
prepped for new mangadex api version
added tristate genre
removed header as its not needed anymore

* added original language filter

* update build.gradle

* update Mangadex icon

* fixed html encoding on groups
prepped for new mangadex api version
added tristate genre
removed header as its not needed anymore

* added original language filter

* mangadex api update
This commit is contained in:
Carlos 2018-08-07 19:57:07 -04:00 committed by GitHub
parent 934b69d9cd
commit a966c1d36e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 26 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -68,28 +68,24 @@ open class Mangadex(override val lang: String, private val internalLang: String,
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}" "${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
} }
override fun popularMangaSelector() = "div.col-sm-6" override fun popularMangaSelector() = "div.col-lg-6.border-bottom.pl-0.my-1"
override fun latestUpdatesSelector() = ".table-responsive tbody tr a.manga_title[href*=manga]" override fun latestUpdatesSelector() = "tr a.manga_title"
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
return GET("$baseUrl/titles/0/$page", headers) return GET("$baseUrl/titles/0/$page/", headers)
} }
override fun latestUpdatesRequest(page: Int): Request { override fun latestUpdatesRequest(page: Int): Request {
return GET("$baseUrl/0/$page", headers) return GET("$baseUrl/updates/$page", headers)
} }
override fun popularMangaFromElement(element: Element): SManga { override fun popularMangaFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
element.select("div.large_logo img").first().let {
manga.thumbnail_url = baseUrl + it.attr("src")
}
element.select("a.manga_title").first().let { element.select("a.manga_title").first().let {
val url = removeMangaNameFromUrl(it.attr("href")) val url = removeMangaNameFromUrl(it.attr("href"))
manga.setUrlWithoutDomain(url) manga.setUrlWithoutDomain(url)
manga.title = it.text().trim() manga.title = it.text().trim()
manga.author = it?.text()?.trim()
} }
return manga return manga
} }
@ -152,20 +148,10 @@ open class Mangadex(override val lang: String, private val internalLang: String,
} }
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val byGenre = filters.find { it is GenreList }
val genresToInclude = mutableListOf<String>() val genresToInclude = mutableListOf<String>()
val genresToExclude = mutableListOf<String>() val genresToExclude = mutableListOf<String>()
if (byGenre != null) {
byGenre as GenreList
byGenre.state.forEach { genre ->
if (genre.isExcluded()) {
genresToExclude.add(genre.id)
} else if (genre.isIncluded()) {
genresToInclude.add(genre.id)
}
}
}
//do traditional search //do traditional search
val url = HttpUrl.parse("$baseUrl/?page=search")!!.newBuilder().addQueryParameter("s", "0").addQueryParameter("p", page.toString()).addQueryParameter("title", query.replace(whitespaceRegex, " ")) val url = HttpUrl.parse("$baseUrl/?page=search")!!.newBuilder().addQueryParameter("s", "0").addQueryParameter("p", page.toString()).addQueryParameter("title", query.replace(whitespaceRegex, " "))
filters.forEach { filter -> filters.forEach { filter ->
@ -182,24 +168,34 @@ open class Mangadex(override val lang: String, private val internalLang: String,
url.addQueryParameter("source_lang", number) url.addQueryParameter("source_lang", number)
} }
} }
is GenreList -> {
filter.state.forEach { genre ->
if (genre.isExcluded()) {
genresToExclude.add(genre.id)
} else if (genre.isIncluded()) {
genresToInclude.add(genre.id)
}
}
}
} }
} }
var urlToUse = url.toString()
if (genresToInclude.isNotEmpty()) { if (genresToInclude.isNotEmpty()) {
url.addQueryParameter("genres_inc", genresToInclude.joinToString(",")) urlToUse = urlToUse + ("?genres_inc=") + genresToInclude.joinToString()
} }
if (genresToExclude.isNotEmpty()) { if (genresToExclude.isNotEmpty()) {
url.addQueryParameter("genres_exc", genresToExclude.joinToString(",")) urlToUse = urlToUse + ("?genres_exc=") + genresToExclude.joinToString()
} }
return GET(url.toString(), headers) return GET(urlToUse, headers)
} }
override fun searchMangaSelector() = "div.col-sm-6" override fun searchMangaSelector() = "div.col-lg-6.border-bottom.pl-0.my-1"
override fun searchMangaFromElement(element: Element): SManga { override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
element.select("div.large_logo img").first().let { element.select("div.rounded.large_logo.mr-2 img").first().let {
manga.thumbnail_url = baseUrl + it.attr("src") manga.thumbnail_url = baseUrl + it.attr("src")
} }
element.select("a.manga_title").first().let { element.select("a.manga_title").first().let {
@ -375,7 +371,7 @@ open class Mangadex(override val lang: String, private val internalLang: String,
val server = json.get("server").string val server = json.get("server").string
pageArray.forEach { pageArray.forEach {
val url = "$server$hash/$it" val url = "$server$hash/${it.asString}"
pages.add(Page(pages.size, "", getImageUrl(url))) pages.add(Page(pages.size, "", getImageUrl(url)))
} }