File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,10 +59,22 @@ func init() {
5959func longzhu (keyword string ) message.Segment {
6060 data , _ := web .GetData (fmt .Sprintf (longZhuURL , url .QueryEscape (keyword )))
6161 // 假设 data 是包含整个 JSON 数组的字节切片
62- result := gjson .GetBytes (data , "#.full_track" )
63- // 取第一个非空的 full_track 链接
64- firstFullTrack := result .Array ()[0 ].String ()
65- return message .Record (firstFullTrack )
62+ results := gjson .ParseBytes (data ).Array ()
63+ for _ , result := range results {
64+ if strings .Contains (strings .ToLower (result .Get ("title" ).String ()), strings .ToLower (keyword )) {
65+ if musicURL := result .Get ("full_track" ).String (); musicURL != "" {
66+ return message .Record (musicURL )
67+ }
68+ }
69+ }
70+
71+ if len (results ) > 0 {
72+ if musicURL := results [0 ].Get ("full_track" ).String (); musicURL != "" {
73+ return message .Record (musicURL )
74+ }
75+ }
76+
77+ return message .Text ("点歌失败, 找不到 " , keyword , " 的相关结果" )
6678}
6779
6880// migu 返回咪咕音乐卡片
You can’t perform that action at this time.
0 commit comments