Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Commit 5645496

Browse files
committed
屏蔽 QQ 搜索,防止崩溃
1 parent 70f7ab7 commit 5645496

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/dirror/music/music/qq/SearchSong.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ object SearchSong {
1111
fun search(keywords: String, success: (ArrayList<StandardSongData>) -> Unit) {
1212
val url = "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?aggr=1&cr=1&flag_qc=0&p=1&n=20&w=${keywords}"
1313
MagicHttp.OkHttpManager().newGet(url, {
14-
var response = it.replace("callback(", "")
15-
if (response.endsWith(")")) {
16-
response = response.substring(0, response.lastIndex)
17-
}
18-
val qqSearch = Gson().fromJson(response, QQSearch::class.java)
19-
val standardSongList = ArrayList<StandardSongData>()
20-
if (qqSearch.data.song.list.isNotEmpty()) {
21-
for (song in qqSearch.data.song.list) {
22-
standardSongList.add(song.switchToStandard())
14+
try {
15+
var response = it.replace("callback(", "")
16+
if (response.endsWith(")")) {
17+
response = response.substring(0, response.lastIndex)
18+
}
19+
val qqSearch = Gson().fromJson(response, QQSearch::class.java)
20+
val standardSongList = ArrayList<StandardSongData>()
21+
if (qqSearch.data.song.list.isNotEmpty()) {
22+
for (song in qqSearch.data.song.list) {
23+
standardSongList.add(song.switchToStandard())
24+
}
2325
}
26+
success.invoke(standardSongList)
27+
} catch (e: Exception) {
28+
2429
}
25-
success.invoke(standardSongList)
2630
}, {
2731

2832
})

0 commit comments

Comments
 (0)