Add hasCloudflare and versionId to output json (#7)

This commit is contained in:
Mitchell Syer 2022-05-07 23:53:30 -04:00 committed by GitHub
parent 556da6a0b1
commit 64aebe5416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ package suwayomi.tachidesk
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
import eu.kanade.tachiyomi.source.online.HttpSource
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
@ -54,13 +55,21 @@ data class SourceJson(
val name: String,
val lang: String,
val id: String,
val baseUrl: String
val baseUrl: String,
val versionId: Int,
val hasCloudflare: Short
) {
constructor(source: HttpSource) :
this(
source.name,
source.lang,
source.id.toString(),
source.baseUrl
source.baseUrl,
source.versionId,
source.client.interceptors
.any { it is CloudflareInterceptor }
.toShort()
)
}
private fun Boolean.toShort(): Short = if (this) 1 else 0