From 76dfd9e6657889d89e7d52754a0f349989c61569 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sat, 13 Jan 2024 22:46:12 +0800 Subject: [PATCH] Clean up codes --- .../iacn/biliroaming/network/BiliRoamingApi.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/me/iacn/biliroaming/network/BiliRoamingApi.kt b/app/src/main/java/me/iacn/biliroaming/network/BiliRoamingApi.kt index cbcba07de5..e1ec5edec6 100644 --- a/app/src/main/java/me/iacn/biliroaming/network/BiliRoamingApi.kt +++ b/app/src/main/java/me/iacn/biliroaming/network/BiliRoamingApi.kt @@ -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) @@ -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) @@ -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( @@ -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( @@ -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 {