Skip to content

Commit

Permalink
✨ music 音乐自定义分享 (#533)
Browse files Browse the repository at this point in the history
1. 酷我音乐音乐直链url和参数修改,添加音乐卡片自定义参数。
2. 酷狗音乐添加音乐卡片自定义参数。
  • Loading branch information
kirbystudy committed Dec 15, 2022
1 parent a1f1016 commit c304d72
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions plugin/music/selecter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,20 @@ func kuwo(keyword string) message.MessageSegment {
}.Encode()
info := gjson.ParseBytes(netGet(search.String(), headers)).Get("data.list.0")
// 获得音乐直链
music, _ := url.Parse("http://www.kuwo.cn/url")
music, _ := url.Parse("http://www.kuwo.cn/api/v1/www/music/playUrl")
music.RawQuery = url.Values{
"format": []string{"mp3"},
"rid": []string{fmt.Sprintf("%d", info.Get("rid").Int())},
"response": []string{"url"},
"mid": []string{fmt.Sprintf("%d", info.Get("rid").Int())},
"type": []string{"convert_url3"},
"br": []string{"128kmp3"},
"from": []string{"web"},
"br": []string{"320kmp3"},
"httpsStatus": []string{"1"},
}.Encode()
audio := gjson.ParseBytes(netGet(music.String(), headers))
// 返回音乐卡片
return message.CustomMusic(
fmt.Sprintf("https://www.kuwo.cn/play_detail/%d", info.Get("rid").Int()),
audio.Get("url").Str,
audio.Get("data.url").Str,
info.Get("name").Str,
).Add("content", info.Get("artist").Str).Add("image", info.Get("pic").Str)
).Add("content", info.Get("artist").Str).Add("image", info.Get("pic").Str).Add("subtype", "kuwo")
}

// kugou 返回酷狗音乐卡片
Expand Down Expand Up @@ -133,7 +130,7 @@ func kugou(keyword string) message.MessageSegment {
"https://www.kugou.com/song/#hash="+audio.Get("hash").Str+"&album_id="+audio.Get("album_id").Str,
strings.ReplaceAll(audio.Get("play_backup_url").Str, "\\/", "/"),
audio.Get("audio_name").Str,
).Add("content", audio.Get("author_name").Str).Add("image", audio.Get("img").Str)
).Add("content", audio.Get("author_name").Str).Add("image", audio.Get("img").Str).Add("subtype", "kugou")
}

// cloud163 返回网易云音乐卡片
Expand Down

0 comments on commit c304d72

Please sign in to comment.