diff --git a/common.gradle b/common.gradle index 07a73d20c..9d652843c 100644 --- a/common.gradle +++ b/common.gradle @@ -78,7 +78,7 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() - freeCompilerArgs += "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi" + freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi" } kotlinter { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e80a3e9d9..c1d31ff7b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version. gradle-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_version" } gradle-kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version = "3.13.0" } -tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "1.4.0" } +tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "1.4.1" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin_version" } kotlin-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization_version" } @@ -19,11 +19,11 @@ coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", ve coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines_version" } injekt-core = { module = "com.github.inorichi.injekt:injekt-core", version = "65b0440" } -jsoup = { module = "org.jsoup:jsoup", version = "1.13.1" } -quickjs = { module = "app.cash.quickjs:quickjs-android", version = "0.9.2" } -okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.9.1" } rxandroid = { module = "io.reactivex:rxandroid", version = "1.2.1" } rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" } +jsoup = { module = "org.jsoup:jsoup", version = "1.13.1" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version = "5.0.0-alpha.11" } +quickjs = { module = "app.cash.quickjs:quickjs-android", version = "0.9.2" } [bundles] common = ["kotlin-stdlib", "coroutines-core", "coroutines-android", "injekt-core", "rxjava", "kotlin-protobuf", "kotlin-json", "jsoup", "okhttp", "tachiyomi-lib", "quickjs"] diff --git a/multisrc/build.gradle.kts b/multisrc/build.gradle.kts index 72ab83962..47a76f489 100644 --- a/multisrc/build.gradle.kts +++ b/multisrc/build.gradle.kts @@ -16,7 +16,7 @@ android { } kotlinOptions { - freeCompilerArgs += "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi" + freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi" } } diff --git a/multisrc/overrides/libgroup/hentailib/src/HentaiLib.kt b/multisrc/overrides/libgroup/hentailib/src/HentaiLib.kt index a8219f6f2..43a826d30 100644 --- a/multisrc/overrides/libgroup/hentailib/src/HentaiLib.kt +++ b/multisrc/overrides/libgroup/hentailib/src/HentaiLib.kt @@ -29,7 +29,7 @@ class HentaiLib : LibGroup("HentaiLib", "https://hentailib.me", "ru") { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (csrfToken.isEmpty()) { val tokenResponse = client.newCall(popularMangaRequest(page)).execute() - val resBody = tokenResponse.body!!.string() + val resBody = tokenResponse.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value } val url = super.searchMangaRequest(page, query, filters).url.newBuilder() diff --git a/multisrc/overrides/libgroup/mangalib/src/MangaLib.kt b/multisrc/overrides/libgroup/mangalib/src/MangaLib.kt index 8bce9f001..c676706ca 100644 --- a/multisrc/overrides/libgroup/mangalib/src/MangaLib.kt +++ b/multisrc/overrides/libgroup/mangalib/src/MangaLib.kt @@ -45,7 +45,7 @@ class MangaLib : LibGroup("MangaLib", "https://mangalib.me", "ru") { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (csrfToken.isEmpty()) { val tokenResponse = client.newCall(popularMangaRequest(page)).execute() - val resBody = tokenResponse.body!!.string() + val resBody = tokenResponse.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value } val url = super.searchMangaRequest(page, query, filters).url.newBuilder() diff --git a/multisrc/overrides/libgroup/yaoilib/src/YaoiLib.kt b/multisrc/overrides/libgroup/yaoilib/src/YaoiLib.kt index b559b8c26..d96dea964 100644 --- a/multisrc/overrides/libgroup/yaoilib/src/YaoiLib.kt +++ b/multisrc/overrides/libgroup/yaoilib/src/YaoiLib.kt @@ -27,7 +27,7 @@ class YaoiLib : LibGroup("YaoiLib", "https://v1.yaoilib.net", "ru") { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (csrfToken.isEmpty()) { val tokenResponse = client.newCall(popularMangaRequest(page)).execute() - val resBody = tokenResponse.body!!.string() + val resBody = tokenResponse.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value } val url = super.searchMangaRequest(page, query, filters).url.newBuilder() diff --git a/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt b/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt index c060a3dfc..2ede5176b 100644 --- a/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt +++ b/multisrc/overrides/madara/immortalupdates/src/ImmortalUpdates.kt @@ -35,7 +35,7 @@ class ImmortalUpdates : Madara("Immortal Updates", "https://immortalupdates.com" val fragment = response.request.url.fragment!! val args = fragment.substringAfter("$DESCRAMBLE=").split(",") - val image = unscrambleImage(response.body!!.byteStream(), args) + val image = unscrambleImage(response.body.byteStream(), args) val body = image.toResponseBody("image/jpeg".toMediaTypeOrNull()) return@addInterceptor response.newBuilder() .body(body) @@ -50,7 +50,7 @@ class ImmortalUpdates : Madara("Immortal Updates", "https://immortalupdates.com" val unscramblingCalls = client.newCall(GET(unscramblingCallsPage.imageUrl!!, headers)) .execute() - .use { it.body!!.string() } + .use { it.body.string() } unscramblingCalls.replace("\r", "").split("\n").filter { !it.isNullOrBlank() }.forEach { val args = unfuckJs(it) diff --git a/multisrc/overrides/mangabz/mangabz/src/Mangabz.kt b/multisrc/overrides/mangabz/mangabz/src/Mangabz.kt index 7e321eca3..d28bef540 100644 --- a/multisrc/overrides/mangabz/mangabz/src/Mangabz.kt +++ b/multisrc/overrides/mangabz/mangabz/src/Mangabz.kt @@ -127,7 +127,7 @@ class Mangabz : MangabzTheme("Mangabz", ""), ConfigurableSource { } return client.newCall(GET(page.url, headers)).asObservableSuccess().map { - val script = Unpacker.unpack(it.body!!.string()) + val script = Unpacker.unpack(it.body.string()) val parser = SubstringExtractor(script) val prefix = parser.substringBetween("pix=\"", "\"") // 2 pages, or 15 if server cache is ready diff --git a/multisrc/overrides/mangabz/vomic/src/Vomic.kt b/multisrc/overrides/mangabz/vomic/src/Vomic.kt index c729858ad..a6fb925eb 100644 --- a/multisrc/overrides/mangabz/vomic/src/Vomic.kt +++ b/multisrc/overrides/mangabz/vomic/src/Vomic.kt @@ -95,7 +95,7 @@ class Vomic : MangabzTheme("vomic", ""), ConfigurableSource { override fun getChapterElements(document: Document): Elements { val chapterId = document.location().removeSuffix("_c/").substringAfterLast('/') val response = client.newCall(GET("$baseUrl/chapter-$chapterId-s2/", headers)).execute() - return Jsoup.parseBodyFragment(response.body!!.string()).body().children() + return Jsoup.parseBodyFragment(response.body.string()).body().children() } override val needPageCount = false @@ -106,7 +106,7 @@ class Vomic : MangabzTheme("vomic", ""), ConfigurableSource { } override fun pageListParse(response: Response): List { - val urls = response.body!!.string().run { + val urls = response.body.string().run { val left = indexOf('[') val right = lastIndexOf(']') if (left + 1 == right) return emptyList() diff --git a/multisrc/overrides/mangaraw/manga9co/src/MangaRaw.kt b/multisrc/overrides/mangaraw/manga9co/src/MangaRaw.kt index 65e3090a0..7f30e3cb1 100644 --- a/multisrc/overrides/mangaraw/manga9co/src/MangaRaw.kt +++ b/multisrc/overrides/mangaraw/manga9co/src/MangaRaw.kt @@ -71,7 +71,7 @@ class MangaRaw : MangaRawTheme("MangaRaw", ""), ConfigurableSource { override fun pageListParse(response: Response): List { if (!isPagesShuffled) return super.pageListParse(response) - val html = response.body!!.string() + val html = response.body.string() val imageList = ImageListParser(html, 32).getImageList() ?: return emptyList() return imageList.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) diff --git a/multisrc/overrides/mangathemesia/constellarscans/src/ConstellarScans.kt b/multisrc/overrides/mangathemesia/constellarscans/src/ConstellarScans.kt index 47b647980..7e96a214d 100644 --- a/multisrc/overrides/mangathemesia/constellarscans/src/ConstellarScans.kt +++ b/multisrc/overrides/mangathemesia/constellarscans/src/ConstellarScans.kt @@ -45,7 +45,7 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca private val mobileUserAgent by lazy { val req = GET(UA_DB_URL) - val data = client.newCall(req).execute().body!!.use { + val data = client.newCall(req).execute().body.use { json.parseToJsonElement(it.string()).jsonArray }.mapNotNull { it.jsonObject["user-agent"]?.jsonPrimitive?.content?.takeIf { ua -> @@ -88,7 +88,7 @@ class ConstellarScans : MangaThemesia("Constellar Scans", "https://constellarsca } private val funkyScript by lazy { - client.newCall(GET(FUNKY_SCRIPT_URL)).execute().body!!.string() + client.newCall(GET(FUNKY_SCRIPT_URL)).execute().body.string() } @SuppressLint("SetJavaScriptEnabled") diff --git a/multisrc/overrides/mangathemesia/flamescans/src/FlameScans.kt b/multisrc/overrides/mangathemesia/flamescans/src/FlameScans.kt index 89187f6f3..bb1e4de7d 100644 --- a/multisrc/overrides/mangathemesia/flamescans/src/FlameScans.kt +++ b/multisrc/overrides/mangathemesia/flamescans/src/FlameScans.kt @@ -100,7 +100,7 @@ open class FlameScans( val request = chain.request().newBuilder().url(imageUrl).build() val response = chain.proceed(request) - val bitmap = BitmapFactory.decodeStream(response.body!!.byteStream()) + val bitmap = BitmapFactory.decodeStream(response.body.byteStream()) width += bitmap.width height = bitmap.height diff --git a/multisrc/overrides/mangathemesia/mangkomik/src/MangKomik.kt b/multisrc/overrides/mangathemesia/mangkomik/src/MangKomik.kt index cd466067b..4f067ffbe 100644 --- a/multisrc/overrides/mangathemesia/mangkomik/src/MangKomik.kt +++ b/multisrc/overrides/mangathemesia/mangkomik/src/MangKomik.kt @@ -21,7 +21,7 @@ class MangKomik : MangaThemesia("MangKomik", "https://mangkomik.net", "id") { ).execute() // Inject external JS - scriptEl.text(scriptResponse.body!!.string()) + scriptEl.text(scriptResponse.body.string()) return super.pageListParse(document) } } diff --git a/multisrc/overrides/mangathemesia/xcalibrscans/src/AntiScrapInterceptor.kt b/multisrc/overrides/mangathemesia/xcalibrscans/src/AntiScrapInterceptor.kt index 72f99c080..548ea0c78 100644 --- a/multisrc/overrides/mangathemesia/xcalibrscans/src/AntiScrapInterceptor.kt +++ b/multisrc/overrides/mangathemesia/xcalibrscans/src/AntiScrapInterceptor.kt @@ -30,7 +30,7 @@ class AntiScrapInterceptor : Interceptor { val newRequest = request.newBuilder().url(imageUrl).build() val response = chain.proceed(newRequest) - val bitmap = BitmapFactory.decodeStream(response.body!!.byteStream()) + val bitmap = BitmapFactory.decodeStream(response.body.byteStream()) response.close() width += bitmap.width diff --git a/multisrc/overrides/multichan/henchan/src/HenChan.kt b/multisrc/overrides/multichan/henchan/src/HenChan.kt index 8ee7ec2fc..ae3e2648e 100644 --- a/multisrc/overrides/multichan/henchan/src/HenChan.kt +++ b/multisrc/overrides/multichan/henchan/src/HenChan.kt @@ -234,7 +234,7 @@ class HenChan : MultiChan("HenChan", "http://y.hchan.live", "ru"), ConfigurableS } override fun pageListParse(response: Response): List { - val html = response.body!!.string() + val html = response.body.string() val prefix = "fullimg\": [" val beginIndex = html.indexOf(prefix) + prefix.length val endIndex = html.indexOf("]", beginIndex) diff --git a/multisrc/overrides/sinmh/gufengmh/src/Gufengmh.kt b/multisrc/overrides/sinmh/gufengmh/src/Gufengmh.kt index 8a703cc90..ee9548db9 100644 --- a/multisrc/overrides/sinmh/gufengmh/src/Gufengmh.kt +++ b/multisrc/overrides/sinmh/gufengmh/src/Gufengmh.kt @@ -41,7 +41,7 @@ class Gufengmh : SinMH("古风漫画网", "https://www.123gf.com") { val response = client.newCall(GET(baseUrl + prevUrl, headers)).execute() chapter.url = buildString { append(prevUrl, 0, prevUrl.lastIndexOf('/') + 1) - append(ProgressiveParser(response.body!!.string()).substringBetween("""nextChapterData = {"id":""", ",")) + append(ProgressiveParser(response.body.string()).substringBetween("""nextChapterData = {"id":""", ",")) append(".html") } } diff --git a/multisrc/overrides/sinmh/wuqimanga/src/WuqiManga.kt b/multisrc/overrides/sinmh/wuqimanga/src/WuqiManga.kt index 20ed9df20..b582138ab 100644 --- a/multisrc/overrides/sinmh/wuqimanga/src/WuqiManga.kt +++ b/multisrc/overrides/sinmh/wuqimanga/src/WuqiManga.kt @@ -55,7 +55,7 @@ class WuqiManga : SinMH("57漫画", "http://www.wuqimh.net") { override val imageHost: String by lazy { client.newCall(GET("$mobileUrl/templates_pc/default/scripts/configs.js", headers)).execute().let { - Regex("""\['(.+?)']""").find(it.body!!.string())!!.groupValues[1].run { "http://$this" } + Regex("""\['(.+?)']""").find(it.body.string())!!.groupValues[1].run { "http://$this" } } } diff --git a/multisrc/overrides/webtoons/webtoons/src/WebtoonsSrc.kt b/multisrc/overrides/webtoons/webtoons/src/WebtoonsSrc.kt index 6218bf040..77f480844 100644 --- a/multisrc/overrides/webtoons/webtoons/src/WebtoonsSrc.kt +++ b/multisrc/overrides/webtoons/webtoons/src/WebtoonsSrc.kt @@ -81,7 +81,7 @@ open class WebtoonsSrc( val motiontoonPath = motiontoonPathRegex.find(docString)!!.destructured.toList()[0] val motiontoonResponse = client.newCall(GET(docUrl, headers)).execute() - val motiontoonJson = json.parseToJsonElement(motiontoonResponse.body!!.string()).jsonObject + val motiontoonJson = json.parseToJsonElement(motiontoonResponse.body.string()).jsonObject val motiontoonImages = motiontoonJson["assets"]!!.jsonObject["image"]!!.jsonObject return motiontoonImages.entries diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/a3manga/A3Manga.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/a3manga/A3Manga.kt index e446544f1..b0e5511b6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/a3manga/A3Manga.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/a3manga/A3Manga.kt @@ -183,7 +183,7 @@ open class A3Manga( override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used") private inline fun Response.parseAs(): T { - return json.decodeFromString(body?.string().orEmpty()) + return json.decodeFromString(body.string()) } // https://stackoverflow.com/a/66614516 diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bakkin/BakkinReaderX.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bakkin/BakkinReaderX.kt index b9e627d8f..757d2b153 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bakkin/BakkinReaderX.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bakkin/BakkinReaderX.kt @@ -49,7 +49,7 @@ abstract class BakkinReaderX( rx.Observable.just(block(seriesCache))!! } else { client.newCall(GET(mainUrl, headers)).asObservableSuccess().map { - seriesCache = json.parseToJsonElement(it.body!!.string()) + seriesCache = json.parseToJsonElement(it.body.string()) .jsonObject.values.map(json::decodeFromJsonElement) block(seriesCache) }!! diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt index 42f3067c2..a072d55c4 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt @@ -412,7 +412,7 @@ abstract class Bilibili( } protected inline fun Response.parseAs(): BilibiliResultDto = use { - json.decodeFromString(it.body?.string().orEmpty()) + json.decodeFromString(it.body.string()) } private fun String.toDate(): Long { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicake/ComiCake.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicake/ComiCake.kt index 078115c1e..316f420e0 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicake/ComiCake.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicake/ComiCake.kt @@ -45,7 +45,7 @@ abstract class ComiCake( } override fun popularMangaParse(response: Response): MangasPage { - val res = response.body!!.string() + val res = response.body.string() return getMangasPageFromComicsResponse(res) } @@ -99,7 +99,7 @@ abstract class ComiCake( } override fun mangaDetailsParse(response: Response): SManga { - val comicJson = JSONObject(response.body!!.string()) + val comicJson = JSONObject(response.body.string()) return parseComicJson(comicJson, true) } @@ -132,7 +132,7 @@ abstract class ComiCake( } override fun searchMangaParse(response: Response): MangasPage { - val res = response.body!!.string() + val res = response.body.string() return getMangasPageFromComicsResponse(res) } @@ -141,7 +141,7 @@ abstract class ComiCake( } override fun latestUpdatesParse(response: Response): MangasPage { - val res = response.body!!.string() + val res = response.body.string() return getMangasPageFromComicsResponse(res, true) } @@ -158,7 +158,7 @@ abstract class ComiCake( } override fun chapterListParse(response: Response): List { - val chapterJson = JSONObject(response.body!!.string()) + val chapterJson = JSONObject(response.body.string()) val results = chapterJson.getJSONArray("results") val ret = ArrayList() for (i in 0 until results.length()) { @@ -168,7 +168,7 @@ abstract class ComiCake( } override fun pageListParse(response: Response): List { - val webPub = JSONObject(response.body!!.string()) + val webPub = JSONObject(response.body.string()) val readingOrder = webPub.getJSONArray("readingOrder") val ret = ArrayList() for (i in 0 until readingOrder.length()) { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicgamma/PtImgInterceptor.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicgamma/PtImgInterceptor.kt index a006809b0..fde055bf6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicgamma/PtImgInterceptor.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/comicgamma/PtImgInterceptor.kt @@ -24,11 +24,11 @@ object PtImgInterceptor : Interceptor { val path = url.pathSegments if (!path.last().endsWith(".ptimg.json")) return response - val metadata = json.decodeFromString(response.body!!.string()) + val metadata = json.decodeFromString(response.body.string()) val imageUrl = url.newBuilder().setEncodedPathSegment(path.size - 1, metadata.getFilename()).build() val imgRequest = request.newBuilder().url(imageUrl).build() val imgResponse = chain.proceed(imgRequest) - val image = BitmapFactory.decodeStream(imgResponse.body!!.byteStream()) + val image = BitmapFactory.decodeStream(imgResponse.body.byteStream()) val (width, height) = metadata.getViewSize() val result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) val view = Canvas(result) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/gigaviewer/GigaViewer.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/gigaviewer/GigaViewer.kt index 80fa62acf..77c83b9bd 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/gigaviewer/GigaViewer.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/gigaviewer/GigaViewer.kt @@ -157,7 +157,7 @@ abstract class GigaViewer( var result = client.newCall(request).execute() while (result.code != 404) { - val jsonResult = json.parseToJsonElement(result.body!!.string()).jsonObject + val jsonResult = json.parseToJsonElement(result.body.string()).jsonObject readMoreEndpoint = jsonResult["nextUrl"]!!.jsonPrimitive.content val tempDocument = Jsoup.parse( jsonResult["html"]!!.jsonPrimitive.content, @@ -265,7 +265,7 @@ abstract class GigaViewer( request = request.newBuilder().url(newUrl).build() val response = chain.proceed(request) - val image = decodeImage(response.body!!.byteStream(), width, height) + val image = decodeImage(response.body.byteStream(), width, height) val body = image.toResponseBody(jpegMediaType) response.close() diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/grouple/GroupLe.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/grouple/GroupLe.kt index 9ff758c68..b0029aaa7 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/grouple/GroupLe.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/grouple/GroupLe.kt @@ -251,7 +251,7 @@ abstract class GroupLe( } override fun pageListParse(response: Response): List { - val html = response.body!!.string() + val html = response.body.string() var readerMark = "rm_h.initReader( [" diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt index a0f578be6..c28be0347 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/guya/Guya.kt @@ -59,7 +59,7 @@ abstract class Guya( // Gets the response object from the request override fun popularMangaParse(response: Response): MangasPage { - val res = response.body!!.string() + val res = response.body.string() return parseManga(JSONObject(res)) } @@ -68,7 +68,7 @@ abstract class Guya( } override fun latestUpdatesParse(response: Response): MangasPage { - val payload = JSONObject(response.body!!.string()) + val payload = JSONObject(response.body.string()) val mangas = sortedMapOf() for (series in payload.keys()) { @@ -109,7 +109,7 @@ abstract class Guya( } private fun mangaDetailsParse(response: Response, manga: SManga): SManga { - val res = response.body!!.string() + val res = response.body.string() return parseMangaFromJson(JSONObject(res), "", manga.title) } @@ -139,7 +139,7 @@ abstract class Guya( // Called after the request private fun chapterListParse(response: Response, manga: SManga): List { - return parseChapterList(response.body!!.string(), manga) + return parseChapterList(response.body.string(), manga) } // Overridden fetch so that we use our overloaded method instead @@ -167,7 +167,7 @@ abstract class Guya( } private fun pageListParse(response: Response, chapter: SChapter): List { - val res = response.body!!.string() + val res = response.body.string() val json = JSONObject(res) val chapterNum = chapter.name.split(" - ")[0] @@ -221,7 +221,7 @@ abstract class Guya( } protected open fun searchMangaParseWithSlug(response: Response, slug: String): MangasPage { - val results = JSONObject(response.body!!.string()) + val results = JSONObject(response.body.string()) val truncatedJSON = JSONObject() for (mangaTitle in results.keys()) { @@ -236,7 +236,7 @@ abstract class Guya( } protected open fun searchMangaParse(response: Response, query: String): MangasPage { - val res = response.body!!.string() + val res = response.body.string() val json = JSONObject(res) val truncatedJSON = JSONObject() @@ -310,7 +310,7 @@ abstract class Guya( } private fun proxyPageListParse(response: Response, chapter: SChapter): List { - val res = response.body!!.string() + val res = response.body.string() val pages = if (chapter.url.removePrefix(PROXY_PREFIX).startsWith(NESTED_PROXY_API_PREFIX)) { JSONArray(res) } else { @@ -338,7 +338,7 @@ abstract class Guya( } protected open fun proxySearchMangaParse(response: Response, query: String): MangasPage { - val json = JSONObject(response.body!!.string()) + val json = JSONObject(response.body.string()) return MangasPage(listOf(parseMangaFromJson(json, query)), false) } @@ -531,7 +531,7 @@ abstract class Guya( if (!response.isSuccessful) { retryCount++ } else { - val json = JSONObject(response.body!!.string()) + val json = JSONObject(response.body.string()) for (scanId in json.keys()) { scanlatorMap[scanId] = json.getString(scanId) } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt index cfa2d16e0..929f27004 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt @@ -70,7 +70,7 @@ abstract class HeanCms( } override fun popularMangaParse(response: Response): MangasPage { - val json = response.body?.string().orEmpty() + val json = response.body.string() if (json.startsWith("{")) { val result = json.parseAs() @@ -153,7 +153,7 @@ abstract class HeanCms( } override fun searchMangaParse(response: Response): MangasPage { - val json = response.body?.string().orEmpty() + val json = response.body.string() if (response.request.url.pathSegments.last() == "search") { fetchAllTitles() @@ -300,7 +300,7 @@ abstract class HeanCms( while (hasNextPage) { val response = client.newCall(allTitlesRequest(page)).execute() - val json = response.body?.string().orEmpty() + val json = response.body.string() if (json.startsWith("{")) { val result = json.parseAs() @@ -368,7 +368,7 @@ abstract class HeanCms( } private inline fun Response.parseAs(): T = use { - it.body?.string().orEmpty().parseAs() + it.body.string().parseAs() } private inline fun String.parseAs(): T = json.decodeFromString(this) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/hentaihand/HentaiHand.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/hentaihand/HentaiHand.kt index 2115e4cfe..36232327d 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/hentaihand/HentaiHand.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/hentaihand/HentaiHand.kt @@ -65,7 +65,7 @@ abstract class HentaiHand( // Popular override fun popularMangaParse(response: Response): MangasPage { - val jsonResponse = json.parseToJsonElement(response.body!!.string()) + val jsonResponse = json.parseToJsonElement(response.body.string()) val mangaList = jsonResponse.jsonObject["data"]!!.jsonArray.map { val obj = it.jsonObject SManga.create().apply { @@ -118,7 +118,7 @@ abstract class HentaiHand( .subscribeOn(Schedulers.io()) .map { response -> // Returns the first matched id, or null if there are no results - val idList = json.parseToJsonElement(response.body!!.string()).jsonObject["data"]!!.jsonArray.map { + val idList = json.parseToJsonElement(response.body.string()).jsonObject["data"]!!.jsonArray.map { it.jsonObject["id"]!!.jsonPrimitive.content } if (idList.isEmpty()) { @@ -179,7 +179,7 @@ abstract class HentaiHand( } override fun mangaDetailsParse(response: Response): SManga { - val obj = json.parseToJsonElement(response.body!!.string()).jsonObject + val obj = json.parseToJsonElement(response.body.string()).jsonObject return SManga.create().apply { url = slugToUrl(obj) title = obj["title"]!!.jsonPrimitive.content @@ -224,7 +224,7 @@ abstract class HentaiHand( override fun chapterListParse(response: Response): List { val slug = response.request.url.toString().substringAfter("/api/comics/").removeSuffix("/chapters") return if (chapters) { - val array = json.parseToJsonElement(response.body!!.string()).jsonArray + val array = json.parseToJsonElement(response.body.string()).jsonArray array.map { SChapter.create().apply { url = "$slug/${it.jsonObject["slug"]!!.jsonPrimitive.content}" @@ -240,7 +240,7 @@ abstract class HentaiHand( } } } else { - val obj = json.parseToJsonElement(response.body!!.string()).jsonObject + val obj = json.parseToJsonElement(response.body.string()).jsonObject listOf( SChapter.create().apply { url = obj["slug"]!!.jsonPrimitive.content @@ -267,7 +267,7 @@ abstract class HentaiHand( } override fun pageListParse(response: Response): List = - json.parseToJsonElement(response.body!!.string()).jsonObject["images"]!!.jsonArray.map { + json.parseToJsonElement(response.body.string()).jsonObject["images"]!!.jsonArray.map { val imgObj = it.jsonObject val index = imgObj["page"]!!.jsonPrimitive.int val imgUrl = imgObj["source_url"]!!.jsonPrimitive.content @@ -304,13 +304,9 @@ abstract class HentaiHand( if (response.code == 401) { throw IOException("Failed to login, check if username and password are correct") } - - if (response.body == null) { - throw IOException("Login response body is empty") - } try { // Returns access token as a string, unless unparseable - return json.parseToJsonElement(response.body!!.string()).jsonObject["auth"]!!.jsonObject["access-token"]!!.jsonPrimitive.content + return json.parseToJsonElement(response.body.string()).jsonObject["auth"]!!.jsonObject["access-token"]!!.jsonPrimitive.content } catch (e: IllegalArgumentException) { throw IOException("Cannot parse login response body") } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/kemono/Kemono.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/kemono/Kemono.kt index 21d3b35a0..09fcbad4a 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/kemono/Kemono.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/kemono/Kemono.kt @@ -150,7 +150,7 @@ open class Kemono( private fun cacheCreators() { val callback = object : Callback { override fun onResponse(call: Call, response: Response) = - response.body!!.source().run { + response.body.source().run { readAll(blackholeSink()) close() } @@ -200,7 +200,7 @@ open class Kemono( override fun imageUrlParse(response: Response) = throw UnsupportedOperationException("Not used.") private inline fun Response.parseAs(): T = use { - json.decodeFromStream(it.body!!.byteStream()) + json.decodeFromStream(it.body.byteStream()) } override fun setupPreferenceScreen(screen: PreferenceScreen) { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGenerator.kt index 9cc3e8678..99b6e96d2 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGenerator.kt @@ -9,7 +9,7 @@ class LibGenerator : ThemeSourceGenerator { override val themeClass = "LibGroup" - override val baseVersionCode: Int = 14 + override val baseVersionCode: Int = 15 override val sources = listOf( SingleLang("MangaLib", "https://mangalib.me", "ru", overrideVersionCode = 74), diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGroup.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGroup.kt index 17d4bca18..40e0d1712 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGroup.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/libgroup/LibGroup.kt @@ -70,7 +70,7 @@ abstract class LibGroup( val possibleType = urlRequest.substringAfterLast("/").substringBefore("?").split(".") return if (urlRequest.contains("/chapters/") and (possibleType.size == 2)) { val realType = possibleType[1] - val image = response.body?.byteString()?.toResponseBody("image/$realType".toMediaType()) + val image = response.body.byteString().toResponseBody("image/$realType".toMediaType()) response.newBuilder().body(image).build() } else { response @@ -120,7 +120,7 @@ abstract class LibGroup( .asObservableSuccess() .flatMap { response -> // Obtain token - val resBody = response.body!!.string() + val resBody = response.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value return@flatMap fetchLatestMangaFromApi(page) } @@ -147,7 +147,7 @@ abstract class LibGroup( .asObservableSuccess() .flatMap { response -> // Obtain token - val resBody = response.body!!.string() + val resBody = response.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value return@flatMap fetchPopularMangaFromApi(page) } @@ -164,7 +164,7 @@ abstract class LibGroup( } override fun popularMangaParse(response: Response): MangasPage { - val resBody = response.body!!.string() + val resBody = response.body.string() val result = json.decodeFromString(resBody) val items = result["items"]!!.jsonObject val popularMangas = items["data"]?.jsonArray?.map { popularMangaFromElement(it) } @@ -266,15 +266,15 @@ abstract class LibGroup( } manga.genre = category + ", " + rawAgeStop + ", " + genres.joinToString { it.trim() } - val altName = if (dataManga!!.jsonObject["altNames"]?.jsonArray.orEmpty().isNotEmpty()) { + val altName = if (dataManga.jsonObject["altNames"]?.jsonArray.orEmpty().isNotEmpty()) { "Альтернативные названия:\n" + dataManga.jsonObject["altNames"]!!.jsonArray.joinToString(" / ") { it.jsonPrimitive.content } + "\n\n" } else { "" } val mediaNameLanguage = when { - isEng.equals("eng") && dataManga!!.jsonObject["rusName"]?.jsonPrimitive?.content.orEmpty().isNotEmpty() -> dataManga.jsonObject["rusName"]!!.jsonPrimitive.content + "\n" - isEng.equals("rus") && dataManga!!.jsonObject["engName"]?.jsonPrimitive?.content.orEmpty().isNotEmpty() -> dataManga.jsonObject["engName"]!!.jsonPrimitive.content + "\n" + isEng.equals("eng") && dataManga.jsonObject["rusName"]?.jsonPrimitive?.content.orEmpty().isNotEmpty() -> dataManga.jsonObject["rusName"]!!.jsonPrimitive.content + "\n" + isEng.equals("rus") && dataManga.jsonObject["engName"]?.jsonPrimitive?.content.orEmpty().isNotEmpty() -> dataManga.jsonObject["engName"]!!.jsonPrimitive.content + "\n" else -> "" } manga.description = mediaNameLanguage + ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")\n" + altName + document.select(".media-description__text").text() @@ -536,7 +536,7 @@ abstract class LibGroup( override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (csrfToken.isEmpty()) { val tokenResponse = client.newCall(popularMangaRequest(page)).execute() - val resBody = tokenResponse.body!!.string() + val resBody = tokenResponse.body.string() csrfToken = "_token\" content=\"(.*)\"".toRegex().find(resBody)!!.groups[1]!!.value } val url = "$baseUrl/filterlist?page=$page".toHttpUrlOrNull()!!.newBuilder() diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt index 9d96aad6d..a81b564dd 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt @@ -95,7 +95,7 @@ abstract class Madara( if (uaResponse.isSuccessful) { var listUserAgentString = - json.decodeFromString>>(uaResponse.body!!.string())["desktop"] + json.decodeFromString>>(uaResponse.body.string())["desktop"] if (filterIncludeUserAgent.isNotEmpty()) { listUserAgentString = listUserAgentString!!.filter { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt index 6423810c3..ffa6a079d 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt @@ -138,7 +138,7 @@ abstract class MangAdventure( /** Decodes the JSON response as an object. */ private inline fun Response.decode() = - json.decodeFromJsonElement(json.parseToJsonElement(body!!.string())) + json.decodeFromJsonElement(json.parseToJsonElement(body.string())) /** Converts a [Series] object to an [SManga]. */ private fun mangaFromJSON(series: Series) = diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt index b2919ff96..264095d37 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangahub/MangaHub.kt @@ -62,7 +62,7 @@ abstract class MangaHub( if (uaResponse.isSuccessful) { // only using desktop chromium-based browsers, apparently they refuse to load(403) if not chrome(ium) - val uaList = json.decodeFromString>>(uaResponse.body!!.string()) + val uaList = json.decodeFromString>>(uaResponse.body.string()) val chromeUserAgentString = uaList["desktop"]!!.filter { it.contains("chrome", ignoreCase = true) } userAgent = chromeUserAgentString.random() checkedUa = true diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangasar/MangaSar.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangasar/MangaSar.kt index 2c0bd4b93..34e35e203 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangasar/MangaSar.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangasar/MangaSar.kt @@ -270,7 +270,7 @@ abstract class MangaSar( } protected inline fun Response.parseAs(): T = use { - json.decodeFromString(body?.string().orEmpty()) + json.decodeFromString(body.string()) } protected fun String.toDate(): Long { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/DecryptInterceptor.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/DecryptInterceptor.kt index 5acbe35b4..b2098f511 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/DecryptInterceptor.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/DecryptInterceptor.kt @@ -17,7 +17,7 @@ object DecryptInterceptor : Interceptor { null -> key2 else -> return response } - val data = decrypt(response.body!!.bytes(), key) + val data = decrypt(response.body.bytes(), key) val body = data.toResponseBody("image/jpeg".toMediaType()) return response.newBuilder().body(body).build() } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/MCCMS.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/MCCMS.kt index 8497e8bdb..cabad627b 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/MCCMS.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mccms/MCCMS.kt @@ -131,7 +131,7 @@ open class MCCMS( override fun imageRequest(page: Page) = GET(page.imageUrl!!, pcHeaders) private inline fun Response.parseAs(): T = use { - json.decodeFromStream>(it.body!!.byteStream()).data + json.decodeFromStream>(it.body.byteStream()).data } val genreData = GenreData(hasCategoryPage) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMS.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMS.kt index 5c13088b9..901820c9d 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMS.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMS.kt @@ -153,7 +153,7 @@ abstract class MMRCMS( override fun searchMangaParse(response: Response): MangasPage { return if (listOf("query", "q").any { it in response.request.url.queryParameterNames }) { // If a search query was specified, use search instead! - val jsonArray = json.decodeFromString(response.body!!.string()).let { + val jsonArray = json.decodeFromString(response.body.string()).let { it["suggestions"]!!.jsonArray } MangasPage( diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMSJsonGen.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMSJsonGen.kt index 1078b08c9..ec6b18b3a 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMSJsonGen.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/MMRCMSJsonGen.kt @@ -111,19 +111,19 @@ class MMRCMSJsonGen { // Bypass Cloudflare ("Please wait 5 seconds" page) if (response.code == 503 && response.header("Server") in serverCheck) { var cookie = "${response.header("Set-Cookie")!!.substringBefore(";")}; " - Jsoup.parse(response.body!!.string()).let { document -> + Jsoup.parse(response.body.string()).let { document -> val path = document.select("[id=\"challenge-form\"]").attr("action") val chk = document.select("[name=\"s\"]").attr("value") getOkHttpClient().newCall(Request.Builder().url("$url/$path?s=$chk").build()).execute().let { solved -> cookie += solved.header("Set-Cookie")!!.substringBefore(";") request.addHeader("Cookie", cookie).build().let { - return Jsoup.parse(getOkHttpClient().newCall(it).execute().body?.string()) + return Jsoup.parse(getOkHttpClient().newCall(it).execute().body.string()) } } } } if (response.code == 200) { - return Jsoup.parse(response.body?.string()) + return Jsoup.parse(response.body.string()) } } } catch (e: Exception) { @@ -216,7 +216,7 @@ class MMRCMSJsonGen { companion object { val sources = sourceList - val relativePath = System.getProperty("user.dir") + "/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/SourceData.kt" + val relativePath = System.getProperty("user.dir")!! + "/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mmrcms/SourceData.kt" @JvmStatic fun main(args: Array) { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/monochrome/MonochromeCMS.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/monochrome/MonochromeCMS.kt index 90ca8ce62..2737f4ce1 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/monochrome/MonochromeCMS.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/monochrome/MonochromeCMS.kt @@ -103,7 +103,7 @@ open class MonochromeCMS( } private inline fun Response.decode() = - json.decodeFromString(body!!.string()) + json.decodeFromString(body.string()) override fun popularMangaRequest(page: Int) = throw UnsupportedOperationException("Not used!") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/multichan/MultiChan.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/multichan/MultiChan.kt index d491857f8..91d82aa75 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/multichan/MultiChan.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/multichan/MultiChan.kt @@ -123,7 +123,7 @@ abstract class MultiChan( } override fun pageListParse(response: Response): List { - val html = response.body!!.string() + val html = response.body.string() val beginIndex = html.indexOf("fullimg\":[") + 10 val endIndex = html.indexOf(",]", beginIndex) val trimmedHtml = html.substring(beginIndex, endIndex).replace("\"", "") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/otakusanctuary/OtakuSanctuary.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/otakusanctuary/OtakuSanctuary.kt index 692454d8b..4e2b5c2c7 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/otakusanctuary/OtakuSanctuary.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/otakusanctuary/OtakuSanctuary.kt @@ -188,7 +188,7 @@ open class OtakuSanctuary( headers, FormBody.Builder().add("chapId", numericId).build(), ), - ).execute().body!!.string(), + ).execute().body.string(), ).jsonObject if (data["view"] != null) { @@ -226,7 +226,7 @@ open class OtakuSanctuary( headers, FormBody.Builder().add("chapId", numericId).build(), ), - ).execute().body!!.string(), + ).execute().body.string(), ).jsonObject val content = alternate["Content"]?.jsonPrimitive?.content ?: throw Exception("No pages found") diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReader.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReader.kt index 128786a3e..e1808a5f5 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReader.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReader.kt @@ -41,7 +41,7 @@ abstract class PizzaReader( GET("$apiUrl/comics", headers) override fun popularMangaParse(response: Response): MangasPage { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) val comicList = result.comics .map(::popularMangaFromObject) @@ -58,7 +58,7 @@ abstract class PizzaReader( override fun latestUpdatesRequest(page: Int): Request = popularMangaRequest(page) override fun latestUpdatesParse(response: Response): MangasPage { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) val comicList = result.comics .filter { comic -> comic.lastChapter != null } @@ -85,7 +85,7 @@ abstract class PizzaReader( .map { mangaDetailsParse(it).apply { initialized = true } } override fun mangaDetailsParse(response: Response): SManga = SManga.create().apply { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) val comic = result.comic!! title = comic.title @@ -100,7 +100,7 @@ abstract class PizzaReader( override fun chapterListRequest(manga: SManga) = GET(apiUrl + manga.url, headers) override fun chapterListParse(response: Response): List { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) val comic = result.comic!! return comic.chapters @@ -120,7 +120,7 @@ abstract class PizzaReader( override fun pageListRequest(chapter: SChapter) = GET(apiUrl + chapter.url, headers) override fun pageListParse(response: Response): List { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) return result.chapter!!.pages.mapIndexed { i, page -> Page(i, "", page) } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/readerfront/ReaderFront.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/readerfront/ReaderFront.kt index db190f666..434218a00 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/readerfront/ReaderFront.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/readerfront/ReaderFront.kt @@ -129,7 +129,7 @@ abstract class ReaderFront( copy(mangas.filter(predicate)) private inline fun Response.parse(name: String) = - json.parseToJsonElement(body!!.string()).jsonObject.run { + json.parseToJsonElement(body.string()).jsonObject.run { if (containsKey("errors")) { throw Error(get("errors")!![0]["message"].content) } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt index fac5e745f..9a12ebfd6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt @@ -187,7 +187,7 @@ abstract class SinMH( protected open val imageHost: String by lazy { client.newCall(GET("$baseUrl/js/config.js", headers)).execute().let { - Regex("""resHost:.+?"domain":\["(.+?)"""").find(it.body!!.string())!! + Regex("""resHost:.+?"domain":\["(.+?)"""").find(it.body.string())!! .groupValues[1].substringAfter(':').run { "https:$this" } } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/Webtoons.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/Webtoons.kt index 4baf9de8c..877f846d6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/Webtoons.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/Webtoons.kt @@ -288,7 +288,7 @@ open class Webtoons( val motiontoonPath = motiontoonPathRegex.find(docString)!!.destructured.toList()[0] val motiontoonResponse = client.newCall(GET(docUrl, headers)).execute() - val motiontoonJson = json.parseToJsonElement(motiontoonResponse.body!!.string()).jsonObject + val motiontoonJson = json.parseToJsonElement(motiontoonResponse.body.string()).jsonObject val motiontoonImages = motiontoonJson["assets"]!!.jsonObject["image"]!!.jsonObject return motiontoonImages.entries diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/WebtoonsTranslate.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/WebtoonsTranslate.kt index b871758ac..b070f6bce 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/WebtoonsTranslate.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/webtoons/WebtoonsTranslate.kt @@ -62,7 +62,7 @@ open class WebtoonsTranslate( override fun popularMangaParse(response: Response): MangasPage { val offset = response.request.url.queryParameter("offset")!!.toInt() - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject val responseCode = result["code"]!!.jsonPrimitive.content if (responseCode != "000") { @@ -115,7 +115,7 @@ open class WebtoonsTranslate( override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = mangaRequest(page, 200) private fun searchMangaParse(response: Response, query: String): MangasPage { - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject val responseCode = result["code"]!!.jsonPrimitive.content if (responseCode != "000") { @@ -177,7 +177,7 @@ open class WebtoonsTranslate( } override fun chapterListParse(response: Response): List { - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject val responseCode = result["code"]!!.jsonPrimitive.content if (responseCode != "000") { @@ -214,7 +214,7 @@ open class WebtoonsTranslate( } override fun pageListParse(response: Response): List { - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject return result["result"]!!.jsonObject["imageInfo"]!!.jsonArray .mapIndexed { i, jsonEl -> diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/weebreader/Weebreader.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/weebreader/Weebreader.kt index 68f1e5f2f..f5a8f43f6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/weebreader/Weebreader.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/weebreader/Weebreader.kt @@ -36,7 +36,7 @@ abstract class Weebreader( override fun latestUpdatesRequest(page: Int): Request = popularMangaRequest(page) override fun latestUpdatesParse(response: Response): MangasPage { - val titlesJson = json.parseToJsonElement(response.body!!.string()).jsonArray + val titlesJson = json.parseToJsonElement(response.body.string()).jsonArray val mangaList = titlesJson .mapNotNull { @@ -61,7 +61,7 @@ abstract class Weebreader( override fun popularMangaRequest(page: Int): Request = GET("$baseUrl/api/titles") override fun popularMangaParse(response: Response): MangasPage { - val titlesJson = json.parseToJsonElement(response.body!!.string()).jsonArray + val titlesJson = json.parseToJsonElement(response.body.string()).jsonArray val mangaList = titlesJson.mapNotNull { val manga = it.jsonObject @@ -87,7 +87,7 @@ abstract class Weebreader( override fun mangaDetailsRequest(manga: SManga) = GET("$baseUrl/titles/${manga.url}") override fun mangaDetailsParse(response: Response): SManga { - val titleJson = json.parseToJsonElement(response.body!!.string()).jsonObject + val titleJson = json.parseToJsonElement(response.body.string()).jsonObject if (titleJson["type"]!!.jsonPrimitive.content != "Comic") { throw UnsupportedOperationException("Tachiyomi only supports Comics.") @@ -108,7 +108,7 @@ abstract class Weebreader( override fun chapterListRequest(manga: SManga) = GET("$baseUrl/api/titles/${manga.url}") override fun chapterListParse(response: Response): List { - val titleJson = json.parseToJsonElement(response.body!!.string()).jsonObject + val titleJson = json.parseToJsonElement(response.body.string()).jsonObject if (titleJson["type"]!!.jsonPrimitive.content != "Comic") { throw UnsupportedOperationException("Tachiyomi only supports Comics.") @@ -129,7 +129,7 @@ abstract class Weebreader( override fun pageListRequest(chapter: SChapter): Request = GET("$baseUrl/api/chapters/${chapter.url.substring(37, 73)}") override fun pageListParse(response: Response): List { - val jsonObject = json.parseToJsonElement(response.body!!.string()).jsonObject + val jsonObject = json.parseToJsonElement(response.body.string()).jsonObject return jsonObject["pages"]!!.jsonArray.map { val item = it.jsonObject diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt index 480ea958a..d0be3a196 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/zeistmanga/ZeistManga.kt @@ -56,7 +56,7 @@ abstract class ZeistManga( val res = client.newCall(req).execute() // Parse JSON API response - val jsonString = res.body!!.string() + val jsonString = res.body.string() val result = json.decodeFromString(jsonString) // Transform JSON response into List @@ -126,7 +126,7 @@ abstract class ZeistManga( } override fun popularMangaParse(response: Response): MangasPage { - val jsonString = response.body?.string().orEmpty() + val jsonString = response.body.string() val result = json.decodeFromString(jsonString) // Transform JSON response into List val mangas = result.feed!!.entry?.map { it.toSManga(baseUrl) } diff --git a/src/all/batoto/src/eu/kanade/tachiyomi/extension/all/batoto/BatoTo.kt b/src/all/batoto/src/eu/kanade/tachiyomi/extension/all/batoto/BatoTo.kt index 6e36c0ff7..ff8fc23b1 100644 --- a/src/all/batoto/src/eu/kanade/tachiyomi/extension/all/batoto/BatoTo.kt +++ b/src/all/batoto/src/eu/kanade/tachiyomi/extension/all/batoto/BatoTo.kt @@ -267,7 +267,7 @@ open class BatoTo( } private fun queryHistoryParse(response: Response): MangasPage { - val json = json.decodeFromString(response.body!!.string()) + val json = json.decodeFromString(response.body.string()) val html = json.jsonObject["html"]!!.jsonPrimitive.content val document = Jsoup.parse(html, response.request.url.toString()) @@ -358,7 +358,7 @@ open class BatoTo( } private fun altChapterParse(response: Response, title: String): List { - return Jsoup.parse(response.body!!.string(), response.request.url.toString(), Parser.xmlParser()) + return Jsoup.parse(response.body.string(), response.request.url.toString(), Parser.xmlParser()) .select("channel > item").map { item -> SChapter.create().apply { url = item.selectFirst("guid").text() diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/ComickFun.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/ComickFun.kt index d1f26cd3a..de77dfef0 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/ComickFun.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/ComickFun.kt @@ -62,7 +62,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun popularMangaParse(response: Response): MangasPage { - val result = json.decodeFromString>(response.body!!.string()) + val result = json.decodeFromString>(response.body.string()) return MangasPage( result.map { data -> SManga.create().apply { @@ -91,7 +91,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun latestUpdatesParse(response: Response): MangasPage { - val result = json.decodeFromString>(response.body!!.string()) + val result = json.decodeFromString>(response.body.string()) return MangasPage( result.map { data -> SManga.create().apply { @@ -190,7 +190,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun searchMangaParse(response: Response): MangasPage { - val result = json.decodeFromString>(response.body!!.string()) + val result = json.decodeFromString>(response.body.string()) return MangasPage( result.map { data -> SManga.create().apply { @@ -221,7 +221,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun mangaDetailsParse(response: Response): SManga { - val mangaData = json.decodeFromString(response.body!!.string()) + val mangaData = json.decodeFromString(response.body.string()) return SManga.create().apply { url = "$baseUrl/comic/${mangaData.comic.slug}" title = mangaData.comic.title @@ -245,7 +245,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun chapterListParse(response: Response): List { - val mangaData = json.decodeFromString(response.body!!.string()) + val mangaData = json.decodeFromString(response.body.string()) val mangaHid = findCurrentSlug(mangaData.comic.slug) val chapterData = client.newCall( GET( @@ -262,7 +262,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S headers, ), ).execute() - val result = json.decodeFromString(chapterData.body!!.string()) + val result = json.decodeFromString(chapterData.body.string()) return result.chapters.map { chapter -> SChapter.create().apply { url = "/comic/${mangaData.comic.slug}/${chapter.hid}-chapter-${chapter.chap}-$comickFunLang" @@ -297,7 +297,7 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S } override fun pageListParse(response: Response): List { - val result = json.decodeFromString(response.body!!.string()) + val result = json.decodeFromString(response.body.string()) return result.chapter.images.mapIndexedNotNull { index, data -> if (data.url == null) null else Page(index = index, imageUrl = data.url) } @@ -331,6 +331,6 @@ abstract class ComickFun(override val lang: String, private val comickFunLang: S ).execute() /** If the API does not contain the ID for the slug, return the slug back **/ - return json.parseToJsonElement(response.body!!.string()).jsonObject[oldSlug]!!.jsonPrimitive.content + return json.parseToJsonElement(response.body.string()).jsonObject[oldSlug]!!.jsonPrimitive.content } } diff --git a/src/all/comico/src/eu/kanade/tachiyomi/extension/all/comico/Comico.kt b/src/all/comico/src/eu/kanade/tachiyomi/extension/all/comico/Comico.kt index 653b77147..5ab0d9882 100644 --- a/src/all/comico/src/eu/kanade/tachiyomi/extension/all/comico/Comico.kt +++ b/src/all/comico/src/eu/kanade/tachiyomi/extension/all/comico/Comico.kt @@ -174,7 +174,7 @@ open class Comico( CryptoAES.decrypt(this, keyBytes, ivBytes) private val Response.data: JsonElement? - get() = json.parseToJsonElement(body!!.string()).jsonObject.also { + get() = json.parseToJsonElement(body.string()).jsonObject.also { val code = it["result"]["code"].jsonPrimitive.int if (code != 200) throw Error(status(code)) }["data"] diff --git a/src/all/commitstrip/src/eu/kanade/tachiyomi/extension/all/commitstrip/CommitStrip.kt b/src/all/commitstrip/src/eu/kanade/tachiyomi/extension/all/commitstrip/CommitStrip.kt index b2f56289b..0c24a82eb 100644 --- a/src/all/commitstrip/src/eu/kanade/tachiyomi/extension/all/commitstrip/CommitStrip.kt +++ b/src/all/commitstrip/src/eu/kanade/tachiyomi/extension/all/commitstrip/CommitStrip.kt @@ -86,7 +86,7 @@ abstract class CommitStrip( override fun fetchChapterList(manga: SManga): Observable> { // create a new call to parse the no of pages in the site // example responseString - Page 1 of 11 - val responseString = client.newCall(GET("${manga.url}", headers)).execute().run { + val responseString = client.newCall(GET(manga.url, headers)).execute().run { asJsoup().selectFirst(".wp-pagenavi .pages")?.text() ?: "1" } // use regex to get the last number (i.e. 11 above) @@ -120,7 +120,7 @@ abstract class CommitStrip( // get the chapter date from the url val date = Regex("\\d{4}\\/\\d{2}\\/\\d{2}").find(url)?.value - val parsedDate = SimpleDateFormat("yyyy/MM/dd", Locale.US).parse(date) + val parsedDate = date?.let { SimpleDateFormat("yyyy/MM/dd", Locale.US).parse(it) } date_upload = parsedDate?.time ?: 0L name = element.select("span").text() @@ -129,7 +129,7 @@ abstract class CommitStrip( // Page override fun fetchPageList(chapter: SChapter): Observable> { - return client.newCall(GET("${chapter.url}", headers)).execute().run { + return client.newCall(GET(chapter.url, headers)).execute().run { asJsoup().select(".entry-content p img").attr("src") }.let { Observable.just(listOf(Page(0, "", it))) diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt index 29443c7f9..aef29ccd3 100644 --- a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt @@ -61,7 +61,7 @@ open class Cubari(override val lang: String) : HttpSource() { } override fun latestUpdatesParse(response: Response): MangasPage { - val result = json.parseToJsonElement(response.body!!.string()).jsonArray + val result = json.parseToJsonElement(response.body.string()).jsonArray return parseMangaList(result, SortType.UNPINNED) } @@ -79,7 +79,7 @@ open class Cubari(override val lang: String) : HttpSource() { } override fun popularMangaParse(response: Response): MangasPage { - val result = json.parseToJsonElement(response.body!!.string()).jsonArray + val result = json.parseToJsonElement(response.body.string()).jsonArray return parseMangaList(result, SortType.PINNED) } @@ -99,7 +99,7 @@ open class Cubari(override val lang: String) : HttpSource() { } private fun mangaDetailsParse(response: Response, manga: SManga): SManga { - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject return parseManga(result, manga) } @@ -124,7 +124,7 @@ open class Cubari(override val lang: String) : HttpSource() { // Called after the request private fun chapterListParse(response: Response, manga: SManga): List { - val res = response.body!!.string() + val res = response.body.string() return parseChapterList(res, manga) } @@ -163,7 +163,7 @@ open class Cubari(override val lang: String) : HttpSource() { } private fun directPageListParse(response: Response): List { - val res = response.body!!.string() + val res = response.body.string() val pages = json.parseToJsonElement(res).jsonArray return pages.mapIndexed { i, jsonEl -> @@ -178,7 +178,7 @@ open class Cubari(override val lang: String) : HttpSource() { } private fun seriesJsonPageListParse(response: Response, chapter: SChapter): List { - val jsonObj = json.parseToJsonElement(response.body!!.string()).jsonObject + val jsonObj = json.parseToJsonElement(response.body.string()).jsonObject val groups = jsonObj["groups"]!!.jsonObject val groupMap = groups.entries .map { Pair(it.value.jsonPrimitive.content, it.key) } @@ -249,7 +249,7 @@ open class Cubari(override val lang: String) : HttpSource() { } private fun searchMangaParse(response: Response, query: String): MangasPage { - val result = json.parseToJsonElement(response.body!!.string()).jsonObject + val result = json.parseToJsonElement(response.body.string()).jsonObject return parseSearchList(result, query) } diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/RemoteStorageUtils.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/RemoteStorageUtils.kt index ee93b00b0..64ea897f9 100644 --- a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/RemoteStorageUtils.kt +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/RemoteStorageUtils.kt @@ -92,7 +92,7 @@ class RemoteStorageUtils { return if (transparent) { response } else { - response.newBuilder().body(jsInterface.payload.toResponseBody(response.body?.contentType())).build() + response.newBuilder().body(jsInterface.payload.toResponseBody(response.body.contentType())).build() } } } diff --git a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt index 7e7cf1548..3be24fe23 100644 --- a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt +++ b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt @@ -173,7 +173,7 @@ abstract class EHentai( // if no genres are selected by the user set all genres to on if (!check) { for (i in it) { - (i as GenreOption).state = true + i.state = true } } } @@ -356,7 +356,7 @@ abstract class EHentai( } // Headers - override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader)!! + override fun headersBuilder() = super.headersBuilder().add("Cookie", cookiesHeader) private fun buildSettings(settings: List) = settings.filterNotNull().joinToString(separator = "-") @@ -381,7 +381,7 @@ abstract class EHentai( .build() chain.proceed(newReq) - }.build()!! + }.build() // Filters override fun getFilterList() = FilterList( diff --git a/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt b/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt index 47853de46..4b1d33249 100644 --- a/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt +++ b/src/all/imhentai/src/eu/kanade/tachiyomi/extension/all/imhentai/IMHentai.kt @@ -36,8 +36,8 @@ class IMHentai(override val lang: String, private val imhLang: String) : ParsedH val response = chain.proceed(chain.request()) if (!response.headers("Content-Type").toString().contains("text/html")) return response - val responseContentType = response.body!!.contentType() - val responseString = response.body!!.string() + val responseContentType = response.body.contentType() + val responseString = response.body.string() if (responseString.contains("Overload... Please use the advanced search")) { response.close() diff --git a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/ImageInterceptor.kt b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/ImageInterceptor.kt index e0fe34c50..683093cd4 100644 --- a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/ImageInterceptor.kt +++ b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/ImageInterceptor.kt @@ -31,7 +31,7 @@ object ImageInterceptor : Interceptor { private fun Response.decode(key: ByteArray, iv: ByteArray) = AES.let { it.init(Cipher.DECRYPT_MODE, SecretKeySpec(key, "AES"), IvParameterSpec(iv)) - newBuilder().body(it.doFinal(body!!.bytes()).toResponseBody(mediaType)).build() + newBuilder().body(it.doFinal(body.bytes()).toResponseBody(mediaType)).build() } private fun String.atob() = Base64.decode(this, Base64.URL_SAFE) diff --git a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt index 93ca1d714..174a957cf 100644 --- a/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt +++ b/src/all/izneo/src/eu/kanade/tachiyomi/extension/all/izneo/Izneo.kt @@ -185,7 +185,7 @@ class Izneo(override val lang: String) : ConfigurableSource, HttpSource() { private fun String.btoa() = Base64.encode(toByteArray(), Base64.DEFAULT) private fun Response.parse() = - json.parseToJsonElement(body!!.string()).apply { + json.parseToJsonElement(body.string()).apply { if (jsonObject["status"]?.jsonPrimitive?.content == "error") { when (jsonObject["code"]?.jsonPrimitive?.content) { "4" -> throw Error("You are not authorized to view this") diff --git a/src/all/junmeitu/src/eu/kanade/tachiyomi/extension/all/junmeitu/Junmeitu.kt b/src/all/junmeitu/src/eu/kanade/tachiyomi/extension/all/junmeitu/Junmeitu.kt index 1464fe64e..d8384c99e 100644 --- a/src/all/junmeitu/src/eu/kanade/tachiyomi/extension/all/junmeitu/Junmeitu.kt +++ b/src/all/junmeitu/src/eu/kanade/tachiyomi/extension/all/junmeitu/Junmeitu.kt @@ -125,7 +125,7 @@ class Junmeitu : ParsedHttpSource() { } override fun imageUrlParse(response: Response): String { - val page: PageDto = json.decodeFromString(response.body!!.string()) + val page: PageDto = json.decodeFromString(response.body.string()) val img = Jsoup.parseBodyFragment(page.pic).body().child(0) return img.attr("src") } diff --git a/src/all/kavita/src/eu/kanade/tachiyomi/extension/all/kavita/Kavita.kt b/src/all/kavita/src/eu/kanade/tachiyomi/extension/all/kavita/Kavita.kt index 97caf0b34..417c91309 100644 --- a/src/all/kavita/src/eu/kanade/tachiyomi/extension/all/kavita/Kavita.kt +++ b/src/all/kavita/src/eu/kanade/tachiyomi/extension/all/kavita/Kavita.kt @@ -126,7 +126,7 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou Throwable("Error. Request body is empty"), ) } - json.decodeFromString(it.body?.string().orEmpty()) + json.decodeFromString(it.body.string()) } private inline fun > safeValueOf(type: String): T { return java.lang.Enum.valueOf(T::class.java, type) @@ -1175,7 +1175,7 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou emptyList() } } catch (e: Exception) { - Log.e(LOG_TAG, "[Filter] Error decoding JSON for genres filter -> ${response.body!!}", e) + Log.e(LOG_TAG, "[Filter] Error decoding JSON for genres filter -> ${response.body}", e) emptyList() } } diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt index d40eacd93..0889de16f 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt @@ -192,10 +192,7 @@ open class Komga(private val suffix: String = "") : ConfigurableSource, Unmetere GET(manga.url.replaceFirst("api/v1/", "", ignoreCase = true), headers) override fun mangaDetailsParse(response: Response): SManga { - val responseBody = response.body - ?: throw IllegalStateException("Response code ${response.code}") - - return responseBody.use { body -> + return response.body.use { body -> if (response.fromReadList()) { val readList = json.decodeFromString(body.string()) readList.toSManga() @@ -211,8 +208,6 @@ open class Komga(private val suffix: String = "") : ConfigurableSource, Unmetere override fun chapterListParse(response: Response): List { val responseBody = response.body - ?: throw IllegalStateException("Response code ${response.code}") - val page = responseBody.use { json.decodeFromString>(it.string()).content } val r = page.mapIndexed { index, book -> @@ -233,8 +228,6 @@ open class Komga(private val suffix: String = "") : ConfigurableSource, Unmetere override fun pageListParse(response: Response): List { val responseBody = response.body - ?: throw IllegalStateException("Response code ${response.code}") - val pages = responseBody.use { json.decodeFromString>(it.string()) } return pages.map { val url = "${response.request.url}/${it.number}" + @@ -252,8 +245,6 @@ open class Komga(private val suffix: String = "") : ConfigurableSource, Unmetere private fun processSeriesPage(response: Response): MangasPage { val responseBody = response.body - ?: throw IllegalStateException("Response code ${response.code}") - return responseBody.use { body -> if (response.fromReadList()) { with(json.decodeFromString>(body.string())) { diff --git a/src/all/lanraragi/src/eu/kanade/tachiyomi/extension/all/lanraragi/LANraragi.kt b/src/all/lanraragi/src/eu/kanade/tachiyomi/extension/all/lanraragi/LANraragi.kt index ec4572a46..2afc25ab3 100644 --- a/src/all/lanraragi/src/eu/kanade/tachiyomi/extension/all/lanraragi/LANraragi.kt +++ b/src/all/lanraragi/src/eu/kanade/tachiyomi/extension/all/lanraragi/LANraragi.kt @@ -76,7 +76,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme } override fun mangaDetailsParse(response: Response): SManga { - val archive = json.decodeFromString(response.body!!.string()) + val archive = json.decodeFromString(response.body.string()) return archiveToSManga(archive) } @@ -89,7 +89,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme } override fun chapterListParse(response: Response): List { - val archive = json.decodeFromString(response.body!!.string()) + val archive = json.decodeFromString(response.body.string()) val uri = getApiUriBuilder("/api/archives/${archive.arcid}/files") val prefClearNew = preferences.getBoolean(NEW_ONLY_KEY, NEW_ONLY_DEFAULT) @@ -123,7 +123,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme } override fun pageListParse(response: Response): List { - val archivePage = json.decodeFromString(response.body!!.string()) + val archivePage = json.decodeFromString(response.body.string()) return archivePage.pages.mapIndexed { index, url -> val uri = Uri.parse("${baseUrl}${url.trimStart('.')}") @@ -197,7 +197,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme } override fun searchMangaParse(response: Response): MangasPage { - val jsonResult = json.decodeFromString(response.body!!.string()) + val jsonResult = json.decodeFromString(response.body.string()) val currentStart = getStart(response) val archives = arrayListOf() @@ -340,7 +340,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme // Helper private fun getRandomID(query: String): String { val searchRandom = client.newCall(GET("$baseUrl/api/search/random?count=1&$query", headers)).execute() - val data = json.parseToJsonElement(searchRandom.body!!.string()).jsonObject["data"] + val data = json.parseToJsonElement(searchRandom.body.string()).jsonObject["data"] val archive = data!!.jsonArray.firstOrNull()?.jsonObject // 0.8.2~0.8.7 = id, 0.8.8+ = arcid @@ -361,7 +361,7 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme .subscribe( { categories = try { - json.decodeFromString(it.body!!.string()) + json.decodeFromString(it.body.string()) } catch (e: Exception) { emptyList() } diff --git a/src/all/leagueoflegends/src/eu/kanade/tachiyomi/extension/all/leagueoflegends/LOLUniverse.kt b/src/all/leagueoflegends/src/eu/kanade/tachiyomi/extension/all/leagueoflegends/LOLUniverse.kt index a87498f6b..0bdfc045f 100644 --- a/src/all/leagueoflegends/src/eu/kanade/tachiyomi/extension/all/leagueoflegends/LOLUniverse.kt +++ b/src/all/leagueoflegends/src/eu/kanade/tachiyomi/extension/all/leagueoflegends/LOLUniverse.kt @@ -110,7 +110,7 @@ class LOLUniverse( throw UnsupportedOperationException("Not used") private inline fun Response.decode() = - json.decodeFromString(body!!.string()) + json.decodeFromString(body.string()) private fun String.clean() = replace("

", "

").replace("

", "\n").replace("

", "") diff --git a/src/all/littlegarden/src/eu/kanade/tachiyomi/extension/all/littlegarden/LittleGarden.kt b/src/all/littlegarden/src/eu/kanade/tachiyomi/extension/all/littlegarden/LittleGarden.kt index 77e4f4e00..33de7bc11 100644 --- a/src/all/littlegarden/src/eu/kanade/tachiyomi/extension/all/littlegarden/LittleGarden.kt +++ b/src/all/littlegarden/src/eu/kanade/tachiyomi/extension/all/littlegarden/LittleGarden.kt @@ -153,7 +153,7 @@ class LittleGarden : ParsedHttpSource() { .headers(newHeaders) .build() val resp = client.newCall(request).execute() - val chapters = Json.parseToJsonElement(resp.body?.string().toString()).jsonObject["data"]?.jsonObject?.get("chapters")?.jsonArray + val chapters = Json.parseToJsonElement(resp.body.string()).jsonObject["data"]?.jsonObject?.get("chapters")?.jsonArray if (chapters != null) { return chapters.map { SChapter.create().apply { diff --git a/src/all/luscious/src/eu/kanade/tachiyomi/extension/all/luscious/Luscious.kt b/src/all/luscious/src/eu/kanade/tachiyomi/extension/all/luscious/Luscious.kt index 1349a7d72..e0db253ad 100644 --- a/src/all/luscious/src/eu/kanade/tachiyomi/extension/all/luscious/Luscious.kt +++ b/src/all/luscious/src/eu/kanade/tachiyomi/extension/all/luscious/Luscious.kt @@ -67,7 +67,7 @@ abstract class Luscious( private val rewriteOctetStream: Interceptor = Interceptor { chain -> val originalResponse: Response = chain.proceed(chain.request()) if (originalResponse.headers("Content-Type").contains("application/octet-stream") && originalResponse.request.url.toString().contains(".webp")) { - val orgBody = originalResponse.body!!.bytes() + val orgBody = originalResponse.body.bytes() val newBody = orgBody.toResponseBody("image/webp".toMediaTypeOrNull()) originalResponse.newBuilder() .body(newBody) @@ -215,7 +215,7 @@ abstract class Luscious( } private fun parseAlbumListResponse(response: Response): MangasPage { - val data = json.decodeFromString(response.body!!.string()) + val data = json.decodeFromString(response.body.string()) with(data["data"]!!.jsonObject["album"]!!.jsonObject["list"]) { return MangasPage( this!!.jsonObject["items"]!!.jsonArray.map { @@ -281,7 +281,7 @@ abstract class Luscious( .let { it.first { f -> f.jsonObject["name"]!!.jsonPrimitive.content == "album_id" } } .let { it.jsonObject["value"]!!.jsonPrimitive.content } - var data = json.decodeFromString(response.body!!.string()) + var data = json.decodeFromString(response.body.string()) .let { it.jsonObject["data"]!!.jsonObject["picture"]!!.jsonObject["list"]!!.jsonObject } while (nextPage) { @@ -303,7 +303,7 @@ abstract class Luscious( } if (nextPage) { val newPage = client.newCall(GET(buildAlbumPicturesPageUrl(id, page))).execute() - data = json.decodeFromString(newPage.body!!.string()) + data = json.decodeFromString(newPage.body.string()) .let { it["data"]!!.jsonObject["picture"]!!.jsonObject["list"]!!.jsonObject } } page++ @@ -353,7 +353,7 @@ abstract class Luscious( .let { it.first { f -> f.jsonObject["name"]!!.jsonPrimitive.content == "album_id" } } .let { it.jsonObject["value"]!!.jsonPrimitive.content } - var data = json.decodeFromString(response.body!!.string()) + var data = json.decodeFromString(response.body.string()) .let { it["data"]!!.jsonObject["picture"]!!.jsonObject["list"]!!.jsonObject } while (nextPage) { @@ -371,7 +371,7 @@ abstract class Luscious( } if (nextPage) { val newPage = client.newCall(GET(buildAlbumPicturesPageUrl(id, page))).execute() - data = json.decodeFromString(newPage.body!!.string()) + data = json.decodeFromString(newPage.body.string()) .let { it["data"]!!.jsonObject["picture"]!!.jsonObject["list"]!!.jsonObject } } page++ @@ -406,7 +406,7 @@ abstract class Luscious( return client.newCall(GET(page.url, headers)) .asObservableSuccess() .map { - val data = json.decodeFromString(it.body!!.string()).let { data -> + val data = json.decodeFromString(it.body.string()).let { data -> data["data"]!!.jsonObject["picture"]!!.jsonObject["list"]!!.jsonObject } when (getResolutionPref()) { @@ -430,7 +430,7 @@ abstract class Luscious( } private fun detailsParse(response: Response): SManga { - val data = json.decodeFromString(response.body!!.string()) + val data = json.decodeFromString(response.body.string()) with(data["data"]!!.jsonObject["album"]!!.jsonObject["get"]!!.jsonObject) { val manga = SManga.create() manga.url = this["url"]!!.jsonPrimitive.content @@ -498,10 +498,10 @@ abstract class Luscious( class TriStateFilterOption(name: String, val value: String) : Filter.TriState(name) abstract class TriStateGroupFilter(name: String, options: List) : Filter.Group(name, options) { - val included: List + private val included: List get() = state.filter { it.isIncluded() }.map { it.value } - val excluded: List + private val excluded: List get() = state.filter { it.isExcluded() }.map { it.value } fun anyNotIgnored(): Boolean = state.any { !it.isIgnored() } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt index 37b231619..4d1f2fc45 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt @@ -745,7 +745,7 @@ abstract class MangaDex(final override val lang: String, private val dexLang: St } private inline fun Response.parseAs(): T = use { - helper.json.decodeFromString(body?.string().orEmpty()) + helper.json.decodeFromString(body.string()) } private val SharedPreferences.contentRating diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt index 53f6b90be..2109aecbc 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt @@ -237,7 +237,7 @@ class MangaDexHelper(lang: String) { return getMdAtHomeUrl(tokenRequestUrl, client, headers, CacheControl.FORCE_NETWORK) } - return response.use { json.decodeFromString(it.body!!.string()).baseUrl } + return response.use { json.decodeFromString(it.body.string()).baseUrl } } /** diff --git a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt index beb9a905a..75f16885c 100644 --- a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt +++ b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt @@ -350,7 +350,7 @@ class MangaPlus( } val contentType = response.headers["Content-Type"] ?: "image/jpeg" - val image = response.body!!.bytes().decodeXorCipher(encryptionKey) + val image = response.body.bytes().decodeXorCipher(encryptionKey) val body = image.toResponseBody(contentType.toMediaTypeOrNull()) return response.newBuilder() @@ -390,7 +390,7 @@ class MangaPlus( } private fun Response.asMangaPlusResponse(): MangaPlusResponse = use { - json.decodeFromString(body?.string().orEmpty()) + json.decodeFromString(body.string()) } private val SharedPreferences.imageQuality: String diff --git a/src/all/mangapluscreators/src/eu/kanade/tachiyomi/extension/all/mangapluscreators/MangaPlusCreators.kt b/src/all/mangapluscreators/src/eu/kanade/tachiyomi/extension/all/mangapluscreators/MangaPlusCreators.kt index c5131d1d9..33188d7e9 100644 --- a/src/all/mangapluscreators/src/eu/kanade/tachiyomi/extension/all/mangapluscreators/MangaPlusCreators.kt +++ b/src/all/mangapluscreators/src/eu/kanade/tachiyomi/extension/all/mangapluscreators/MangaPlusCreators.kt @@ -192,7 +192,7 @@ class MangaPlusCreators(override val lang: String) : HttpSource() { } private fun Response.asMpcResponse(): MpcResponse = use { - json.decodeFromString(body!!.string()) + json.decodeFromString(body.string()) } companion object { diff --git a/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReader.kt b/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReader.kt index ddf7c28a3..36fc4fa70 100644 --- a/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReader.kt +++ b/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReader.kt @@ -251,7 +251,7 @@ open class MangaReader( ) private fun Response.parseHtmlProperty(): Document { - val html = Json.parseToJsonElement(body!!.string()).jsonObject["html"]!!.jsonPrimitive.content + val html = Json.parseToJsonElement(body.string()).jsonObject["html"]!!.jsonPrimitive.content return Jsoup.parseBodyFragment(html) } } diff --git a/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReaderImageInterceptor.kt b/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReaderImageInterceptor.kt index 1844f6032..d0f86d0ca 100644 --- a/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReaderImageInterceptor.kt +++ b/src/all/mangareaderto/src/eu/kanade/tachiyomi/extension/all/mangareaderto/MangaReaderImageInterceptor.kt @@ -26,7 +26,7 @@ object MangaReaderImageInterceptor : Interceptor { // TODO: remove the query parameter check (legacy) in later versions if (url.fragment != SCRAMBLED && url.queryParameter("shuffled") == null) return response - val image = descramble(response.body!!.byteStream()) + val image = descramble(response.body.byteStream()) val body = image.toResponseBody("image/jpeg".toMediaType()) return response.newBuilder() .body(body) diff --git a/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt b/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt index 6ddd22300..d79ec194e 100644 --- a/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt +++ b/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt @@ -173,7 +173,7 @@ class MangaUp(override val lang: String) : HttpSource() { } private inline fun Response.parseAs(): T = use { - json.decodeFromString(body?.string().orEmpty()) + json.decodeFromString(body.string()) } companion object { diff --git a/src/all/mango/src/eu/kanade/tachiyomi/extension/all/mango/Mango.kt b/src/all/mango/src/eu/kanade/tachiyomi/extension/all/mango/Mango.kt index 50872ecd9..93551ae39 100644 --- a/src/all/mango/src/eu/kanade/tachiyomi/extension/all/mango/Mango.kt +++ b/src/all/mango/src/eu/kanade/tachiyomi/extension/all/mango/Mango.kt @@ -47,7 +47,7 @@ class Mango : ConfigurableSource, UnmeteredSource, HttpSource() { // Our popular manga are just our library of manga override fun popularMangaParse(response: Response): MangasPage { val result = try { - json.decodeFromString(response.body!!.string()) + json.decodeFromString(response.body.string()) } catch (e: Exception) { apiCookies = "" throw Exception("Login Likely Failed. Try Refreshing.") @@ -122,7 +122,7 @@ class Mango : ConfigurableSource, UnmeteredSource, HttpSource() { // This will just return the same thing as the main library endpoint override fun mangaDetailsParse(response: Response): SManga { val result = try { - json.decodeFromString(response.body!!.string()) + json.decodeFromString(response.body.string()) } catch (e: Exception) { apiCookies = "" throw Exception("Login Likely Failed. Try Refreshing.") @@ -140,7 +140,7 @@ class Mango : ConfigurableSource, UnmeteredSource, HttpSource() { // The chapter url will contain how many pages the chapter contains for our page list endpoint override fun chapterListParse(response: Response): List { val result = try { - json.decodeFromString(response.body!!.string()) + json.decodeFromString(response.body.string()) } catch (e: Exception) { apiCookies = "" throw Exception("Login Likely Failed. Try Refreshing.") diff --git a/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt b/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt index f6874feef..a04c3f3b0 100644 --- a/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt +++ b/src/all/myreadingmanga/src/eu/kanade/tachiyomi/extension/all/myreadingmanga/MyReadingManga.kt @@ -231,7 +231,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin // Grabs page containing filters and puts it into cache private fun filterAssist(url: String): String { val response = client.newCall(GET(url, headers)).execute() - return response.body!!.string() + return response.body.string() } private fun cacheAssistant() { diff --git a/src/all/netcomics/src/eu/kanade/tachiyomi/extension/all/netcomics/Netcomics.kt b/src/all/netcomics/src/eu/kanade/tachiyomi/extension/all/netcomics/Netcomics.kt index d124e925e..7c1c477fa 100644 --- a/src/all/netcomics/src/eu/kanade/tachiyomi/extension/all/netcomics/Netcomics.kt +++ b/src/all/netcomics/src/eu/kanade/tachiyomi/extension/all/netcomics/Netcomics.kt @@ -242,7 +242,7 @@ class Netcomics( private inline fun Response.data() = json.decodeFromJsonElement( - json.parseToJsonElement(body!!.string()).run { + json.parseToJsonElement(body.string()).run { jsonObject["data"] ?: throw Error( jsonObject["message"]!!.jsonPrimitive.content, ) diff --git a/src/all/peppercarrot/src/eu/kanade/tachiyomi/extension/all/peppercarrot/Preferences.kt b/src/all/peppercarrot/src/eu/kanade/tachiyomi/extension/all/peppercarrot/Preferences.kt index e7b803dc2..4d22ce6ef 100644 --- a/src/all/peppercarrot/src/eu/kanade/tachiyomi/extension/all/peppercarrot/Preferences.kt +++ b/src/all/peppercarrot/src/eu/kanade/tachiyomi/extension/all/peppercarrot/Preferences.kt @@ -52,7 +52,7 @@ val SharedPreferences.langData: List @Synchronized fun updateLangData(client: OkHttpClient, headers: Headers, preferences: SharedPreferences) { val lastUpdated = client.newCall(GET("$BASE_URL/0_sources/last_updated.txt", headers)) - .execute().body!!.string().substringBefore('\n').toLong() + .execute().body.string().substringBefore('\n').toLong() if (lastUpdated <= preferences.lastUpdated) return val editor = preferences.edit().putLong(LAST_UPDATED_PREF, lastUpdated) @@ -125,7 +125,7 @@ private fun fetchTitles(client: OkHttpClient, headers: Headers): Map Response.parseAs(): T = json.decodeFromString(body!!.string()) +private inline fun Response.parseAs(): T = json.decodeFromString(body.string()) private inline fun ProtoBuf.decodeFromBase64(base64: String): T = decodeFromByteArray(Base64.decode(base64, Base64.NO_WRAP)) diff --git a/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt b/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt index d0ef8ba95..195c7c1ff 100644 --- a/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt +++ b/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt @@ -216,7 +216,7 @@ open class SimplyHentai(override val lang: String) : ConfigurableSource, HttpSou get() = preferences.getString("blacklist", "")!! private inline fun Response.decode() = - json.decodeFromString(body!!.string()) + json.decodeFromString(body.string()) override fun imageUrlParse(response: Response) = throw UnsupportedOperationException("Not used") diff --git a/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt b/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt index 66e796b49..73f15a232 100644 --- a/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt +++ b/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt @@ -65,7 +65,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { override fun popularMangaParse(response: Response): MangasPage = MangasPage( - json.decodeFromString>(response.body!!.string()).map { + json.decodeFromString>(response.body.string()).map { it.toSManga() }, false, @@ -76,7 +76,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { GET("$checkedBaseUrl/api/v1/manga/${manga.url}/?onlineFetch=true", headers) override fun mangaDetailsParse(response: Response): SManga = - json.decodeFromString(response.body!!.string()).let { it.toSManga() } + json.decodeFromString(response.body.string()).let { it.toSManga() } // ------------- Chapter ------------- @@ -84,7 +84,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { GET("$checkedBaseUrl/api/v1/manga/${manga.url}/chapters?onlineFetch=true", headers) override fun chapterListParse(response: Response): List = - json.decodeFromString>(response.body!!.string()).map { + json.decodeFromString>(response.body.string()).map { it.toSChapter() } @@ -109,7 +109,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { val mangaId = sChapter.url.split(" ").first() val chapterIndex = sChapter.url.split(" ").last() - val chapter = json.decodeFromString(response.body!!.string()) + val chapter = json.decodeFromString(response.body.string()) return List(chapter.pageCount) { Page(it + 1, "", "$checkedBaseUrl/api/v1/manga/$mangaId/chapter/$chapterIndex/page/$it/") @@ -135,7 +135,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { .subscribe( { response -> categoryList = try { - json.decodeFromString>(response.body!!.string()) + json.decodeFromString>(response.body.string()) } catch (e: Exception) { emptyList() } diff --git a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt index 4aefdc44d..7e663a3ab 100644 --- a/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt +++ b/src/all/tappytoon/src/eu/kanade/tachiyomi/extension/all/tappytoon/Tappytoon.kt @@ -40,13 +40,13 @@ class Tappytoon(override val lang: String) : HttpSource() { } // Fix image content type val type = IMG_CONTENT_TYPE.toMediaType() - val body = res.body!!.bytes().toResponseBody(type) + val body = res.body.bytes().toResponseBody(type) return@addInterceptor res.newBuilder().body(body) .header("Content-Type", IMG_CONTENT_TYPE).build() } // Throw JSON error if available if (mime == "application/json") { - res.body?.string()?.let(json::parseToJsonElement)?.run { + res.body.string().let(json::parseToJsonElement).run { throw IOException(jsonObject["message"]!!.jsonPrimitive.content) } } @@ -185,7 +185,7 @@ class Tappytoon(override val lang: String) : HttpSource() { ) private inline fun Response.parse() = - json.decodeFromJsonElement(json.parseToJsonElement(body!!.string())) + json.decodeFromJsonElement(json.parseToJsonElement(body.string())) class Genre(values: Array) : Filter.Select("Genre", values) diff --git a/src/all/xinmeitulu/src/eu/kanade/tachiyomi/extension/all/xinmeitulu/Xinmeitulu.kt b/src/all/xinmeitulu/src/eu/kanade/tachiyomi/extension/all/xinmeitulu/Xinmeitulu.kt index b62b7c403..cfd03aa46 100644 --- a/src/all/xinmeitulu/src/eu/kanade/tachiyomi/extension/all/xinmeitulu/Xinmeitulu.kt +++ b/src/all/xinmeitulu/src/eu/kanade/tachiyomi/extension/all/xinmeitulu/Xinmeitulu.kt @@ -92,7 +92,7 @@ class Xinmeitulu : ParsedHttpSource() { private fun contentTypeIntercept(chain: Interceptor.Chain): Response { val response = chain.proceed(chain.request()) if (response.header("content-type")?.startsWith("image") == true) { - val body = response.body!!.source().asResponseBody(jpegMediaType) + val body = response.body.source().asResponseBody(jpegMediaType) return response.newBuilder().body(body).build() } return response diff --git a/src/all/xkcd/src/eu/kanade/tachiyomi/extension/all/xkcd/translations/XkcdZH.kt b/src/all/xkcd/src/eu/kanade/tachiyomi/extension/all/xkcd/translations/XkcdZH.kt index 9ed173179..e65f15aaa 100644 --- a/src/all/xkcd/src/eu/kanade/tachiyomi/extension/all/xkcd/translations/XkcdZH.kt +++ b/src/all/xkcd/src/eu/kanade/tachiyomi/extension/all/xkcd/translations/XkcdZH.kt @@ -34,7 +34,7 @@ class XkcdZH : Xkcd("https://xkcd.tw", "zh", "yyyy-MM-dd HH:mm:ss") { override fun mangaDetailsRequest(manga: SManga) = GET(baseUrl, headers) override fun chapterListParse(response: Response) = - json.parseToJsonElement(response.body!!.string()).jsonObject.values.map { + json.parseToJsonElement(response.body.string()).jsonObject.values.map { val obj = it.jsonObject val number = obj["id"]!!.jsonPrimitive.content val title = obj["title"]!!.jsonPrimitive.content diff --git a/src/ar/asgardteam/src/eu/kanade/tachiyomi/extension/ar/asgardteam/AsgardTeam.kt b/src/ar/asgardteam/src/eu/kanade/tachiyomi/extension/ar/asgardteam/AsgardTeam.kt index 7fdb0ef07..2fa2e61da 100644 --- a/src/ar/asgardteam/src/eu/kanade/tachiyomi/extension/ar/asgardteam/AsgardTeam.kt +++ b/src/ar/asgardteam/src/eu/kanade/tachiyomi/extension/ar/asgardteam/AsgardTeam.kt @@ -151,7 +151,7 @@ class AsgardTeam : ParsedHttpSource() { private class TypeFilter(vals: Array>) : UriPartFilter("Type", vals) - open fun getTypeFilter(): Array> = arrayOf( + private fun getTypeFilter(): Array> = arrayOf( Pair("", "