Cleanup EhEngine
This commit is contained in:
1 parent
cec0578b77
commit
8eec363581
2 files changed
+3
-10
No files matched your search
@@ -218,16 +218,7 @@ object EhEngine {
|
||||
return ehRequest(EhUrl.apiUrl, referer, EhUrl.origin) {
|
||||
jsonBody {
|
||||
put("method", "gdata")
|
||||
array("gidlist") {
|
||||
galleryInfoList.forEach {
|
||||
put(
|
||||
array {
|
||||
put(it.gid)
|
||||
put(it.token)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
array("gidlist") { galleryInfoList.forEach { put(jsonArrayOf(it.gid, it.token)) } }
|
||||
put("namespace", 1)
|
||||
}
|
||||
}.executeAndParsingWith { GalleryApiParser.parse(this, galleryInfoList) }
|
||||
|
||||
@@ -43,6 +43,8 @@ inline fun JSONObject.array(name: String, builder: JSONArray.() -> Unit): JSONOb
|
||||
|
||||
inline fun JSONArray.array(builder: JSONArray.() -> Unit): JSONArray = put(JSONArray().apply(builder))
|
||||
|
||||
fun jsonArrayOf(vararg element: Any?) = JSONArray().apply { element.forEach { put(it) } } // Should ensure it is inlined
|
||||
|
||||
inline fun Request.Builder.jsonBody(builder: JSONObject.() -> Unit) = post(JSONObject().apply(builder).toString().toRequestBody(MEDIA_TYPE_JSON))
|
||||
|
||||
fun HttpMessageBuilder.referer(value: String?): Unit = value?.let { headers.append("Referer", it) } ?: Unit
|
||||
|
||||
Reference in new issue
Block a user