This commit is contained in:
Coloryr committed 2020-03-02 12:15:58 +08:00
1 parent b988cedbda
commit e4d72cd53f
6 files changed
+28 -35

No files matched your search

@@ -56,6 +56,9 @@ public class CommandEX {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music list 查看歌曲队列");
ALLMusic.Side.SendMessage(sender, "§d[ALLmusic]§2使用/music vote 投票切歌");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music nomusic 不再参与点歌");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music v [音量] 调节音量");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music search [歌名] 搜索歌曲");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music select [序列] 选择歌曲");
} else if (args[0].equalsIgnoreCase("stop")) {
ALLMusic.Side.Send("[Stop]", Name, false);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已停止" + Name + "的音乐播放");
@@ -136,6 +139,7 @@ public class CommandEX {
if (!search.isDone())
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c无法搜索歌曲:" + args[1]);
else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2搜索结果");
ALLMusic.Side.SendMessage(sender, "§2" + search.GetInfo());
PlayerSearch.SearchSave.put(Name, search);
}
+18 -31
View File
@@ -6,14 +6,15 @@ import javazoom.jl.decoder.Header;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class Get {
public static int getMusicTime(String music) {
try {
URL urlfile = new URL(music);
@@ -31,42 +32,34 @@ public class Get {
}
public static String realURL(String path) {
HttpURLConnection connection = null;
try {
URL realUrl = new URL(path);
connection = (HttpURLConnection) realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
connection.connect();
connection.getContent();
return connection.getURL().toString();
} catch (IOException e) {
if (connection == null) {
ALLMusic.log.warning("§d[ALLMusic]§c获取网页错误");
e.printStackTrace();
return null;
}
} catch (NullPointerException e) {
} catch (Exception e) {
ALLMusic.log.warning("§d[ALLMusic]§c获取网页错误");
e.printStackTrace();
}
return null;
}
public static String realData(String path) {
HttpURLConnection connection = null;
public static String realData(String path, String data) {
try {
URL realUrl = new URL(path);
connection = (HttpURLConnection) realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
data = URLEncoder.encode(data, "UTF-8");
URL realUrl = new URL(path + data);
HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(4 * 1000);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.connect();
connection.getContent();
InputStream inputStream = connection.getInputStream();
InputStream inputStream;
if (connection.getResponseCode() >= 400) {
inputStream = connection.getErrorStream();
} else {
inputStream = connection.getInputStream();
}
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
@@ -74,13 +67,7 @@ public class Get {
result.write(buffer, 0, length);
}
return result.toString(StandardCharsets.UTF_8.name());
} catch (IOException e) {
if (connection == null) {
ALLMusic.log.warning("§d[ALLMusic]§c获取网页错误");
e.printStackTrace();
return null;
}
} catch (NullPointerException e) {
} catch (Exception e) {
ALLMusic.log.warning("§d[ALLMusic]§c获取网页错误");
e.printStackTrace();
}
@@ -78,7 +78,7 @@ class PlayGo extends Thread {
PlayMusic.haveLyric = false;
ALLMusic.Side.SendLyric("");
String songURL = Get.realURL(ALLMusic.Config.getMusic_Api1() + PlayMusic.NowPlayMusic.getID());
String Lyric = Get.realData(ALLMusic.Config.getLyric_Api1() + PlayMusic.NowPlayMusic.getID());
String Lyric = Get.realData(ALLMusic.Config.getLyric_Api1(), PlayMusic.NowPlayMusic.getID());
if (Lyric != null) {
try {
PlayMusic.Lyric = new LyricDo(Lyric);
@@ -13,7 +13,7 @@ public class GetList {
public static void GetL(String ID) {
Thread thread = new Thread(() ->
{
String data = Get.realData(ALLMusic.Config.getList_Api1() + ID);
String data = Get.realData(ALLMusic.Config.getList_Api1(), ID);
if (data != null)
try {
isUpdata = true;
@@ -16,7 +16,9 @@ public class Search {
for (int a = 1; a < name.length; a++) {
name1.append(name[a]).append(" ");
}
String data = Get.realData(ALLMusic.Config.getSearch_Api1() + name1.toString());
String data = name1.toString();
data = data.substring(0, data.length() - 1);
data = Get.realData(ALLMusic.Config.getSearch_Api1() , data);
if (data != null) {
DataOBJ obj = new Gson().fromJson(data, DataOBJ.class);
if (obj != null && obj.getResult() != null) {
@@ -6,7 +6,7 @@ import com.google.gson.Gson;
public class GetInfo {
public static SongInfo Get(String ID, String player) {
String data = Get.realData(ALLMusic.Config.getInfo_Api1() + ID);
String data = Get.realData(ALLMusic.Config.getInfo_Api1(), ID);
SongInfo info = new SongInfo(null, null, ID, null, player);
if (data != null) {
InfoOBJ temp = new Gson().fromJson(data, InfoOBJ.class);