diff --git a/pom.xml b/pom.xml
index 5733fea..bd0df80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.khjxiaogu
MiraiSongPlugin
- 1.1.4
+ 1.1.5
MiraiSongPlugin
使用“#音乐 关键词”、“#QQ 关键词”、“#网易 关键词”等方式进行点歌的插件。
diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/cardprovider/AmrVoiceProvider.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/cardprovider/AmrVoiceProvider.java
index 1df40c6..6a64caf 100644
--- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/cardprovider/AmrVoiceProvider.java
+++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/cardprovider/AmrVoiceProvider.java
@@ -7,6 +7,7 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLConnection;
import java.util.Map;
import com.khjxiaogu.MiraiSongPlugin.MusicCardProvider;
@@ -32,13 +33,12 @@ public AmrVoiceProvider() {
@Override
public Message process(MusicInfo mi, Contact ct) {
- HttpURLConnection huc2 = null;
+ URLConnection huc2 = null;
try {
- huc2 = (HttpURLConnection) new URL(mi.murl).openConnection();
+ huc2 = new URL(mi.murl).openConnection();
if (mi.properties != null)
for (Map.Entry me : mi.properties.entrySet())
huc2.addRequestProperty(me.getKey(), me.getValue());
- huc2.setRequestMethod("GET");
huc2.connect();
} catch (IOException e) {
return new PlainText("获取音频失败");
diff --git a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java
index 25c373e..5b1bb81 100644
--- a/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java
+++ b/src/main/java/com/khjxiaogu/MiraiSongPlugin/musicsource/NetEaseRadioSource.java
@@ -5,6 +5,7 @@
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import com.google.gson.JsonArray;
@@ -93,7 +94,17 @@ public MusicInfo get(String keyword) throws Exception {
public MusicInfo get(String keyword, String songname) throws Exception {
- URL url = new URL("http://music.163.com/api/search/pc");
+ JsonObject params = new JsonObject();
+ params.add("s", new JsonPrimitive(URLDecoder.decode(keyword, "UTF-8")));
+ params.add("type",new JsonPrimitive(1009));
+ params.add("offset",new JsonPrimitive(0));
+ params.add("limit",new JsonPrimitive(3));
+ String[] encrypt = NetEaseCrypto.weapiEncrypt(params.toString());
+ StringBuilder sb = new StringBuilder("params=");
+ sb.append(encrypt[0]);
+ sb.append("&encSecKey=");
+ sb.append(encrypt[1]);
+ URL url = new URL("https://music.163.com/weapi/cloudsearch/get/web?csrf_token=");
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
huc.setDoInput(true);
huc.setDoOutput(true);
@@ -102,8 +113,7 @@ public MusicInfo get(String keyword, String songname) throws Exception {
huc.setRequestProperty("Cookie", "appver=1.5.0.75771;");
huc.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
huc.connect();
-
- huc.getOutputStream().write(("type=1009&offset=0&limit=1&s=" + keyword).getBytes(StandardCharsets.UTF_8));
+ huc.getOutputStream().write(sb.toString().getBytes(StandardCharsets.UTF_8));
JsonArray ja;
String murl;
if (huc.getResponseCode() == 200) {