[Manhuaren] Add referers to headers and use query key (Fixes #653) (#678)

[Manhuaren] Add referers to headers and use query key (Fixes #653)
This commit is contained in:
Ken Swenson 2018-12-23 08:33:16 -05:00 committed by Carlos
parent 9d2fd277ee
commit bac1926e29
2 changed files with 11 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Manhuaren'
pkgNameSuffix = 'zh.manhuaren'
extClass = '.Manhuaren'
extVersionCode = 3
extVersionCode = 4
libVersion = '1.2'
}

View File

@ -4,6 +4,7 @@ import android.text.format.DateFormat
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.HttpSource
import okhttp3.Headers
import okhttp3.Request
import okhttp3.Response
import org.json.JSONArray
@ -28,7 +29,13 @@ class Manhuaren : HttpSource() {
return GET(url, headers)
}
override fun headersBuilder() = super.headersBuilder().add("X-Yq-Yqci", "{\"le\": \"zh\"}")
override fun headersBuilder() = Headers.Builder().apply {
add("X-Yq-Yqci", "{\"le\": \"zh\"}")
add("User-Agent", "okhttp/3.11.0")
add("Referer", "http://www.dm5.com/dm5api/")
add("clubReferer", "http://mangaapi.manhuaren.com/")
}
private fun hashString(type: String, input: String): String {
val HEX_CHARS = "0123456789abcdef"
@ -257,8 +264,9 @@ class Manhuaren : HttpSource() {
val ret = ArrayList<Page>()
val host = obj.getJSONArray("hostList").getString(0)
val arr = obj.getJSONArray("mangaSectionImages")
val query = obj.getString("query")
for (i in 0 until arr.length()) {
ret.add(Page(i, "$host${arr.getString(i)}", "$host${arr.getString(i)}"))
ret.add(Page(i, "$host${arr.getString(i)}$query", "$host${arr.getString(i)}$query"))
}
return ret
}