Skip to content

Commit

Permalink
Clean up codes
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Jan 13, 2024
1 parent 8d5ee10 commit 76dfd9e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/src/main/java/me/iacn/biliroaming/network/BiliRoamingApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ object BiliRoamingApi {
val mobiApp = sPrefs.getString("th_server_platform", platform)!!
if (thUrl != null) {
val builder = Uri.Builder()
builder.scheme("https").encodedAuthority(thUrl).path(THAILAND_PATH_SEASON)
builder.scheme("https").encodedAuthority(thUrl)
.encodedPath(THAILAND_PATH_SEASON)
.appendQueryParameter("s_locale", "zh_SG")
.appendQueryParameter("access_key", instance.getCustomizeAccessKey("th_server"))
.appendQueryParameter("mobi_app", "bstar_a")
.appendQueryParameter("build", "1080003")
.appendQueryParameter("season_id", seasonId.toString())
.appendQueryParameter("ep_id", info.getOrDefault("ep_id", "0"))
getContent(builder.toString(), mobiApp)?.toJSONObject()?.also {
it.optJSONObject("result")?.let { result ->
fixThailandSeason(result)
Expand Down Expand Up @@ -178,7 +180,8 @@ object BiliRoamingApi {
val thUrl = sPrefs.getString("th_server", null) ?: return null
val uri = Uri.Builder()
.scheme("https")
.encodedAuthority(thUrl + THAILAND_PATH_SUBTITLES)
.encodedAuthority(thUrl)
.encodedPath(THAILAND_PATH_SUBTITLES)
.appendQueryParameter("ep_id", epId)
.toString()
return getContent(uri)
Expand All @@ -192,7 +195,8 @@ object BiliRoamingApi {
val hostUrl = sPrefs.getString(area + "_server", null) ?: return null
val uri = Uri.Builder()
.scheme("https")
.encodedAuthority(hostUrl + BILI_SEARCH_URL)
.encodedAuthority(hostUrl)
.encodedPath(BILI_SEARCH_URL)
.encodedQuery(
signQuery(
query, mapOf(
Expand All @@ -211,7 +215,8 @@ object BiliRoamingApi {
val thUrl = sPrefs.getString("th_server", null) ?: return null
val uri = Uri.Builder()
.scheme("https")
.encodedAuthority(thUrl + THAILAND_PATH_SEARCH)
.encodedAuthority(thUrl)
.encodedPath(THAILAND_PATH_SEARCH)
.encodedQuery(
signQuery(
query, mapOf(
Expand Down Expand Up @@ -464,7 +469,8 @@ object BiliRoamingApi {
val path = if (area == "th") THAILAND_PATH_PLAYURL else PATH_PLAYURL
val uri = Uri.Builder()
.scheme("https")
.encodedAuthority(host + path)
.encodedAuthority(host)
.encodedPath(path)
.encodedQuery(signQuery(queryString, extraMap))
.toString()
getContent(uri, mobiApp)?.let {
Expand Down

0 comments on commit 76dfd9e

Please sign in to comment.