Skip to content

Commit

Permalink
No more client_info since it's deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Jan 8, 2024
1 parent f6cf56e commit f738fef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/me/iacn/biliroaming/Constant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ object Constant {
const val CUSTOM_COLOR_KEY = "biliroaming_custom_color"
const val CURRENT_COLOR_KEY = "theme_entries_current_key"
const val DEFAULT_CUSTOM_COLOR = -0xe6b7d
const val infoUrl = "https://api.bilibili.com/client_info"
const val zoneUrl = "https://api.bilibili.com/x/web-interface/zone"
}
15 changes: 4 additions & 11 deletions app/src/main/java/me/iacn/biliroaming/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.future.future
import me.iacn.biliroaming.hook.*
import me.iacn.biliroaming.utils.*
import org.json.JSONObject
import java.util.concurrent.CompletableFuture


Expand Down Expand Up @@ -69,16 +68,10 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
)

country = MainScope().future(Dispatchers.IO) {
fun JSONObject.optStringFix(name: String, fallback: String = "") =
if (isNull(name)) fallback else optString(name, fallback)
when (fetchJson(Constant.infoUrl)?.optJSONObject("data")
?.optStringFix("country").orEmpty().ifEmpty {
fetchJson(Constant.zoneUrl)?.optJSONObject("data")
?.optStringFix("country")
}) {
"中国" -> "cn"
"香港", "澳门" -> "hk"
"台湾" -> "tw"
when (fetchJson(Constant.zoneUrl)?.optJSONObject("data")?.optInt("country_code", 0)?.or(0)) {
86 -> "cn"
852, 853 -> "hk"
886 -> "tw"
else -> "global"
}.also { Log.d("当前地区: $it") }
}
Expand Down

0 comments on commit f738fef

Please sign in to comment.