Skip to content

Commit 58631c5

Browse files
authored
⚡️update music (#535)
* ⚡️update music 添加咪咕点歌 * ⚡️update music 添加咪咕点歌功能
1 parent e994768 commit 58631c5

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

plugin/music/selecter.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package music QQ音乐、网易云、酷狗、酷我 点歌
1+
// Package music QQ音乐、网易云、酷狗、酷我、咪咕 点歌
22
package music
33

44
import (
@@ -28,11 +28,14 @@ func init() {
2828
Help: "- 点歌[xxx]\n" +
2929
"- 网易点歌[xxx]\n" +
3030
"- 酷我点歌[xxx]\n" +
31-
"- 酷狗点歌[xxx]",
31+
"- 酷狗点歌[xxx]\n" +
32+
"- 咪咕点歌[xxx]",
3233
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).Limit(ctxext.LimitByUser).
3334
Handle(func(ctx *zero.Ctx) {
3435
// switch 平台
3536
switch ctx.State["regex_matched"].([]string)[1] {
37+
case "咪咕":
38+
ctx.SendChain(migu(ctx.State["regex_matched"].([]string)[2]))
3639
case "酷我":
3740
ctx.SendChain(kuwo(ctx.State["regex_matched"].([]string)[2]))
3841
case "酷狗":
@@ -45,6 +48,32 @@ func init() {
4548
})
4649
}
4750

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+
4877
// kuwo 返回酷我音乐卡片
4978
func kuwo(keyword string) message.MessageSegment {
5079
headers := http.Header{

0 commit comments

Comments
 (0)