Skip to content

Commit

Permalink
feat: add unique_k parameter to share (#1274)
Browse files Browse the repository at this point in the history
  • Loading branch information
keta1 authored Sep 27, 2023
1 parent 2bb5b25 commit 8a19697
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/src/main/java/me/iacn/biliroaming/hook/ShareHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,24 @@ class ShareHook(classLoader: ClassLoader) : BaseHook(classLoader) {
?.firstOrNull { it.startsWith("BV") && it.length == 12 }
else null
val av = bv?.let { "av${bv2av(bv)}" }
val query = target.encodedQuery?.split("&")?.map {
it.split("=")
}?.filter {
it.size == 2
}?.mapNotNull {
if (it[0] == "p" || it[0] == "t") "${it[0]}=${it[1]}"
else if (it[0] == "start_progress") "start_progress=${it[1]}&t=${it[1].toLong() / 1000}"
else null
}?.joinToString("&")
val newUrl = target.buildUpon()
if (av != null) {
newUrl.path(target.path!!.replace(bv, av))
}
if (query != null) {
val encodedQuery = target.encodedQuery
if (encodedQuery != null) {
val query = encodedQuery.split("&").map {
it.split("=")
}.filter {
it.size == 2
}.mapNotNull {
if (it[0] == "p" || it[0] == "t") "${it[0]}=${it[1]}"
else if (it[0] == "start_progress") "start_progress=${it[1]}&t=${it[1].toLong() / 1000}"
else null
}.joinToString("&", postfix = "&unique_k=114514")
newUrl.encodedQuery(query)
} else {
newUrl.appendQueryParameter("unique_k", "114514")
}
return newUrl.build().toString()
}
Expand Down

0 comments on commit 8a19697

Please sign in to comment.