Add MangaDex login

This commit is contained in:
NerdNumber9
2019-04-19 02:46:34 -04:00
parent 5c2fbec80a
commit ea7ff432b2
14 changed files with 238 additions and 95 deletions

View File

@ -0,0 +1,31 @@
package exh.util
import com.elvishew.xlog.XLog
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Response
import okhttp3.ResponseBody
import org.jsoup.nodes.Document
fun Response.interceptAsHtml(block: (Document) -> Unit): Response {
val body = body()
if(body != null) {
if (body.contentType()?.type() == "text"
&& body.contentType()?.subtype() == "html") {
val bodyString = body.string()
val rebuiltResponse = newBuilder()
.body(ResponseBody.create(body.contentType(), bodyString))
.build()
try {
// Search for captcha
val parsed = asJsoup(html = bodyString)
block(parsed)
} catch (t: Throwable) {
// Ignore all errors
XLog.w("Interception error!", t)
}
return rebuiltResponse
}
}
return this
}