Replace usages of Gson (#10079)
This commit is contained in:
parent
2cf0e7779f
commit
1f6027dd67
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Mango'
|
||||
|
|
|
@ -4,11 +4,6 @@ import android.app.Application
|
|||
import android.content.SharedPreferences
|
||||
import android.text.InputType
|
||||
import android.widget.Toast
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSyntaxException
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
|
@ -22,6 +17,13 @@ import eu.kanade.tachiyomi.source.model.SManga
|
|||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import info.debatty.java.stringsimilarity.JaroWinkler
|
||||
import info.debatty.java.stringsimilarity.Levenshtein
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import kotlinx.serialization.json.long
|
||||
import okhttp3.Dns
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
|
@ -33,6 +35,7 @@ import okhttp3.Response
|
|||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.IOException
|
||||
|
||||
class Mango : ConfigurableSource, HttpSource() {
|
||||
|
@ -43,18 +46,18 @@ class Mango : ConfigurableSource, HttpSource() {
|
|||
// Our popular manga are just our library of manga
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val result = try {
|
||||
gson.fromJson<JsonObject>(response.body!!.string())
|
||||
} catch (e: JsonSyntaxException) {
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
} catch (e: Exception) {
|
||||
apiCookies = ""
|
||||
throw Exception("Login Likely Failed. Try Refreshing.")
|
||||
}
|
||||
val mangas = result["titles"].asJsonArray
|
||||
val mangas = result["titles"]!!.jsonArray
|
||||
return MangasPage(
|
||||
mangas.asJsonArray.map {
|
||||
mangas.jsonArray.map {
|
||||
SManga.create().apply {
|
||||
url = "/book/" + it["id"].asString
|
||||
title = it["display_name"].asString
|
||||
thumbnail_url = baseUrl + it["cover_url"].asString
|
||||
url = "/book/" + it.jsonObject["id"]!!.jsonPrimitive.content
|
||||
title = it.jsonObject["display_name"]!!.jsonPrimitive.content
|
||||
thumbnail_url = baseUrl + it.jsonObject["cover_url"]!!.jsonPrimitive.content
|
||||
}
|
||||
},
|
||||
false
|
||||
|
@ -119,15 +122,15 @@ class Mango : ConfigurableSource, HttpSource() {
|
|||
// This will just return the same thing as the main library endpoint
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
val result = try {
|
||||
gson.fromJson<JsonObject>(response.body!!.string())
|
||||
} catch (e: JsonSyntaxException) {
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
} catch (e: Exception) {
|
||||
apiCookies = ""
|
||||
throw Exception("Login Likely Failed. Try Refreshing.")
|
||||
}
|
||||
return SManga.create().apply {
|
||||
url = "/book/" + result["id"].asString
|
||||
title = result["display_name"].asString
|
||||
thumbnail_url = baseUrl + result["cover_url"].asString
|
||||
url = "/book/" + result.jsonObject["id"]!!.jsonPrimitive.content
|
||||
title = result.jsonObject["display_name"]!!.jsonPrimitive.content
|
||||
thumbnail_url = baseUrl + result.jsonObject["cover_url"]!!.jsonPrimitive.content
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,8 +140,8 @@ class Mango : ConfigurableSource, HttpSource() {
|
|||
// The chapter url will contain how many pages the chapter contains for our page list endpoint
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val result = try {
|
||||
gson.fromJson<JsonObject>(response.body!!.string())
|
||||
} catch (e: JsonSyntaxException) {
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
} catch (e: Exception) {
|
||||
apiCookies = ""
|
||||
throw Exception("Login Likely Failed. Try Refreshing.")
|
||||
}
|
||||
|
@ -148,17 +151,17 @@ class Mango : ConfigurableSource, HttpSource() {
|
|||
// Helper function for listing chapters and chapters in nested titles recursively
|
||||
private fun listChapters(titleObj: JsonObject): List<SChapter> {
|
||||
val chapters = mutableListOf<SChapter>()
|
||||
val topChapters = titleObj.getAsJsonArray("entries")?.map { obj ->
|
||||
val topChapters = titleObj["entries"]?.jsonArray?.map { obj ->
|
||||
SChapter.create().apply {
|
||||
name = obj["display_name"].asString
|
||||
name = obj.jsonObject["display_name"]!!.jsonPrimitive.content
|
||||
url =
|
||||
"/page/${obj["title_id"].asString}/${obj["id"].asString}/${obj["pages"].asString}/"
|
||||
date_upload = 1000L * obj["mtime"].asLong
|
||||
"/page/${obj.jsonObject["title_id"]!!.jsonPrimitive.content}/${obj.jsonObject["id"]!!.jsonPrimitive.content}/${obj.jsonObject["pages"]!!.jsonPrimitive.content}/"
|
||||
date_upload = 1000L * obj.jsonObject["mtime"]!!.jsonPrimitive.long
|
||||
}
|
||||
}
|
||||
val subChapters = titleObj.getAsJsonArray("titles")?.map { obj ->
|
||||
val name = obj["display_name"].asString
|
||||
listChapters(obj.asJsonObject).map { chp ->
|
||||
val subChapters = titleObj["titles"]?.jsonArray?.map { obj ->
|
||||
val name = obj.jsonObject["display_name"]!!.jsonPrimitive.content
|
||||
listChapters(obj.jsonObject).map { chp ->
|
||||
chp.name = "$name / ${chp.name}"
|
||||
chp
|
||||
}
|
||||
|
@ -200,11 +203,11 @@ class Mango : ConfigurableSource, HttpSource() {
|
|||
override val lang = "en"
|
||||
override val supportsLatest = false
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||
private val port by lazy { getPrefPort() }
|
||||
private val username by lazy { getPrefUsername() }
|
||||
private val password by lazy { getPrefPassword() }
|
||||
private val gson by lazy { Gson() }
|
||||
private var apiCookies: String = ""
|
||||
|
||||
override fun headersBuilder(): Headers.Builder =
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Fansubs.cat'
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.ca.fansubscat
|
||||
|
||||
import com.github.salomonbrys.kotson.float
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.github.salomonbrys.kotson.long
|
||||
import com.github.salomonbrys.kotson.nullString
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
|
@ -17,12 +9,22 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.contentOrNull
|
||||
import kotlinx.serialization.json.float
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import kotlinx.serialization.json.long
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class FansubsCat : HttpSource() {
|
||||
|
||||
|
@ -39,22 +41,22 @@ class FansubsCat : HttpSource() {
|
|||
|
||||
override val client: OkHttpClient = network.client
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val apiBaseUrl = "https://api.fansubs.cat"
|
||||
|
||||
private fun parseMangaFromJson(response: Response): MangasPage {
|
||||
val jsonObject = gson.fromJson<JsonObject>(response.body!!.string())
|
||||
val jsonObject = json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
|
||||
val mangas = jsonObject["result"].asJsonArray.map { json ->
|
||||
val mangas = jsonObject["result"]!!.jsonArray.map { json ->
|
||||
SManga.create().apply {
|
||||
url = json["slug"].string
|
||||
title = json["name"].string
|
||||
thumbnail_url = json["thumbnail_url"].string
|
||||
author = json["author"].nullString
|
||||
description = json["synopsis"].nullString
|
||||
status = json["status"].string.toStatus()
|
||||
genre = json["genres"].nullString
|
||||
url = json.jsonObject["slug"]!!.jsonPrimitive.content
|
||||
title = json.jsonObject["name"]!!.jsonPrimitive.content
|
||||
thumbnail_url = json.jsonObject["thumbnail_url"]!!.jsonPrimitive.content
|
||||
author = json.jsonObject["author"]!!.jsonPrimitive.contentOrNull
|
||||
description = json.jsonObject["synopsis"]!!.jsonPrimitive.contentOrNull
|
||||
status = json.jsonObject["status"]!!.jsonPrimitive.content.toStatus()
|
||||
genre = json.jsonObject["genres"]!!.jsonPrimitive.contentOrNull
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,24 +64,24 @@ class FansubsCat : HttpSource() {
|
|||
}
|
||||
|
||||
private fun parseChapterListFromJson(response: Response): List<SChapter> {
|
||||
val jsonObject = gson.fromJson<JsonObject>(response.body!!.string())
|
||||
val jsonObject = json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
|
||||
return jsonObject["result"].asJsonArray.map { json ->
|
||||
return jsonObject["result"]!!.jsonArray.map { json ->
|
||||
SChapter.create().apply {
|
||||
url = json["id"].string
|
||||
name = json["title"].string
|
||||
chapter_number = json["number"].float
|
||||
scanlator = json["fansub"].string
|
||||
date_upload = json["created"].long
|
||||
url = json.jsonObject["id"]!!.jsonPrimitive.content
|
||||
name = json.jsonObject["title"]!!.jsonPrimitive.content
|
||||
chapter_number = json.jsonObject["number"]!!.jsonPrimitive.float
|
||||
scanlator = json.jsonObject["fansub"]!!.jsonPrimitive.content
|
||||
date_upload = json.jsonObject["created"]!!.jsonPrimitive.long
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun parsePageListFromJson(response: Response): List<Page> {
|
||||
val jsonObject = gson.fromJson<JsonObject>(response.body!!.string())
|
||||
val jsonObject = json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
|
||||
return jsonObject["result"].asJsonArray.mapIndexed { i, it ->
|
||||
Page(i, it["url"].asString, it["url"].asString)
|
||||
return jsonObject["result"]!!.jsonArray.mapIndexed { i, it ->
|
||||
Page(i, it.jsonObject["url"]!!.jsonPrimitive.content, it.jsonObject["url"]!!.jsonPrimitive.content)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,16 +126,17 @@ class FansubsCat : HttpSource() {
|
|||
}
|
||||
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
val jsonObject = gson.fromJson<JsonObject>(response.body!!.string())
|
||||
val jsonObject = json.decodeFromString<JsonObject>(response.body!!.string())
|
||||
val resultObject = jsonObject.jsonObject["result"]!!.jsonObject
|
||||
|
||||
return SManga.create().apply {
|
||||
url = jsonObject["result"]["slug"].string
|
||||
title = jsonObject["result"]["name"].string
|
||||
thumbnail_url = jsonObject["result"]["thumbnail_url"].string
|
||||
author = jsonObject["result"]["author"].nullString
|
||||
description = jsonObject["result"]["synopsis"].nullString
|
||||
status = jsonObject["result"]["status"].string.toStatus()
|
||||
genre = jsonObject["result"]["genres"].nullString
|
||||
url = resultObject["slug"]!!.jsonPrimitive.content
|
||||
title = resultObject["name"]!!.jsonPrimitive.content
|
||||
thumbnail_url = resultObject["thumbnail_url"]!!.jsonPrimitive.content
|
||||
author = resultObject["author"]!!.jsonPrimitive.contentOrNull
|
||||
description = resultObject["synopsis"]!!.jsonPrimitive.contentOrNull
|
||||
status = resultObject["status"]!!.jsonPrimitive.content.toStatus()
|
||||
genre = resultObject["genres"]!!.jsonPrimitive.contentOrNull
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Doujins'
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.en.doujins
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
|
@ -15,11 +9,16 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
|
@ -37,16 +36,12 @@ class Doujins : HttpSource() {
|
|||
|
||||
override val supportsLatest: Boolean = true
|
||||
|
||||
private val gson = Gson()
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
return listOf(
|
||||
SChapter.create().apply {
|
||||
var element = response.asJsoup()
|
||||
val element = response.asJsoup()
|
||||
name = "Chapter"
|
||||
scanlator = element.select("div.folder-message:contains(Translated)").text().substringAfter("by:").trim()
|
||||
setUrlWithoutDomain(response.request.url.toString())
|
||||
|
@ -68,14 +63,14 @@ class Doujins : HttpSource() {
|
|||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
return MangasPage(
|
||||
gson.fromJson<JsonObject>(response.body!!.string())["folders"].asJsonArray.map {
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())["folders"]!!.jsonArray.map {
|
||||
SManga.create().apply {
|
||||
setUrlWithoutDomain(it["link"].asString)
|
||||
title = it["name"].asString
|
||||
artist = it["artistList"].asString
|
||||
setUrlWithoutDomain(it.jsonObject["link"]!!.jsonPrimitive.content)
|
||||
title = it.jsonObject["name"]!!.jsonPrimitive.content
|
||||
artist = it.jsonObject["artistList"]!!.jsonPrimitive.content
|
||||
author = artist
|
||||
genre = it["tags"].asJsonArray.joinToString(", ") { it["tag"].asString }
|
||||
thumbnail_url = it["thumbnail2"].asString
|
||||
genre = it.jsonObject["tags"]!!.jsonArray.joinToString(", ") { it.jsonObject["tag"]!!.jsonPrimitive.content }
|
||||
thumbnail_url = it.jsonObject["thumbnail2"]!!.jsonPrimitive.content
|
||||
}
|
||||
},
|
||||
true
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Madokami'
|
||||
|
|
|
@ -3,9 +3,6 @@ package eu.kanade.tachiyomi.extension.en.madokami
|
|||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.text.InputType
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
|
@ -13,6 +10,10 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
@ -23,6 +24,7 @@ import org.jsoup.nodes.Document
|
|||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.IOException
|
||||
import java.net.URLDecoder
|
||||
import java.net.URLEncoder
|
||||
|
@ -36,7 +38,7 @@ class Madokami : ConfigurableSource, ParsedHttpSource() {
|
|||
override val lang = "en"
|
||||
override val supportsLatest = false
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH)
|
||||
|
||||
|
@ -154,7 +156,7 @@ class Madokami : ConfigurableSource, ParsedHttpSource() {
|
|||
override fun pageListParse(document: Document): List<Page> {
|
||||
val element = document.select("div#reader")
|
||||
val path = element.attr("data-path")
|
||||
val files = gson.fromJson<JsonArray>(element.attr("data-files"))
|
||||
val files = json.decodeFromString<JsonArray>(element.attr("data-files"))
|
||||
val pages = mutableListOf<Page>()
|
||||
for ((index, file) in files.withIndex()) {
|
||||
val url = HttpUrl.Builder()
|
||||
|
@ -162,7 +164,7 @@ class Madokami : ConfigurableSource, ParsedHttpSource() {
|
|||
.host("manga.madokami.al")
|
||||
.addPathSegments("reader/image")
|
||||
.addEncodedQueryParameter("path", URLEncoder.encode(path, "UTF-8"))
|
||||
.addEncodedQueryParameter("file", URLEncoder.encode(file.asString, "UTF-8"))
|
||||
.addEncodedQueryParameter("file", URLEncoder.encode(file.jsonPrimitive.content, "UTF-8"))
|
||||
.build()
|
||||
.toUrl()
|
||||
pages.add(Page(index, url.toExternalForm(), url.toExternalForm()))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Manga Linkz'
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package eu.kanade.tachiyomi.extension.en.mangalinkz
|
||||
|
||||
import android.util.Base64
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
@ -137,14 +139,14 @@ class MangaLinkz : ParsedHttpSource() {
|
|||
|
||||
// Pages
|
||||
|
||||
private val gson by lazy { Gson() }
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val encoded = document.select("script:containsData(atob)").first().data()
|
||||
.substringAfter("atob(\"").substringBefore("\"")
|
||||
val decoded = Base64.decode(encoded, Base64.DEFAULT).toString(Charsets.UTF_8).removeSurrounding("[", "]")
|
||||
|
||||
return gson.fromJson<JsonObject>(decoded)["pages"].asJsonArray.mapIndexed { i, jsonElement -> Page(i, "", jsonElement.string) }
|
||||
return json.decodeFromString<JsonObject>(decoded)["pages"]!!.jsonArray.mapIndexed { i, jsonElement -> Page(i, "", jsonElement.jsonPrimitive.content) }
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Multporn'
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.en.multporn
|
||||
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservable
|
||||
|
@ -16,6 +12,11 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
@ -27,6 +28,7 @@ import org.jsoup.nodes.Document
|
|||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
class Multporn : ParsedHttpSource() {
|
||||
|
@ -36,7 +38,7 @@ class Multporn : ParsedHttpSource() {
|
|||
override val baseUrl = "https://multporn.net"
|
||||
override val supportsLatest = true
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||
.add("User-Agent", HEADER_USER_AGENT)
|
||||
|
@ -65,8 +67,8 @@ class Multporn : ParsedHttpSource() {
|
|||
override fun popularMangaRequest(page: Int) = buildPopularMangaRequest(page - 1)
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val html = gson.fromJson<JsonArray>(response.body!!.string())
|
||||
.last { it["command"].asString == "insert" }.asJsonObject["data"].asString
|
||||
val html = json.decodeFromString<JsonArray>(response.body!!.string())
|
||||
.last { it.jsonObject["command"]!!.jsonPrimitive.content == "insert" }.jsonObject["data"]!!.jsonPrimitive.content
|
||||
|
||||
return super.popularMangaParse(
|
||||
response.newBuilder()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Henchan'
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
package eu.kanade.tachiyomi.extension.ru.henchan
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.github.salomonbrys.kotson.array
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservable
|
||||
|
@ -17,6 +11,12 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
|
@ -24,6 +24,7 @@ import okhttp3.Response
|
|||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.net.URL
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
@ -254,17 +255,17 @@ class Henchan : ParsedHttpSource() {
|
|||
|
||||
override fun imageUrlParse(document: Document) = throw Exception("Not Used")
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private fun Document.parseJsonArray(): JsonArray {
|
||||
val imgScript = this.select("script:containsData(fullimg)").first().toString()
|
||||
val imgString = imgScript.substring(imgScript.indexOf('{'), imgScript.lastIndexOf('}') + 1).replace(""", "\"")
|
||||
return gson.fromJson<JsonObject>(imgString)["fullimg"].array
|
||||
return json.decodeFromString<JsonObject>(imgString)["fullimg"]!!.jsonArray
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
return document.parseJsonArray().mapIndexed { index, imageUrl ->
|
||||
Page(index, imageUrl = imageUrl.string.replace(".gif.webp", ".gif"))
|
||||
Page(index, imageUrl = imageUrl.jsonPrimitive.content.replace(".gif.webp", ".gif"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Nekopost'
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost
|
||||
|
||||
import com.google.gson.Gson
|
||||
import eu.kanade.tachiyomi.extension.th.nekopost.model.RawChapterInfo
|
||||
import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectInfo
|
||||
import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectNameList
|
||||
import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectNameListItem
|
||||
import eu.kanade.tachiyomi.extension.th.nekopost.model.RawProjectSummaryList
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
|
@ -13,6 +12,8 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
|
@ -20,11 +21,12 @@ import okhttp3.Response
|
|||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class Nekopost : ParsedHttpSource() {
|
||||
private val gson: Gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
override val baseUrl: String = "https://www.nekopost.net/project"
|
||||
|
||||
private val latestMangaEndpoint: String =
|
||||
|
@ -81,10 +83,10 @@ class Nekopost : ParsedHttpSource() {
|
|||
.map { response ->
|
||||
val responseBody =
|
||||
response.body ?: throw Error("Unable to fetch manga detail of ${manga.title}")
|
||||
val projectInfo = gson.fromJson(responseBody.string(), RawProjectInfo::class.java)
|
||||
val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string())
|
||||
|
||||
manga.apply {
|
||||
projectInfo.projectData.let {
|
||||
projectInfo.projectInfo.let {
|
||||
url = it.npProjectId
|
||||
title = it.npName
|
||||
artist = it.artistName
|
||||
|
@ -95,7 +97,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
}
|
||||
|
||||
genre =
|
||||
projectInfo.projectCategoryUsed.map { it.npcName }.joinToString(", ")
|
||||
projectInfo.projectCategoryUsed.joinToString(", ") { it.npcName }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +110,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
val responseBody =
|
||||
response.body
|
||||
?: throw Error("Unable to fetch manga detail of ${manga.title}")
|
||||
val projectInfo =
|
||||
gson.fromJson(responseBody.string(), RawProjectInfo::class.java)
|
||||
val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string())
|
||||
|
||||
projectInfo.projectChapterList.map { chapter ->
|
||||
SChapter.create().apply {
|
||||
|
@ -137,8 +138,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
val responseBody =
|
||||
response.body
|
||||
?: throw Error("Unable to fetch page list of chapter ${chapter.chapter_number}")
|
||||
val chapterInfo =
|
||||
gson.fromJson(responseBody.string(), RawChapterInfo::class.java)
|
||||
val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string())
|
||||
|
||||
chapterInfo.pageItem.map { page ->
|
||||
Page(
|
||||
|
@ -159,7 +159,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
val responseBody = response.body ?: throw Error("Unable to fetch mangas")
|
||||
val projectList = gson.fromJson(responseBody.string(), RawProjectSummaryList::class.java)
|
||||
val projectList: RawProjectSummaryList = json.decodeFromString(responseBody.string())
|
||||
|
||||
val mangaList: List<SManga> =
|
||||
projectList.listItem
|
||||
|
@ -200,8 +200,7 @@ class Nekopost : ParsedHttpSource() {
|
|||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
val responseBody = response.body ?: throw Error("Unable to fetch title list")
|
||||
val projectList =
|
||||
gson.fromJson(responseBody.string(), RawProjectNameList::class.java)
|
||||
val projectList: List<RawProjectNameListItem> = json.decodeFromString(responseBody.string())
|
||||
|
||||
val mangaList: List<SManga> = projectList.filter { project ->
|
||||
Regex(
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawChapterInfo(
|
||||
@SerializedName("chapterId")
|
||||
val chapterId: Int,
|
||||
@SerializedName("chapterNo")
|
||||
val chapterNo: String,
|
||||
@SerializedName("pageCount")
|
||||
val pageCount: Int,
|
||||
@SerializedName("pageItem")
|
||||
val pageItem: List<RawPageItem>,
|
||||
@SerializedName("projectId")
|
||||
val projectId: String
|
||||
)
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawPageItem(
|
||||
@SerializedName("fileName")
|
||||
val fileName: String,
|
||||
@SerializedName("height")
|
||||
val height: Int,
|
||||
@SerializedName("pageNo")
|
||||
val pageNo: Int,
|
||||
@SerializedName("width")
|
||||
val width: Int
|
||||
)
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectCategory(
|
||||
@SerializedName("npc_name")
|
||||
@SerialName("npc_name")
|
||||
val npcName: String,
|
||||
@SerializedName("npc_name_link")
|
||||
@SerialName("npc_name_link")
|
||||
val npcNameLink: String
|
||||
)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectChapter(
|
||||
@SerializedName("cu_displayname")
|
||||
val cuDisplayname: String,
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectInfo(
|
||||
@SerializedName("code")
|
||||
val code: String,
|
||||
@SerializedName("projectCategoryUsed")
|
||||
val projectCategoryUsed: List<RawProjectCategory>,
|
||||
@SerializedName("projectChapterList")
|
||||
val projectChapterList: List<RawProjectChapter>,
|
||||
@SerializedName("projectInfo")
|
||||
val projectData: RawProjectInfoData
|
||||
val projectInfo: RawProjectInfoData
|
||||
)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectInfoData(
|
||||
@SerializedName("artist_name")
|
||||
val artistName: String,
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
class RawProjectNameList : ArrayList<RawProjectNameListItem>()
|
|
@ -1,18 +1,20 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectNameListItem(
|
||||
@SerializedName("np_name")
|
||||
@SerialName("np_name")
|
||||
val npName: String,
|
||||
@SerializedName("np_name_link")
|
||||
@SerialName("np_name_link")
|
||||
val npNameLink: String,
|
||||
@SerializedName("np_no_chapter")
|
||||
@SerialName("np_no_chapter")
|
||||
val npNoChapter: String,
|
||||
@SerializedName("np_project_id")
|
||||
@SerialName("np_project_id")
|
||||
val npProjectId: String,
|
||||
@SerializedName("np_status")
|
||||
@SerialName("np_status")
|
||||
val npStatus: String,
|
||||
@SerializedName("np_type")
|
||||
@SerialName("np_type")
|
||||
val npType: String
|
||||
)
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectSummary(
|
||||
@SerializedName("nc_chapter_cover")
|
||||
@SerialName("nc_chapter_cover")
|
||||
val ncChapterCover: String,
|
||||
@SerializedName("nc_chapter_id")
|
||||
@SerialName("nc_chapter_id")
|
||||
val ncChapterId: String,
|
||||
@SerializedName("nc_chapter_name")
|
||||
@SerialName("nc_chapter_name")
|
||||
val ncChapterName: String,
|
||||
@SerializedName("nc_chapter_no")
|
||||
@SerialName("nc_chapter_no")
|
||||
val ncChapterNo: String,
|
||||
@SerializedName("nc_created_date")
|
||||
@SerialName("nc_created_date")
|
||||
val ncCreatedDate: String,
|
||||
@SerializedName("nc_provider")
|
||||
@SerialName("nc_provider")
|
||||
val ncProvider: String,
|
||||
@SerializedName("no_new_chapter")
|
||||
@SerialName("no_new_chapter")
|
||||
val noNewChapter: String,
|
||||
@SerializedName("np_group_dir")
|
||||
@SerialName("np_group_dir")
|
||||
val npGroupDir: String,
|
||||
@SerializedName("np_name")
|
||||
@SerialName("np_name")
|
||||
val npName: String,
|
||||
@SerializedName("np_name_link")
|
||||
@SerialName("np_name_link")
|
||||
val npNameLink: String,
|
||||
@SerializedName("np_project_id")
|
||||
@SerialName("np_project_id")
|
||||
val npProjectId: String
|
||||
)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class RawProjectSummaryList(
|
||||
@SerializedName("code")
|
||||
val code: String,
|
||||
@SerializedName("listItem")
|
||||
val listItem: List<RawProjectSummary>?
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Comico'
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.comico
|
||||
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
|
@ -12,12 +7,19 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -33,7 +35,7 @@ abstract class Comico(
|
|||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
val gson = Gson()
|
||||
val json: Json by injectLazy()
|
||||
|
||||
// Popular
|
||||
|
||||
|
@ -122,12 +124,12 @@ abstract class Comico(
|
|||
return POST("$baseUrl/api/getArticleList.nhn", chapterListHeaders, body)
|
||||
}
|
||||
|
||||
fun chapterFromJson(jsonElement: JsonElement): SChapter {
|
||||
fun chapterFromJson(jsonObject: JsonObject): SChapter {
|
||||
val chapter = SChapter.create()
|
||||
|
||||
chapter.name = jsonElement["subtitle"].asString
|
||||
chapter.setUrlWithoutDomain(jsonElement["articleDetailUrl"].asString)
|
||||
chapter.date_upload = parseDate(jsonElement["date"].asString)
|
||||
chapter.name = jsonObject["subtitle"]!!.jsonPrimitive.content
|
||||
chapter.setUrlWithoutDomain(jsonObject["articleDetailUrl"]!!.jsonPrimitive.content)
|
||||
chapter.date_upload = parseDate(jsonObject["date"]!!.jsonPrimitive.content)
|
||||
|
||||
return chapter
|
||||
}
|
||||
|
@ -135,9 +137,14 @@ abstract class Comico(
|
|||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val chapters = mutableListOf<SChapter>()
|
||||
|
||||
gson.fromJson<JsonObject>(response.body!!.string())["result"]["list"].asJsonArray.forEach {
|
||||
if (it["freeFlg"].asString == "Y") chapters.add(chapterFromJson(it))
|
||||
}
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())["result"]!!
|
||||
.jsonObject["list"]!!
|
||||
.jsonArray
|
||||
.forEach {
|
||||
if (it.jsonObject["freeFlg"]!!.jsonPrimitive.content == "Y") {
|
||||
chapters.add(chapterFromJson(it.jsonObject))
|
||||
}
|
||||
}
|
||||
|
||||
return chapters.reversed()
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.comico
|
||||
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.github.salomonbrys.kotson.get
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
|
@ -10,6 +7,11 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
|||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
|
@ -36,21 +38,24 @@ class ComicoChallenge : Comico("Comico Challenge", "/challenge", true) {
|
|||
val mangas = mutableListOf<SManga>()
|
||||
val body = response.body!!.string()
|
||||
|
||||
gson.fromJson<JsonObject>(body)["result"]["list"].asJsonArray.forEach {
|
||||
val manga = SManga.create()
|
||||
json.decodeFromString<JsonObject>(body)["result"]!!
|
||||
.jsonObject["list"]!!
|
||||
.jsonArray
|
||||
.forEach {
|
||||
val manga = SManga.create()
|
||||
|
||||
manga.thumbnail_url = it["img_url"].asString
|
||||
manga.title = it["article_title"].asString
|
||||
manga.author = it["author"].asString
|
||||
manga.description = it["description"].asString
|
||||
manga.url = it["article_url"].asString.substringAfter(urlModifier)
|
||||
manga.status = if (it["is_end"].asString == "false") SManga.ONGOING else SManga.COMPLETED
|
||||
manga.thumbnail_url = it.jsonObject["img_url"]!!.jsonPrimitive.content
|
||||
manga.title = it.jsonObject["article_title"]!!.jsonPrimitive.content
|
||||
manga.author = it.jsonObject["author"]!!.jsonPrimitive.content
|
||||
manga.description = it.jsonObject["description"]!!.jsonPrimitive.content
|
||||
manga.url = it.jsonObject["article_url"]!!.jsonPrimitive.content.substringAfter(urlModifier)
|
||||
manga.status = if (it.jsonObject["is_end"]!!.jsonPrimitive.content == "false") SManga.ONGOING else SManga.COMPLETED
|
||||
|
||||
mangas.add(manga)
|
||||
}
|
||||
mangas.add(manga)
|
||||
}
|
||||
|
||||
val lastPage = gson.fromJson<JsonObject>(body)["result"]["totalPageCnt"].asString
|
||||
val currentPage = gson.fromJson<JsonObject>(body)["result"]["currentPageNo"].asString
|
||||
val lastPage = json.decodeFromString<JsonObject>(body)["result"]!!.jsonObject["totalPageCnt"]!!.jsonPrimitive.content
|
||||
val currentPage = json.decodeFromString<JsonObject>(body)["result"]!!.jsonObject["currentPageNo"]!!.jsonPrimitive.content
|
||||
|
||||
return MangasPage(mangas, currentPage < lastPage)
|
||||
}
|
||||
|
@ -82,8 +87,12 @@ class ComicoChallenge : Comico("Comico Challenge", "/challenge", true) {
|
|||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val chapters = mutableListOf<SChapter>()
|
||||
|
||||
gson.fromJson<JsonObject>(response.body!!.string())["result"]["list"].asJsonArray
|
||||
.forEach { chapters.add(chapterFromJson(it)) }
|
||||
json.decodeFromString<JsonObject>(response.body!!.string())["result"]!!
|
||||
.jsonObject["list"]!!
|
||||
.jsonArray
|
||||
.forEach {
|
||||
chapters.add(chapterFromJson(it.jsonObject))
|
||||
}
|
||||
|
||||
return chapters.reversed()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'ManHuaGui'
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.manhuagui
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Comic(
|
||||
val bid: Int? = 0,
|
||||
val block_cc: String? = "",
|
||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.extension.zh.manhuagui
|
|||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import com.google.gson.Gson
|
||||
import com.squareup.duktape.Duktape
|
||||
import eu.kanade.tachiyomi.lib.ratelimit.SpecificHostRateLimitInterceptor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
|
@ -22,6 +21,8 @@ import kotlinx.coroutines.GlobalScope
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.Headers
|
||||
|
@ -37,6 +38,7 @@ import org.jsoup.nodes.Element
|
|||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.IOException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
@ -65,7 +67,7 @@ class Manhuagui : ConfigurableSource, ParsedHttpSource() {
|
|||
|
||||
private val imageServer = arrayOf("https://i.hamreus.com", "https://cf.hamreus.com")
|
||||
private val mobileWebsiteUrl = "https://m.$baseHost"
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
private val baseHttpUrl: HttpUrl = baseUrl.toHttpUrlOrNull()!!
|
||||
|
||||
// Add rate limit to fix manga thumbnail load failure
|
||||
|
@ -388,7 +390,7 @@ class Manhuagui : ConfigurableSource, ParsedHttpSource() {
|
|||
}
|
||||
|
||||
val imgJsonStr = re2.find(imgDecode)?.groups?.get(0)?.value
|
||||
val imageJson: Comic = gson.fromJson(imgJsonStr, Comic::class.java)
|
||||
val imageJson: Comic = json.decodeFromString(imgJsonStr!!)
|
||||
|
||||
return imageJson.files!!.mapIndexed { i, imgStr ->
|
||||
val imgurl = "${imageServer[0]}${imageJson.path}$imgStr?cid=${imageJson.cid}&md5=${imageJson.sl?.md5}"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.manhuagui
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Sl(
|
||||
val md5: String? = ""
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'Tohomh123'
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.tohomh123
|
||||
|
||||
import com.github.salomonbrys.kotson.fromJson
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
|
@ -10,11 +7,16 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -142,10 +144,10 @@ class Tohomh : ParsedHttpSource() {
|
|||
return pages
|
||||
}
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override fun imageUrlParse(response: Response): String {
|
||||
return gson.fromJson<JsonObject>(response.body!!.string())["Code"].asString
|
||||
return json.decodeFromString<JsonObject>(response.body!!.string())["Code"]!!.jsonPrimitive.content
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'WuqiManga'
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.wuqimanga
|
||||
|
||||
class Comic {
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class Comic {
|
||||
val fs: List<String?>? = listOf()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.kanade.tachiyomi.extension.zh.wuqimanga
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.squareup.duktape.Duktape
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
|
@ -9,11 +8,14 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
|||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class WuqiManga : ParsedHttpSource() {
|
||||
|
||||
|
@ -137,7 +139,7 @@ class WuqiManga : ParsedHttpSource() {
|
|||
return chapters
|
||||
}
|
||||
|
||||
private val gson = Gson()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val html = document.html()
|
||||
|
@ -147,7 +149,7 @@ class WuqiManga : ParsedHttpSource() {
|
|||
}
|
||||
val re2 = Regex("""\{.*\}""")
|
||||
val imgJsonStr = re2.find(result)?.groups?.get(0)?.value
|
||||
val imageJson: Comic = gson.fromJson(imgJsonStr, Comic::class.java)
|
||||
val imageJson: Comic = json.decodeFromString(imgJsonStr!!)
|
||||
|
||||
return imageJson.fs!!.mapIndexed { i, imgStr ->
|
||||
val imgurl = "$imageServer$imgStr"
|
||||
|
|
Loading…
Reference in New Issue