Remove JsonParser deprecation warning in some sources. (#6748)
This commit is contained in:
parent
f0c4083f24
commit
0c25f62d56
@ -283,7 +283,7 @@ abstract class MangasProject(
|
||||
protected open fun getReaderToken(document: Document): String? {
|
||||
return document.select("script[src*=\"reader.\"]").firstOrNull()
|
||||
?.attr("abs:src")
|
||||
?.let { it.toHttpUrlOrNull() }
|
||||
?.toHttpUrlOrNull()
|
||||
?.queryParameter("token")
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ abstract class MangasProject(
|
||||
throw Exception("HTTP error $code")
|
||||
}
|
||||
|
||||
return JSON_PARSER.parse(body!!.string()).obj
|
||||
return JsonParser.parseString(body!!.string()).obj
|
||||
}
|
||||
|
||||
private fun String.toDate(): Long {
|
||||
@ -323,8 +323,6 @@ abstract class MangasProject(
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) }
|
||||
|
||||
private const val MANGA_REMOVED = "Mangá licenciado e removido pela fonte."
|
||||
|
@ -180,7 +180,7 @@ class ShonenJumpPlus : ParsedHttpSource() {
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val episodeJson = document.select("script#episode-json")
|
||||
.attr("data-value")
|
||||
.let { JSON_PARSER.parse(it).obj }
|
||||
.let { JsonParser.parseString(it).obj }
|
||||
|
||||
return episodeJson["readableProduct"]["pageStructure"]["pages"].asJsonArray
|
||||
.filter { it["type"].string == "main" }
|
||||
@ -269,11 +269,10 @@ class ShonenJumpPlus : ParsedHttpSource() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body!!.string()).obj
|
||||
private fun Response.asJsonObject(): JsonObject = JsonParser.parseString(body!!.string()).obj
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36"
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
private val DATE_PARSER by lazy { SimpleDateFormat("yyyy/MM/dd", Locale.ENGLISH) }
|
||||
|
||||
private val LIST_MODES = listOf(
|
||||
|
@ -184,12 +184,10 @@ class Bruttal : HttpSource() {
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used")
|
||||
|
||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body!!.string())
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ class CentralDeMangas : ParsedHttpSource() {
|
||||
|
||||
private fun getCoverUrl(slug: String): String = "$COVER_CDN/150x200/$slug.jpg"
|
||||
|
||||
private fun Response.asJsonArray(): JsonArray = JSON_PARSER.parse(body!!.string()).array
|
||||
private fun Response.asJsonArray(): JsonArray = JsonParser.parseString(body!!.string()).array
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
@ -203,7 +203,5 @@ class CentralDeMangas : ParsedHttpSource() {
|
||||
private const val SCRIPT_URL_END = "';"
|
||||
private const val SCRIPT_PAGES_BEGIN = "var pages = ["
|
||||
private const val SCRIPT_PAGES_END = ",];"
|
||||
|
||||
val JSON_PARSER by lazy { JsonParser() }
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.github.salomonbrys.kotson.jsonObject
|
||||
import com.github.salomonbrys.kotson.obj
|
||||
import com.github.salomonbrys.kotson.string
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import eu.kanade.tachiyomi.annotations.Nsfw
|
||||
@ -57,7 +58,7 @@ class Hipercool : HttpSource() {
|
||||
.add("X-Requested-With", "XMLHttpRequest")
|
||||
|
||||
private fun genericMangaListParse(response: Response): MangasPage {
|
||||
val result = response.asJsonArray()
|
||||
val result = response.asJson().array
|
||||
|
||||
if (result.size() == 0)
|
||||
return MangasPage(emptyList(), false)
|
||||
@ -129,7 +130,7 @@ class Hipercool : HttpSource() {
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
val result = response.asJsonObject()
|
||||
val result = response.asJson().obj
|
||||
|
||||
val artists = result["tags"].array
|
||||
.filter { it["label"].string == "Artista" }
|
||||
@ -160,7 +161,7 @@ class Hipercool : HttpSource() {
|
||||
override fun chapterListRequest(manga: SManga): Request = mangaDetailsApiRequest(manga)
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val result = response.asJsonObject()
|
||||
val result = response.asJson().obj
|
||||
|
||||
if (!result["chapters"]!!.isJsonArray)
|
||||
return emptyList()
|
||||
@ -242,9 +243,7 @@ class Hipercool : HttpSource() {
|
||||
.addQueryParameter("revision", revision.toString())
|
||||
.toString()
|
||||
|
||||
private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body!!.string()).obj
|
||||
|
||||
private fun Response.asJsonArray(): JsonArray = JSON_PARSER.parse(body!!.string()).array
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val STATIC_URL = "https://static.hiper.cool"
|
||||
@ -254,8 +253,6 @@ class Hipercool : HttpSource() {
|
||||
|
||||
private const val DEFAULT_COUNT = 40
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) }
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.Response
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@ -52,7 +53,7 @@ class HQNow : HttpSource() {
|
||||
// Popular
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
return POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getHqsByFilters\",\"variables\":{\"orderByViews\":true,\"loadCovers\":true,\"limit\":30},\"query\":\"query getHqsByFilters(\$orderByViews: Boolean, \$limit: Int, \$publisherId: Int, \$loadCovers: Boolean) {\\n getHqsByFilters(orderByViews: \$orderByViews, limit: \$limit, publisherId: \$publisherId, loadCovers: \$loadCovers) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n hqCover\\n synopsis\\n updatedAt\\n }\\n}\\n\"}"))
|
||||
return POST(baseUrl, jsonHeaders, "{\"operationName\":\"getHqsByFilters\",\"variables\":{\"orderByViews\":true,\"loadCovers\":true,\"limit\":30},\"query\":\"query getHqsByFilters(\$orderByViews: Boolean, \$limit: Int, \$publisherId: Int, \$loadCovers: Boolean) {\\n getHqsByFilters(orderByViews: \$orderByViews, limit: \$limit, publisherId: \$publisherId, loadCovers: \$loadCovers) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n hqCover\\n synopsis\\n updatedAt\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
}
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
@ -62,7 +63,7 @@ class HQNow : HttpSource() {
|
||||
// Latest
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
return POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getRecentlyUpdatedHqs\",\"variables\":{},\"query\":\"query getRecentlyUpdatedHqs {\\n getRecentlyUpdatedHqs {\\n name\\n hqCover\\n synopsis\\n id\\n updatedAt\\n updatedChapters\\n }\\n}\\n\"}"))
|
||||
return POST(baseUrl, jsonHeaders, "{\"operationName\":\"getRecentlyUpdatedHqs\",\"variables\":{},\"query\":\"query getRecentlyUpdatedHqs {\\n getRecentlyUpdatedHqs {\\n name\\n hqCover\\n synopsis\\n id\\n updatedAt\\n updatedChapters\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
}
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
@ -76,7 +77,7 @@ class HQNow : HttpSource() {
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return if (query.isNotBlank()) {
|
||||
queryIsTitle = true
|
||||
POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getHqsByName\",\"variables\":{\"name\":\"$query\"},\"query\":\"query getHqsByName(\$name: String!) {\\n getHqsByName(name: \$name) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n impressionsCount\\n }\\n}\\n\"}"))
|
||||
POST(baseUrl, jsonHeaders, "{\"operationName\":\"getHqsByName\",\"variables\":{\"name\":\"$query\"},\"query\":\"query getHqsByName(\$name: String!) {\\n getHqsByName(name: \$name) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n impressionsCount\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
} else {
|
||||
queryIsTitle = false
|
||||
var searchLetter = ""
|
||||
@ -88,7 +89,7 @@ class HQNow : HttpSource() {
|
||||
}
|
||||
}
|
||||
}
|
||||
POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getHqsByNameStartingLetter\",\"variables\":{\"letter\":\"$searchLetter-$searchLetter\"},\"query\":\"query getHqsByNameStartingLetter(\$letter: String!) {\\n getHqsByNameStartingLetter(letter: \$letter) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n impressionsCount\\n }\\n}\\n\"}"))
|
||||
POST(baseUrl, jsonHeaders, "{\"operationName\":\"getHqsByNameStartingLetter\",\"variables\":{\"letter\":\"$searchLetter-$searchLetter\"},\"query\":\"query getHqsByNameStartingLetter(\$letter: String!) {\\n getHqsByNameStartingLetter(letter: \$letter) {\\n id\\n name\\n editoraId\\n status\\n publisherName\\n impressionsCount\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +100,7 @@ class HQNow : HttpSource() {
|
||||
// Details
|
||||
|
||||
override fun mangaDetailsRequest(manga: SManga): Request {
|
||||
return POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getHqsById\",\"variables\":{\"id\":${manga.url}},\"query\":\"query getHqsById(\$id: Int!) {\\n getHqsById(id: \$id) {\\n id\\n name\\n synopsis\\n editoraId\\n status\\n publisherName\\n hqCover\\n impressionsCount\\n capitulos {\\n name\\n id\\n number\\n }\\n }\\n}\\n\"}"))
|
||||
return POST(baseUrl, jsonHeaders, "{\"operationName\":\"getHqsById\",\"variables\":{\"id\":${manga.url}},\"query\":\"query getHqsById(\$id: Int!) {\\n getHqsById(id: \$id) {\\n id\\n name\\n synopsis\\n editoraId\\n status\\n publisherName\\n hqCover\\n impressionsCount\\n capitulos {\\n name\\n id\\n number\\n }\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
@ -140,7 +141,7 @@ class HQNow : HttpSource() {
|
||||
// Pages
|
||||
|
||||
override fun pageListRequest(chapter: SChapter): Request {
|
||||
return POST(baseUrl, jsonHeaders, RequestBody.create(null, "{\"operationName\":\"getChapterById\",\"variables\":{\"chapterId\":${chapter.url}},\"query\":\"query getChapterById(\$chapterId: Int!) {\\n getChapterById(chapterId: \$chapterId) {\\n name\\n number\\n oneshot\\n pictures {\\n pictureUrl\\n }\\n hq {\\n id\\n name\\n capitulos {\\n id\\n number\\n }\\n }\\n }\\n}\\n\"}"))
|
||||
return POST(baseUrl, jsonHeaders, "{\"operationName\":\"getChapterById\",\"variables\":{\"chapterId\":${chapter.url}},\"query\":\"query getChapterById(\$chapterId: Int!) {\\n getChapterById(chapterId: \$chapterId) {\\n name\\n number\\n oneshot\\n pictures {\\n pictureUrl\\n }\\n hq {\\n id\\n name\\n capitulos {\\n id\\n number\\n }\\n }\\n }\\n}\\n\"}".toRequestBody(null))
|
||||
}
|
||||
|
||||
override fun pageListParse(response: Response): List<Page> {
|
||||
|
@ -248,7 +248,7 @@ class MangaTube : HttpSource() {
|
||||
val apiParams = document.select("script:containsData(pAPI)").first()!!.data()
|
||||
.substringAfter("pAPI = ")
|
||||
.substringBeforeLast(";")
|
||||
.let { JSON_PARSER.parse(it) }
|
||||
.let { JsonParser.parseString(it) }
|
||||
|
||||
val newUrl = chain.request().url.newBuilder()
|
||||
.addQueryParameter("nonce", apiParams["nonce"].string)
|
||||
@ -272,7 +272,7 @@ class MangaTube : HttpSource() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body!!.string())
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val ACCEPT = "application/json, text/plain, */*"
|
||||
@ -283,8 +283,6 @@ class MangaTube : HttpSource() {
|
||||
|
||||
private val TOKEN_REGEX = "token\\s+= \"(.*)\"".toRegex()
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) }
|
||||
|
||||
private const val TOKEN_NOT_FOUND = "Não foi possível obter o token de leitura."
|
||||
|
@ -184,7 +184,7 @@ class MundoHentai : ParsedHttpSource() {
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun latestUpdatesNextPageSelector(): String? = throw UnsupportedOperationException("Not used")
|
||||
override fun latestUpdatesNextPageSelector(): String = throw UnsupportedOperationException("Not used")
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
|
@ -124,7 +124,7 @@ class MundoMangaKun : ParsedHttpSource() {
|
||||
val link = element.attr("onclick")
|
||||
.substringAfter("this,")
|
||||
.substringBeforeLast(")")
|
||||
.let { JSON_PARSER.parse(it) }
|
||||
.let { JsonParser.parseString(it) }
|
||||
.array
|
||||
.first { it.obj["tipo"].string == "LEITOR" }
|
||||
|
||||
@ -135,7 +135,7 @@ class MundoMangaKun : ParsedHttpSource() {
|
||||
return document.select("script:containsData(var paginas)").first().data()
|
||||
.substringAfter("var paginas=")
|
||||
.substringBefore(";var")
|
||||
.let { JSON_PARSER.parse(it) }
|
||||
.let { JsonParser.parseString(it) }
|
||||
.array
|
||||
.mapIndexed { i, page -> Page(i, document.location(), page.string) }
|
||||
}
|
||||
@ -237,7 +237,5 @@ class MundoMangaKun : ParsedHttpSource() {
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ class SocialComics : HttpSource(), ConfigurableSource {
|
||||
response.close()
|
||||
}
|
||||
|
||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body!!.string())
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val SERVICE_URL = "https://service.socialcomics.com.br"
|
||||
@ -374,8 +374,6 @@ class SocialComics : HttpSource(), ConfigurableSource {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private const val EMAIL_PREF_KEY = "email"
|
||||
private const val EMAIL_PREF_TITLE = "E-mail"
|
||||
private const val EMAIL_PREF_SUMMARY = "Defina aqui o seu e-mail para o login."
|
||||
|
@ -347,7 +347,7 @@ class TsukiMangas : HttpSource() {
|
||||
else -> SManga.UNKNOWN
|
||||
}
|
||||
|
||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body!!.string())
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val ACCEPT = "application/json, text/plain, */*"
|
||||
@ -356,8 +356,6 @@ class TsukiMangas : HttpSource() {
|
||||
// By request of site owner. Detailed at Issue #4912 (in Portuguese).
|
||||
private val USER_AGENT = "Tachiyomi " + System.getProperty("http.agent")
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) }
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ class UnionMangas : ParsedHttpSource() {
|
||||
|
||||
private fun Element.textWithoutLabel(): String = text()!!.substringAfter(":").trim()
|
||||
|
||||
private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body!!.string())
|
||||
private fun Response.asJson(): JsonElement = JsonParser.parseString(body!!.string())
|
||||
|
||||
companion object {
|
||||
private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," +
|
||||
@ -269,8 +269,6 @@ class UnionMangas : ParsedHttpSource() {
|
||||
private const val BLOCK_MESSAGE = "O site está bloqueando o Tachiyomi. " +
|
||||
"Migre para outra fonte caso o problema persistir."
|
||||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
private val DATE_FORMATTER by lazy {
|
||||
SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user