Skip to content

Commit 225d831

Browse files
TinyHaiyujincheng08
authored andcommitted
a small fix
1 parent c90c935 commit 225d831

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

app/src/main/java/me/iacn/biliroaming/hook/LiveQualityHook.kt

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,25 @@ class LiveQualityHook(classLoader: ClassLoader) : BaseHook(classLoader) {
112112

113113
debug { "originalLiveUrl: $originalUri" }
114114

115-
newQn = findQuality(
116-
JSONArray(originalUri.getQueryParameter("accept_quality")),
117-
liveQuality
118-
).toString()
119-
debug { "newQn: $newQn" }
120-
121-
param.args[0] = originalUri.removeQuery { name ->
122-
name.startsWith("playurl")
123-
}.also {
124-
debug { "newLiveUrl: $it" }
115+
if (originalUri.getQueryParameter("no_playurl") == "1") {
116+
newQn = liveQuality.toString()
117+
} else {
118+
newQn = findQuality(
119+
JSONArray(originalUri.getQueryParameter("accept_quality")),
120+
liveQuality
121+
).toString()
122+
123+
param.args[0] = originalUri.modified(
124+
removeIf = { name ->
125+
name.startsWith("playurl")
126+
},
127+
append = mapOf("no_playurl" to "1")
128+
).also {
129+
debug { "newLiveUrl: $it" }
130+
}
125131
}
132+
133+
debug { "newQn: $newQn" }
126134
}
127135
}
128136

@@ -143,14 +151,17 @@ class LiveQualityHook(classLoader: ClassLoader) : BaseHook(classLoader) {
143151
}
144152
}
145153

146-
private fun Uri.removeQuery(predicate: (String) -> Boolean): Uri {
154+
private fun Uri.modified(removeIf: (String) -> Boolean, append: Map<String, Any>): Uri {
147155
val newBuilder = buildUpon().clearQuery()
148156
for (name in queryParameterNames) {
149157
val value = getQueryParameter(name) ?: ""
150-
if (!predicate(name)) {
158+
if (!removeIf(name)) {
151159
newBuilder.appendQueryParameter(name, value)
152160
}
153161
}
162+
append.forEach { (k, v) ->
163+
newBuilder.appendQueryParameter(k, v.toString())
164+
}
154165
return newBuilder.build()
155166
}
156167

0 commit comments

Comments
 (0)