1
- // Package music QQ音乐、网易云、酷狗、酷我 点歌
1
+ // Package music QQ音乐、网易云、酷狗、酷我、咪咕 点歌
2
2
package music
3
3
4
4
import (
@@ -28,11 +28,14 @@ func init() {
28
28
Help : "- 点歌[xxx]\n " +
29
29
"- 网易点歌[xxx]\n " +
30
30
"- 酷我点歌[xxx]\n " +
31
- "- 酷狗点歌[xxx]" ,
31
+ "- 酷狗点歌[xxx]\n " +
32
+ "- 咪咕点歌[xxx]" ,
32
33
}).OnRegex (`^(.{0,2})点歌\s?(.{1,25})$` ).SetBlock (true ).Limit (ctxext .LimitByUser ).
33
34
Handle (func (ctx * zero.Ctx ) {
34
35
// switch 平台
35
36
switch ctx .State ["regex_matched" ].([]string )[1 ] {
37
+ case "咪咕" :
38
+ ctx .SendChain (migu (ctx .State ["regex_matched" ].([]string )[2 ]))
36
39
case "酷我" :
37
40
ctx .SendChain (kuwo (ctx .State ["regex_matched" ].([]string )[2 ]))
38
41
case "酷狗" :
@@ -45,6 +48,32 @@ func init() {
45
48
})
46
49
}
47
50
51
+ // migu 返回咪咕音乐卡片
52
+ func migu (keyword string ) message.MessageSegment {
53
+ headers := http.Header {
54
+ "Cookie" : []string {"audioplayer_exist=1; audioplayer_open=0; migu_cn_cookie_id=3ad476db-f021-4bda-ab91-c485ac3d56a0; Hm_lvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; Hm_lpvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; WT_FPC=id=279ef92eaf314cbb8d01671116477485:lv=1671119583092:ss=1671116477485" },
55
+ "csrf" : []string {"LWKACV45JSQ" },
56
+ "User-Agent" : []string {"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" },
57
+ "Referer" : []string {"http://m.music.migu.cn" },
58
+ "proxy" : []string {"false" },
59
+ }
60
+ // 搜索音乐信息 第一首歌
61
+ search , _ := url .Parse ("http://m.music.migu.cn/migu/remoting/scr_search_tag" )
62
+ search .RawQuery = url.Values {
63
+ "keyword" : []string {keyword },
64
+ "type" : []string {"2" },
65
+ "pgc" : []string {"1" },
66
+ "rows" : []string {"10" },
67
+ }.Encode ()
68
+ info := gjson .ParseBytes (netGet (search .String (), headers )).Get ("musics.0" )
69
+ // 返回音乐卡片
70
+ return message .CustomMusic (
71
+ fmt .Sprintf ("https://music.migu.cn/v3/music/song/%s" , info .Get ("copyrightId" ).String ()),
72
+ info .Get ("mp3" ).String (),
73
+ info .Get ("songName" ).String (),
74
+ ).Add ("content" , info .Get ("artist" ).Str ).Add ("image" , info .Get ("cover" ).Str ).Add ("subtype" , "migu" )
75
+ }
76
+
48
77
// kuwo 返回酷我音乐卡片
49
78
func kuwo (keyword string ) message.MessageSegment {
50
79
headers := http.Header {
0 commit comments