mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-20 13:29:37 +00:00
clean
This commit is contained in:
1 parent
b6ce0bf3f5
commit
f4fd9b62ca
16 files changed
+146
-335
No files matched your search
@@ -62,28 +62,6 @@ public class ALLMusic {
|
||||
return Config;
|
||||
}
|
||||
|
||||
public static int getPlayListSize() {
|
||||
return PlayMusic.PlayList.size();
|
||||
}
|
||||
|
||||
public static void removeList(int index) {
|
||||
PlayMusic.PlayList.remove(index);
|
||||
}
|
||||
|
||||
public static void addPlayList(SongInfo song) {
|
||||
PlayMusic.PlayList.add(song);
|
||||
}
|
||||
|
||||
public static SongInfo getFirst() {
|
||||
SongInfo info = PlayMusic.PlayList.get(0);
|
||||
PlayMusic.PlayList.remove(0);
|
||||
return info;
|
||||
}
|
||||
|
||||
public static SongInfo getList(int index) {
|
||||
return PlayMusic.PlayList.get(index);
|
||||
}
|
||||
|
||||
public static MessageOBJ getMessage() {
|
||||
return Message;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ public class CommandEX {
|
||||
if (PlayMusic.getSize() == 0) {
|
||||
ALLMusic.Side.SendMessage(sender, ALLMusic.getMessage().getMusicPlay().getNoPlay());
|
||||
} else {
|
||||
ALLMusic.Side.SendMessage(sender, ALLMusic.getMessage().getMusicPlay().getListMusic().getHead().replace("&Count&", "" + ALLMusic.getPlayListSize()));
|
||||
ALLMusic.Side.SendMessage(sender, ALLMusic.getMessage().getMusicPlay().getListMusic().getHead()
|
||||
.replace("&Count&", "" + PlayMusic.getSize()));
|
||||
ALLMusic.Side.SendMessage(sender, PlayMusic.getAllList());
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("vote")) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Color_yr.ALLMusic.MusicAPI;
|
||||
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
|
||||
public interface IMusic {
|
||||
@@ -11,7 +11,7 @@ public interface IMusic {
|
||||
|
||||
void SetList(String ID, Object sender);
|
||||
|
||||
LyricDo getLyric(String ID);
|
||||
LyricSave getLyric(String ID);
|
||||
|
||||
SearchPage Search(String[] name);
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo.PlayOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicList.DataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric.LyricCheck;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric.LyricOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch.songs;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import com.google.gson.Gson;
|
||||
@@ -86,14 +87,15 @@ public class API1 implements IMusic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricDo getLyric(String ID) {
|
||||
LyricDo Lyric = new LyricDo();
|
||||
public LyricSave getLyric(String ID) {
|
||||
LyricSave Lyric = new LyricSave();
|
||||
Res res = HttpGet.realData("https://api.imjad.cn/cloudmusic/?type=lyric&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricCheck temp = new LyricCheck(res.getData());
|
||||
LyricOBJ obj = new Gson().fromJson(res.getData(), LyricOBJ.class);
|
||||
LyricDo temp = new LyricDo();
|
||||
for (int times = 0; times < 3; times++) {
|
||||
if (!temp.Check()) {
|
||||
if (temp.Check(obj)) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
} else {
|
||||
Lyric.setHaveLyric(ALLMusic.getConfig().isSendLyric());
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricCheck {
|
||||
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
private LyricOBJ obj;
|
||||
|
||||
public LyricCheck(String obj) {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
String[] lyric;
|
||||
|
||||
boolean haveT = false;
|
||||
if (!obj.isok())
|
||||
return false;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
Tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
haveT = true;
|
||||
}
|
||||
Map<Integer, String> temp = GetTime(Arrays.asList(lyric));
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
if (Function.countChar(Function.getString(s, "[", "]"), ':') > 1) {
|
||||
String[] a = s.split(":");
|
||||
min = a[0].substring(1);
|
||||
sec = a[1];
|
||||
mil = a[2];
|
||||
} else {
|
||||
min = Function.getString(s, "[", ":");
|
||||
sec = Function.getString(s, ":", ".");
|
||||
mil = Function.getString(s, ".", "]");
|
||||
}
|
||||
if (!Function.isInteger(min))
|
||||
continue;
|
||||
if (!Function.isInteger(sec))
|
||||
continue;
|
||||
if (!Function.isInteger(mil))
|
||||
continue;
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if (mil.length() == 3) {
|
||||
milt /= 10;
|
||||
}
|
||||
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
|
||||
if (time > 0 && time + ALLMusic.getConfig().getDelay() > 0)
|
||||
time += ALLMusic.getConfig().getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric;
|
||||
|
||||
public class LyricOBJ {
|
||||
private boolean sgc;
|
||||
private boolean sfy;
|
||||
private boolean qfy;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.Lyric;
|
||||
|
||||
public class LyricOBJ implements Lyric {
|
||||
private lrc lrc;
|
||||
private tlyric tlyric;
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo.PlayOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicList.DataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric.LyricCheck;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric.LyricOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch.songs;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import com.google.gson.Gson;
|
||||
@@ -86,14 +87,15 @@ public class API2 implements IMusic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricDo getLyric(String ID) {
|
||||
LyricDo Lyric = new LyricDo();
|
||||
public LyricSave getLyric(String ID) {
|
||||
LyricSave Lyric = new LyricSave();
|
||||
Res res = HttpGet.realData(ALLMusic.getConfig().getMusic_Api2() + "?type=lyric&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricCheck temp = new LyricCheck(res.getData());
|
||||
LyricOBJ obj = new Gson().fromJson(res.getData(), LyricOBJ.class);
|
||||
LyricDo temp = new LyricDo();
|
||||
for (int times = 0; times < 3; times++) {
|
||||
if (!temp.Check()) {
|
||||
if (temp.Check(obj)) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
} else {
|
||||
Lyric.setHaveLyric(ALLMusic.getConfig().isSendLyric());
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricCheck {
|
||||
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
private LyricOBJ obj;
|
||||
|
||||
public LyricCheck(String obj) {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
String[] lyric;
|
||||
|
||||
boolean haveT = false;
|
||||
if (!obj.isok())
|
||||
return false;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
Tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
haveT = true;
|
||||
}
|
||||
Map<Integer, String> temp = GetTime(Arrays.asList(lyric));
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
if (Function.countChar(Function.getString(s, "[", "]"), ':') > 1) {
|
||||
String[] a = s.split(":");
|
||||
min = a[0].substring(1);
|
||||
sec = a[1];
|
||||
mil = a[2];
|
||||
} else {
|
||||
min = Function.getString(s, "[", ":");
|
||||
sec = Function.getString(s, ":", ".");
|
||||
mil = Function.getString(s, ".", "]");
|
||||
}
|
||||
if (!Function.isInteger(min))
|
||||
continue;
|
||||
if (!Function.isInteger(sec))
|
||||
continue;
|
||||
if (!Function.isInteger(mil))
|
||||
continue;
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if (mil.length() == 3) {
|
||||
milt /= 10;
|
||||
}
|
||||
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
|
||||
if (time > 0 && time + ALLMusic.getConfig().getDelay() > 0)
|
||||
time += ALLMusic.getConfig().getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric;
|
||||
|
||||
public class LyricOBJ {
|
||||
private boolean sgc;
|
||||
private boolean sfy;
|
||||
private boolean qfy;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.Lyric;
|
||||
|
||||
public class LyricOBJ implements Lyric {
|
||||
private lrc lrc;
|
||||
private tlyric tlyric;
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicInfo.PlayOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicList.DataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicLyric.LyricCheck;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicLyric.LyricOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicSearch.songs;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import com.google.gson.Gson;
|
||||
@@ -86,14 +87,15 @@ public class API3 implements IMusic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricDo getLyric(String ID) {
|
||||
LyricDo Lyric = new LyricDo();
|
||||
public LyricSave getLyric(String ID) {
|
||||
LyricSave Lyric = new LyricSave();
|
||||
Res res = HttpGet.realData(ALLMusic.getConfig().getMusic_Api3() + "/lyric?id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricCheck temp = new LyricCheck(res.getData());
|
||||
LyricOBJ obj = new Gson().fromJson(res.getData(), LyricOBJ.class);
|
||||
LyricDo temp = new LyricDo();
|
||||
for (int times = 0; times < 3; times++) {
|
||||
if (!temp.Check()) {
|
||||
if (temp.Check(obj)) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
} else {
|
||||
Lyric.setHaveLyric(ALLMusic.getConfig().isSendLyric());
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricCheck {
|
||||
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
private LyricOBJ obj;
|
||||
|
||||
public LyricCheck(String obj) {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
String[] lyric;
|
||||
|
||||
boolean haveT = false;
|
||||
if (!obj.isok())
|
||||
return false;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
Tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
haveT = true;
|
||||
}
|
||||
Map<Integer, String> temp = GetTime(Arrays.asList(lyric));
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
if (Function.countChar(Function.getString(s, "[", "]"), ':') > 1) {
|
||||
String[] a = s.split(":");
|
||||
min = a[0].substring(1);
|
||||
sec = a[1];
|
||||
mil = a[2];
|
||||
} else {
|
||||
min = Function.getString(s, "[", ":");
|
||||
sec = Function.getString(s, ":", ".");
|
||||
mil = Function.getString(s, ".", "]");
|
||||
}
|
||||
if (!Function.isInteger(min))
|
||||
continue;
|
||||
if (!Function.isInteger(sec))
|
||||
continue;
|
||||
if (!Function.isInteger(mil))
|
||||
continue;
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if (mil.length() == 3) {
|
||||
milt /= 10;
|
||||
}
|
||||
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
|
||||
if (time > 0 && time + ALLMusic.getConfig().getDelay() > 0)
|
||||
time += ALLMusic.getConfig().getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI3.GetMusicLyric;
|
||||
|
||||
public class LyricOBJ {
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.Lyric;
|
||||
|
||||
public class LyricOBJ implements Lyric {
|
||||
private lrc lrc;
|
||||
private tlyric tlyric;
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.SongLyric;
|
||||
|
||||
public interface Lyric {
|
||||
boolean isok();
|
||||
|
||||
String getLyric();
|
||||
|
||||
String getTlyric();
|
||||
}
|
||||
@@ -1,31 +1,81 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.SongLyric;
|
||||
|
||||
import java.util.Map;
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricDo {
|
||||
private Map<Integer, ShowOBJ> Lyric;
|
||||
private boolean haveLyric = false;
|
||||
|
||||
public LyricDo() {
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public void setLyric(Map<Integer, ShowOBJ> lyric) {
|
||||
Lyric = lyric;
|
||||
public boolean Check(Lyric obj) {
|
||||
String[] lyric;
|
||||
|
||||
boolean haveT = false;
|
||||
if (!obj.isok())
|
||||
return true;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
Tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
haveT = true;
|
||||
}
|
||||
Map<Integer, String> temp = GetTime(Arrays.asList(lyric));
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isHaveLyric() {
|
||||
return haveLyric;
|
||||
}
|
||||
|
||||
public void setHaveLyric(boolean haveLyric) {
|
||||
this.haveLyric = haveLyric;
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric == null)
|
||||
return null;
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
if (Function.countChar(Function.getString(s, "[", "]"), ':') > 1) {
|
||||
String[] a = s.split(":");
|
||||
min = a[0].substring(1);
|
||||
sec = a[1];
|
||||
mil = a[2];
|
||||
} else {
|
||||
min = Function.getString(s, "[", ":");
|
||||
sec = Function.getString(s, ":", ".");
|
||||
mil = Function.getString(s, ".", "]");
|
||||
}
|
||||
if (!Function.isInteger(min))
|
||||
continue;
|
||||
if (!Function.isInteger(sec))
|
||||
continue;
|
||||
if (!Function.isInteger(mil))
|
||||
continue;
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if (mil.length() == 3) {
|
||||
milt /= 10;
|
||||
}
|
||||
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
|
||||
if (time > 0 && time + ALLMusic.getConfig().getDelay() > 0)
|
||||
time += ALLMusic.getConfig().getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.SongLyric;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LyricSave {
|
||||
private Map<Integer, ShowOBJ> Lyric;
|
||||
private boolean haveLyric = false;
|
||||
|
||||
public LyricSave() {
|
||||
}
|
||||
|
||||
public void setLyric(Map<Integer, ShowOBJ> lyric) {
|
||||
Lyric = lyric;
|
||||
}
|
||||
|
||||
public boolean isHaveLyric() {
|
||||
return haveLyric;
|
||||
}
|
||||
|
||||
public void setHaveLyric(boolean haveLyric) {
|
||||
this.haveLyric = haveLyric;
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric == null)
|
||||
return null;
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package Color_yr.ALLMusic.MusicPlay;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.logs;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PlayMusic {
|
||||
public static int MusicNowTime = 0;
|
||||
public static SongInfo NowPlayMusic;
|
||||
|
||||
public static LyricDo Lyric;
|
||||
public static LyricSave Lyric;
|
||||
public static ShowOBJ nowLyric;
|
||||
private static PlayGo PlayGo;
|
||||
|
||||
|
||||
Reference in new issue
Block a user