DMZJ: Update API (#8264)

Update API
This commit is contained in:
Shikonin 2025-03-31 22:38:57 +08:00 committed by Draff
parent 26eb2757b4
commit cea3c8a60b
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
4 changed files with 23 additions and 2 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'DMZJ'
extClass = '.Dmzj'
extVersionCode = 44
extVersionCode = 45
}
apply from: "$rootDir/common.gradle"

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.zh.dmzj
import android.content.SharedPreferences
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.SChapter
@ -10,8 +11,14 @@ import okhttp3.Response
import org.jsoup.parser.Parser
object ApiV3 {
lateinit var preferences: SharedPreferences
private val v3apiUrl: String
get() = if (preferences.isOlderV3API == true) {
"https://v3api.idmzj.com"
} else {
"https://nnv3api.dmzj.com"
}
private const val v3apiUrl = "https://v3api.idmzj.com"
private const val apiUrl = "https://api.dmzj.com"
fun popularMangaUrl(page: Int) = "$v3apiUrl/classify/0/0/${page - 1}.json"

View File

@ -28,6 +28,9 @@ class Dmzj : ConfigurableSource, HttpSource() {
override val baseUrl = "https://m.idmzj.com"
private val preferences: SharedPreferences = getPreferences()
init {
ApiV3.preferences = preferences
}
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor(ImageUrlInterceptor)

View File

@ -35,6 +35,13 @@ fun getPreferencesInternal(context: Context) = arrayOf(
summary = "可以更精细地筛选出同时符合多个题材的作品。"
setDefaultValue(false)
},
SwitchPreferenceCompat(context).apply {
key = DMZJ_V3API_PREF
title = "V3API选择"
summary = "是否使用旧版v3API(默认nnv3api)"
setDefaultValue(false)
},
)
val SharedPreferences.imageQuality get() = getString(IMAGE_QUALITY_PREF, AUTO_RES)!!
@ -43,6 +50,8 @@ val SharedPreferences.showChapterComments get() = getBoolean(CHAPTER_COMMENTS_PR
val SharedPreferences.isMultiGenreFilter get() = getBoolean(MULTI_GENRE_FILTER_PREF, false)
val SharedPreferences.isOlderV3API get() = getBoolean(DMZJ_V3API_PREF, false)
private const val IMAGE_QUALITY_PREF = "imageSourcePreference"
const val AUTO_RES = "PREFER_ORIG_RES"
const val ORIGINAL_RES = "ORIG_RES_ONLY"
@ -50,3 +59,5 @@ const val LOW_RES = "LOW_RES_ONLY"
private const val CHAPTER_COMMENTS_PREF = "chapterComments"
private const val MULTI_GENRE_FILTER_PREF = "multiGenreFilter"
private const val DMZJ_V3API_PREF = "v3APIVersion"