Even more lint cleanup (#3191)

This commit is contained in:
TacoTheDank 2020-05-17 15:47:37 -04:00 committed by GitHub
parent a1857f5f35
commit 11ac392755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 76 additions and 83 deletions

View File

@ -294,7 +294,7 @@ class INKR : HttpSource() {
// Decrypt file content using XOR cipher with 101 as the key // Decrypt file content using XOR cipher with 101 as the key
val cipherKey = 101.toByte() val cipherKey = 101.toByte()
for (r in 0 until data.size) { for (r in data.indices) {
buffer[r + 15] = cipherKey xor data[r] buffer[r + 15] = cipherKey xor data[r]
} }

View File

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -198,7 +198,7 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(BROWSE_PREF, entry).commit() preferences.edit().putString(BROWSE_PREF, entry).commit()
} }
} }
@ -212,7 +212,7 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(LATEST_PREF, entry).commit() preferences.edit().putString(LATEST_PREF, entry).commit()
} }
} }
@ -231,7 +231,7 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(BROWSE_PREF, entry).commit() preferences.edit().putString(BROWSE_PREF, entry).commit()
} }
} }
@ -245,7 +245,7 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(LATEST_PREF, entry).commit() preferences.edit().putString(LATEST_PREF, entry).commit()
} }
} }

View File

@ -481,7 +481,7 @@ class MangaPark : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(SOURCE_PREF, entry).commit() preferences.edit().putString(SOURCE_PREF, entry).commit()
} }
} }
@ -499,7 +499,7 @@ class MangaPark : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(SOURCE_PREF, entry).commit() preferences.edit().putString(SOURCE_PREF, entry).commit()
} }
} }

View File

@ -206,7 +206,7 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(QUALITY_PREF, entry).commit() preferences.edit().putString(QUALITY_PREF, entry).commit()
} }
} }
@ -224,7 +224,7 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(QUALITY_PREF, entry).commit() preferences.edit().putString(QUALITY_PREF, entry).commit()
} }
} }

View File

@ -42,7 +42,7 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(SHOW_LOCKED_CHAPTERS, entry).commit() preferences.edit().putString(SHOW_LOCKED_CHAPTERS, entry).commit()
} }
} }
@ -60,7 +60,7 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String val selected = newValue as String
val index = this.findIndexOfValue(selected) val index = this.findIndexOfValue(selected)
val entry = entryValues.get(index) as String val entry = entryValues[index] as String
preferences.edit().putString(SHOW_LOCKED_CHAPTERS, entry).commit() preferences.edit().putString(SHOW_LOCKED_CHAPTERS, entry).commit()
} }
} }

View File

@ -250,7 +250,7 @@ class ManaMoa : ConfigurableSource, ParsedHttpSource() {
"" ""
} }
} }
.forEach { pages.add(Page(pages.size, decoder.request(it), "${it.substringBefore("!!")}")) } .forEach { pages.add(Page(pages.size, decoder.request(it), it.substringBefore("!!"))) }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }

View File

@ -59,7 +59,7 @@ class NaverChallenge : NaverComicChallengeBase("challenge") {
while (document.select(paginationNextPageSelector).hasText()) { while (document.select(paginationNextPageSelector).hasText()) {
document.select(paginationNextPageSelector).let { document.select(paginationNextPageSelector).let {
document = client.newCall(GET(it.attr("abs:href"))).execute().asJsoup() document = client.newCall(GET(it.attr("abs:href"))).execute().asJsoup()
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) } document.select(chapterListSelector()).map { element -> chapters.add(chapterFromElement(element)) }
} }
} }
return chapters return chapters

View File

@ -55,7 +55,7 @@ abstract class NaverComicBase(protected val mType: String) : ParsedHttpSource()
while (document.select(paginationNextPageSelector).isNotEmpty()) { while (document.select(paginationNextPageSelector).isNotEmpty()) {
document.select(paginationNextPageSelector).let { document.select(paginationNextPageSelector).let {
document = client.newCall(chapterListRequest(it.attr("href"), nextPage)).execute().asJsoup() document = client.newCall(chapterListRequest(it.attr("href"), nextPage)).execute().asJsoup()
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) } document.select(chapterListSelector()).map { element -> chapters.add(chapterFromElement(element)) }
nextPage++ nextPage++
} }
} }

View File

@ -187,8 +187,8 @@ class Hipercool : HttpSource() {
val regex = CHAPTER_REGEX.toRegex() val regex = CHAPTER_REGEX.toRegex()
val results = regex.find(chapter.url)!!.groupValues val results = regex.find(chapter.url)!!.groupValues
val bookSlug = results[1].toString() val bookSlug = results[1]
val chapterSlug = results[2].toString() val chapterSlug = results[2]
val images = results[3].toInt() val images = results[3].toInt()
val revision = results[4].toInt() val revision = results[4].toInt()
val pages = arrayListOf<Page>() val pages = arrayListOf<Page>()

View File

@ -54,7 +54,7 @@ class SuperMangas : SuperMangasGeneric(
Tag("30", "Ficção científica"), Tag("30", "Ficção científica"),
Tag("68", "Food"), Tag("68", "Food"),
Tag("72", "Gender Bender"), Tag("72", "Gender Bender"),
Tag("25", "Harém"), Tag("25", "Harém"),
Tag("48", "Histórico"), Tag("48", "Histórico"),
Tag("50", "Horror"), Tag("50", "Horror"),
Tag("75", "Isekai"), Tag("75", "Isekai"),

View File

@ -76,12 +76,12 @@ class YesMangas : ParsedHttpSource() {
override fun searchMangaNextPageSelector(): String? = null override fun searchMangaNextPageSelector(): String? = null
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
var container = document.select("div#descricao") val container = document.select("div#descricao")
var statusEl = container.select("ul li:contains(Status)") val statusEl = container.select("ul li:contains(Status)")
var authorEl = container.select("ul li:contains(Autor)") val authorEl = container.select("ul li:contains(Autor)")
var artistEl = container.select("ul li:contains(Desenho)") val artistEl = container.select("ul li:contains(Desenho)")
var genresEl = container.select("ul li:contains(Categorias)") val genresEl = container.select("ul li:contains(Categorias)")
var synopsis = container.select("article") val synopsis = container.select("article")
return SManga.create().apply { return SManga.create().apply {
status = parseStatus(removeLabel(statusEl.text())) status = parseStatus(removeLabel(statusEl.text()))
@ -108,11 +108,11 @@ class YesMangas : ParsedHttpSource() {
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
var script = document.select("script").last().data() val script = document.select("script").last().data()
var images = script.substringAfter(SCRIPT_BEGIN).substringBefore(SCRIPT_END) val images = script.substringAfter(SCRIPT_BEGIN).substringBefore(SCRIPT_END)
.replace(SCRIPT_REGEX.toRegex(), "") .replace(SCRIPT_REGEX.toRegex(), "")
var newDocument = Jsoup.parse(images) val newDocument = Jsoup.parse(images)
return newDocument.select("a img") return newDocument.select("a img")
.mapIndexed { i, el -> Page(i, "", el.attr("src")) } .mapIndexed { i, el -> Page(i, "", el.attr("src")) }
@ -128,6 +128,6 @@ class YesMangas : ParsedHttpSource() {
private const val SCRIPT_BEGIN = "var images = [" private const val SCRIPT_BEGIN = "var images = ["
private const val SCRIPT_END = "];" private const val SCRIPT_END = "];"
private const val SCRIPT_REGEX = "\"|," private const val SCRIPT_REGEX = "[\",]"
} }
} }

View File

@ -130,7 +130,7 @@ class Anibe : ParsedHttpSource() {
} }
}) })
for (i in 0 until jsonChapters.size) { for (i in jsonChapters.indices) {
val chapter = SChapter.create() val chapter = SChapter.create()
chapter.name = "Chapter: " + jsonChapters.elementAt(i) // Key for chapter in JSON object chapter.name = "Chapter: " + jsonChapters.elementAt(i) // Key for chapter in JSON object
chapter.url = "/posts/" + jsonManga["id"].asString + "?$i" chapter.url = "/posts/" + jsonManga["id"].asString + "?$i"

View File

@ -148,7 +148,7 @@ class ComX : ParsedHttpSource() {
} }
private fun chapterPageListParse(document: Document): List<String> { private fun chapterPageListParse(document: Document): List<String> {
return document.select("span[class=\"\"]").map { it -> it.text() } return document.select("span[class=\"\"]").map { it.text() }
} }
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {

View File

@ -33,7 +33,7 @@ class Desu : HttpSource() {
val arr = JSONArray(json) val arr = JSONArray(json)
val ret = ArrayList<SManga>(arr.length()) val ret = ArrayList<SManga>(arr.length())
for (i in 0 until arr.length()) { for (i in 0 until arr.length()) {
var obj = arr.getJSONObject(i) val obj = arr.getJSONObject(i)
ret.add(SManga.create().apply { ret.add(SManga.create().apply {
mangaFromJSON(obj, false) mangaFromJSON(obj, false)
}) })
@ -49,7 +49,7 @@ class Desu : HttpSource() {
description = obj.getString("description") description = obj.getString("description")
genre = if (chapter) { genre = if (chapter) {
val jsonArray = obj.getJSONArray("genres") val jsonArray = obj.getJSONArray("genres")
var genreList = kotlin.collections.mutableListOf<String>() val genreList = mutableListOf<String>()
for (i in 0 until jsonArray.length()) { for (i in 0 until jsonArray.length()) {
genreList.add(jsonArray.getJSONObject(i).getString("russian")) genreList.add(jsonArray.getJSONObject(i).getString("russian"))
} }
@ -74,8 +74,8 @@ class Desu : HttpSource() {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
var url = "$baseUrl/?limit=20&page=$page" var url = "$baseUrl/?limit=20&page=$page"
var types = mutableListOf<Type>() val types = mutableListOf<Type>()
var genres = mutableListOf<Genre>() val genres = mutableListOf<Genre>()
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter -> (if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
when (filter) { when (filter) {
is OrderBy -> url += "&order=" + arrayOf("popular", "updated", "name")[filter.state] is OrderBy -> url += "&order=" + arrayOf("popular", "updated", "name")[filter.state]
@ -84,13 +84,13 @@ class Desu : HttpSource() {
} }
} }
if (!types.isEmpty()) { if (types.isNotEmpty()) {
url += "&kinds=" + types.joinToString(",") { it.id } url += "&kinds=" + types.joinToString(",") { it.id }
} }
if (!genres.isEmpty()) { if (genres.isNotEmpty()) {
url += "&genres=" + genres.joinToString(",") { it.id } url += "&genres=" + genres.joinToString(",") { it.id }
} }
if (!query.isEmpty()) { if (query.isNotEmpty()) {
url += "&search=$query" url += "&search=$query"
} }
return GET(url) return GET(url)
@ -123,10 +123,10 @@ class Desu : HttpSource() {
ret.add(SChapter.create().apply { ret.add(SChapter.create().apply {
val ch = obj2.getString("ch") val ch = obj2.getString("ch")
val title = if (obj2.getString("title") == "null") "" else obj2.getString("title") val title = if (obj2.getString("title") == "null") "" else obj2.getString("title")
if (title.isEmpty()) { name = if (title.isEmpty()) {
name = "Глава $ch" "Глава $ch"
} else { } else {
name = "$ch - $title" "$ch - $title"
} }
val id = obj2.getString("id") val id = obj2.getString("id")
url = "/$cid/chapter/$id" url = "/$cid/chapter/$id"

View File

@ -233,7 +233,7 @@ class Mangachan : ParsedHttpSource() {
private class Status : Filter.Select<String>("Статус", arrayOf("Все", "Перевод завершен", "Выпуск завершен", "Онгоинг", "Новые главы")) private class Status : Filter.Select<String>("Статус", arrayOf("Все", "Перевод завершен", "Выпуск завершен", "Онгоинг", "Новые главы"))
private class OrderBy : Filter.Sort("Сортировка", private class OrderBy : Filter.Sort("Сортировка",
arrayOf("Дата", "Популярность", "Имя", "Главы"), arrayOf("Дата", "Популярность", "Имя", "Главы"),
Filter.Sort.Selection(1, false)) Selection(1, false))
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
Status(), Status(),

View File

@ -83,7 +83,7 @@ class Mintmanga : ParsedHttpSource() {
} }
} }
} }
if (!query.isEmpty()) { if (query.isNotEmpty()) {
url.addQueryParameter("q", query) url.addQueryParameter("q", query)
} }
return GET(url.toString().replace("=%3D", "="), headers) return GET(url.toString().replace("=%3D", "="), headers)

View File

@ -73,7 +73,7 @@ class Onlinecomics : ParsedHttpSource() {
document.select(selector).first() document.select(selector).first()
} != null } != null
return MangasPage(mangas.distinctBy { it -> it.url }, hasNextPage) return MangasPage(mangas.distinctBy { it.url }, hasNextPage)
} }
override fun popularMangaSelector() = "div.PrewLine" override fun popularMangaSelector() = "div.PrewLine"

View File

@ -83,7 +83,7 @@ class Readmanga : ParsedHttpSource() {
} }
} }
} }
if (!query.isEmpty()) { if (query.isNotEmpty()) {
url.addQueryParameter("q", query) url.addQueryParameter("q", query)
} }
return GET(url.toString().replace("=%3D", "="), headers) return GET(url.toString().replace("=%3D", "="), headers)

View File

@ -71,7 +71,7 @@ class Selfmanga : ParsedHttpSource() {
} }
} }
} }
if (!query.isEmpty()) { if (query.isNotEmpty()) {
url.addQueryParameter("q", query) url.addQueryParameter("q", query)
} }
return GET(url.toString().replace("=%3D", "="), headers) return GET(url.toString().replace("=%3D", "="), headers)

View File

@ -10,11 +10,9 @@ import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import okhttp3.OkHttpClient
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
class MangaDenizi : ParsedHttpSource() { class MangaDenizi : ParsedHttpSource() {
@ -96,9 +94,7 @@ class MangaDenizi : ParsedHttpSource() {
override fun mangaDetailsParse(document: Document) = SManga.create().apply { override fun mangaDetailsParse(document: Document) = SManga.create().apply {
description = document.select(".well > p").text() description = document.select(".well > p").text()
genre = document.select("dd > a[href*=category]").joinToString { it.text() } genre = document.select("dd > a[href*=category]").joinToString { it.text() }
status = document.select(".label.label-success").let { status = parseStatus(document.select(".label.label-success").text())
parseStatus(it.text())
}
thumbnail_url = document.select("img.img-responsive").attr("abs:src") thumbnail_url = document.select("img.img-responsive").attr("abs:src")
} }

View File

@ -8,9 +8,7 @@ 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 eu.kanade.tachiyomi.util.asJsoup
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale import java.util.Locale
import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -30,10 +28,10 @@ class SeriManga : ParsedHttpSource() {
override fun popularMangaSelector() = "a.manga-list-bg" override fun popularMangaSelector() = "a.manga-list-bg"
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
if (page == 1) { return if (page == 1) {
return GET("$baseUrl/mangalar", headers) GET("$baseUrl/mangalar", headers)
} else { } else {
return GET("$baseUrl/mangalar?page=$page", headers) GET("$baseUrl/mangalar?page=$page", headers)
} }
} }
@ -106,8 +104,8 @@ class SeriManga : ParsedHttpSource() {
override fun chapterFromElement(element: Element) = SChapter.create().apply { override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.select("a").attr("href")) setUrlWithoutDomain(element.select("a").attr("href"))
name = "${element.select("span").first().text()}: ${element.select("span").get(1).text()}" name = "${element.select("span").first().text()}: ${element.select("span")[1].text()}"
date_upload = dateFormat.parse(element.select("span").get(2).ownText()).time ?: 0 date_upload = dateFormat.parse(element.select("span")[2].ownText()).time ?: 0
} }
companion object { companion object {

View File

@ -105,10 +105,10 @@ class BlogTruyen : ParsedHttpSource() {
} }
} }
} }
if (genres.isNotEmpty()) temp = temp + "/" + genres.joinToString(",") temp = if (genres.isNotEmpty()) temp + "/" + genres.joinToString(",")
else temp = "$temp/-1" else "$temp/-1"
if (genresEx.isNotEmpty()) temp = temp + "/" + genresEx.joinToString(",") temp = if (genresEx.isNotEmpty()) temp + "/" + genresEx.joinToString(",")
else temp = "$temp/-1" else "$temp/-1"
val url = HttpUrl.parse(temp)!!.newBuilder() val url = HttpUrl.parse(temp)!!.newBuilder()
url.addQueryParameter("txt", query) url.addQueryParameter("txt", query)
if (aut.isNotEmpty()) url.addQueryParameter("aut", aut) if (aut.isNotEmpty()) url.addQueryParameter("aut", aut)

View File

@ -101,7 +101,7 @@ class Dmzj : HttpSource() {
params = "0" params = "0"
} }
val order = filters.filter { it is SortFilter }.map { (it as UriPartFilter).toUriPart() }.joinToString("") val order = filters.filterIsInstance<SortFilter>().joinToString("") { (it as UriPartFilter).toUriPart() }
return myGet("http://v2.api.dmzj.com/classify/$params/$order/${page - 1}.json") return myGet("http://v2.api.dmzj.com/classify/$params/$order/${page - 1}.json")
} }

View File

@ -111,7 +111,7 @@ class Gufengmh : ParsedHttpSource() {
// Filters // Filters
override fun getFilterList(): FilterList { override fun getFilterList(): FilterList {
val filterList = FilterList( return FilterList(
Filter.Header("如果使用文本搜索"), Filter.Header("如果使用文本搜索"),
Filter.Header("过滤器将被忽略"), Filter.Header("过滤器将被忽略"),
typefilter(), typefilter(),
@ -120,7 +120,6 @@ class Gufengmh : ParsedHttpSource() {
letterfilter(), letterfilter(),
statusfilter() statusfilter()
) )
return filterList
} }
private class typefilter : UriSelectFilterPath("按类型", "filtertype", arrayOf( private class typefilter : UriSelectFilterPath("按类型", "filtertype", arrayOf(

View File

@ -160,8 +160,8 @@ class HanhanKuman : ParsedHttpSource() {
val k = sk.substring(0, sk.length - 1) val k = sk.substring(0, sk.length - 1)
val f = sk.substring(sk.length - 1) val f = sk.substring(sk.length - 1)
for (i in 0 until k.length) { for (i in k.indices) {
s = s.replace(k.substring(i, i + 1), Integer.toString(i)) s = s.replace(k.substring(i, i + 1), i.toString())
} }
val ss = s.split(f.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() val ss = s.split(f.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
s = "" s = ""

View File

@ -41,17 +41,17 @@ class Manhuadui : ParsedHttpSource() {
override fun popularMangaRequest(page: Int) = GET("$baseUrl/list_$page/", headers) override fun popularMangaRequest(page: Int) = GET("$baseUrl/list_$page/", headers)
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/update/$page/", headers) override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/update/$page/", headers)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (query != "") { return if (query != "") {
val url = HttpUrl.parse("$baseUrl/search/?keywords=$query")?.newBuilder() val url = HttpUrl.parse("$baseUrl/search/?keywords=$query")?.newBuilder()
return GET(url.toString(), headers) GET(url.toString(), headers)
} else { } else {
var params = filters.map { val params = filters.map {
if (it is UriPartFilter) { if (it is UriPartFilter) {
it.toUriPart() it.toUriPart()
} else "" } else ""
}.filter { it != "" }.joinToString("-") }.filter { it != "" }.joinToString("-")
val url = HttpUrl.parse("$baseUrl/list/$params/$page/")?.newBuilder() val url = HttpUrl.parse("$baseUrl/list/$params/$page/")?.newBuilder()
return GET(url.toString(), headers) GET(url.toString(), headers)
} }
} }

View File

@ -40,7 +40,7 @@ class Manhuaren : HttpSource() {
url.queryParameterNames().toSortedSet().forEach { url.queryParameterNames().toSortedSet().forEach {
if (it != "gsn") { if (it != "gsn") {
s += it s += it
s += urlEncode(url.queryParameterValues(it).get(0)) s += urlEncode(url.queryParameterValues(it)[0])
} }
} }
s += c s += c
@ -49,7 +49,7 @@ class Manhuaren : HttpSource() {
private fun myGet(url: HttpUrl): Request { private fun myGet(url: HttpUrl): Request {
val now = DateFormat.format("yyyy-MM-dd+HH:mm:ss", Date()).toString() val now = DateFormat.format("yyyy-MM-dd+HH:mm:ss", Date()).toString()
val real_url = url.newBuilder() val realUrl = url.newBuilder()
.setQueryParameter("gsm", "md5") .setQueryParameter("gsm", "md5")
.setQueryParameter("gft", "json") .setQueryParameter("gft", "json")
.setQueryParameter("gts", now) .setQueryParameter("gts", now)
@ -59,7 +59,7 @@ class Manhuaren : HttpSource() {
.setQueryParameter("gui", "191909801") .setQueryParameter("gui", "191909801")
.setQueryParameter("gut", "0") .setQueryParameter("gut", "0")
return Request.Builder() return Request.Builder()
.url(real_url.setQueryParameter("gsn", generateGSNHash(real_url.build())).build()) .url(realUrl.setQueryParameter("gsn", generateGSNHash(realUrl.build())).build())
.headers(headers) .headers(headers)
.cacheControl(cacheControl) .cacheControl(cacheControl)
.build() .build()
@ -73,7 +73,7 @@ class Manhuaren : HttpSource() {
} }
private fun hashString(type: String, input: String): String { private fun hashString(type: String, input: String): String {
val HEX_CHARS = "0123456789abcdef" val hexChars = "0123456789abcdef"
val bytes = MessageDigest val bytes = MessageDigest
.getInstance(type) .getInstance(type)
.digest(input.toByteArray()) .digest(input.toByteArray())
@ -81,8 +81,8 @@ class Manhuaren : HttpSource() {
bytes.forEach { bytes.forEach {
val i = it.toInt() val i = it.toInt()
result.append(HEX_CHARS[i shr 4 and 0x0f]) result.append(hexChars[i shr 4 and 0x0f])
result.append(HEX_CHARS[i and 0x0f]) result.append(hexChars[i and 0x0f])
} }
return result.toString() return result.toString()

View File

@ -33,7 +33,7 @@ fun bodyWithAutoCharset(response: Response, _charset: String? = null): String {
var c = _charset var c = _charset
if (c == null) { if (c == null) {
var regexPat = Regex("""charset=(\w+)""") val regexPat = Regex("""charset=(\w+)""")
val match = regexPat.find(String(htmlBytes)) val match = regexPat.find(String(htmlBytes))
c = match?.groups?.get(1)?.value c = match?.groups?.get(1)?.value
} }
@ -151,7 +151,7 @@ class Pufei : ParsedHttpSource() {
val imgbase64 = re.find(html)?.groups?.get(1)?.value val imgbase64 = re.find(html)?.groups?.get(1)?.value
val imgCode = String(Base64.decode(imgbase64, Base64.DEFAULT)) val imgCode = String(Base64.decode(imgbase64, Base64.DEFAULT))
val imgArrStr = Duktape.create().use { val imgArrStr = Duktape.create().use {
it.evaluate(imgCode + """.join('|')""") as String it.evaluate("$imgCode.join('|')") as String
} }
return imgArrStr.split('|').mapIndexed { i, imgStr -> return imgArrStr.split('|').mapIndexed { i, imgStr ->
Page(i, "", imageServer + imgStr) Page(i, "", imageServer + imgStr)

View File

@ -90,8 +90,8 @@ class Qimiaomh : ParsedHttpSource() {
override fun pageListParse(document: Document): List<Page> = mutableListOf<Page>().apply { override fun pageListParse(document: Document): List<Page> = mutableListOf<Page>().apply {
val script = document.select("script:containsData(var did =)").html() val script = document.select("script:containsData(var did =)").html()
var did = script.substringAfter("var did = ").substringBefore(";") val did = script.substringAfter("var did = ").substringBefore(";")
var sid = script.substringAfter("var sid = ").substringBefore(";") val sid = script.substringAfter("var sid = ").substringBefore(";")
val url = "$baseUrl/Action/Play/AjaxLoadImgUrl?did=$did&sid=$sid&tmp=${Random().nextFloat()}" val url = "$baseUrl/Action/Play/AjaxLoadImgUrl?did=$did&sid=$sid&tmp=${Random().nextFloat()}"
val body = client.newCall(GET(url, headers)).execute().body()!!.string() val body = client.newCall(GET(url, headers)).execute().body()!!.string()
val json = JsonParser().parse(body).asJsonObject val json = JsonParser().parse(body).asJsonObject

View File

@ -53,7 +53,7 @@ class wnacg : ParsedHttpSource() {
} }
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
var document = response.asJsoup() val document = response.asJsoup()
val chapters = mutableListOf<SChapter>() val chapters = mutableListOf<SChapter>()
// create one chapter since it is single books // create one chapter since it is single books
chapters.add(createChapter("1", document.baseUri())) chapters.add(createChapter("1", document.baseUri()))
@ -84,7 +84,7 @@ class wnacg : ParsedHttpSource() {
val galleryaid = client.newCall(GET(baseUrl + slideaid.select("script[src$=html]").attr("src"), headers)).execute().asJsoup().toString() val galleryaid = client.newCall(GET(baseUrl + slideaid.select("script[src$=html]").attr("src"), headers)).execute().asJsoup().toString()
val matchresult = regex.findAll(galleryaid).map { it.value }.toList() val matchresult = regex.findAll(galleryaid).map { it.value }.toList()
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
for (i in 0 until matchresult.size) { for (i in matchresult.indices) {
pages.add(Page(i, "", "https:" + matchresult[i])) pages.add(Page(i, "", "https:" + matchresult[i]))
} }
return pages return pages