diff --git a/README.md b/README.md index 540fd26d..74a8e8bb 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,11 @@ >重载插件 ## 播放VIP歌曲 -1. 在插件配置文件的`LoginUser`填写手机号 -2. 重载插件或者重启服务器 -3. 输入/music code 获取手机验证码 -4. 输入/music login 验证码 登录账户 +1. 手机号创建网易云账户并购买网易云音乐VIP +2. 在插件配置文件的`LoginUser`填写手机号 +3. 重载插件或者重启服务器 +4. 输入/music code 获取手机验证码 +5. 输入/music login 验证码 登录账户 如果登录失效,请删除`cookie.json`再打`/music reload` diff --git a/build.gradle b/build.gradle index 56ca90f6..f6b4d292 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'maven-publish' id 'com.github.johnrengelman.shadow' version '6.1.0' } -version = "2.17.5" +version = "2.17.6" repositories { mavenCentral() diff --git a/src/main/java/coloryr/allmusic/AllMusic.java b/src/main/java/coloryr/allmusic/AllMusic.java index f700c204..3fa27e23 100644 --- a/src/main/java/coloryr/allmusic/AllMusic.java +++ b/src/main/java/coloryr/allmusic/AllMusic.java @@ -39,7 +39,7 @@ public class AllMusic { /** * 插件版本号 */ - public static final String version = "2.17.5"; + public static final String version = "2.17.6"; /** * 配置文件版本号 */ diff --git a/src/main/java/coloryr/allmusic/music/play/LyricDo.java b/src/main/java/coloryr/allmusic/music/play/LyricDo.java index 29f49a39..852a7879 100644 --- a/src/main/java/coloryr/allmusic/music/play/LyricDo.java +++ b/src/main/java/coloryr/allmusic/music/play/LyricDo.java @@ -52,7 +52,7 @@ public class LyricDo { if (temp2 != null && !temp2.isEmpty()) { String[] klyric = temp2.split("\n"); for (String item : klyric) { - Map temp4 = getKTime(item); + Map temp4 = getKTime(item, obj.getVersion()); if (temp4 != null) { kly.putAll(temp4); } @@ -119,7 +119,7 @@ public class LyricDo { return res; } - private Map getKTime(String lyric) { + private Map getKTime(String lyric, boolean yrc) { Map res = new LinkedHashMap<>(); if (!lyric.startsWith("[") || !lyric.contains("](")) return null; @@ -134,19 +134,28 @@ public class LyricDo { for (int a = 1; a < temp1.length; a++) { String time = temp1[a]; int temp2 = time.indexOf(')'); - String temp3 = time.substring(2, temp2); - int temp7 = Function.countChar(temp3, ','); + String temp3 = time.substring(0, temp2); + String[] temp8 = temp3.split(","); int temp5; - if (temp7 == 2) { - String[] temp8 = temp3.split(","); - temp5 = (Integer.parseInt(temp8[1]) / 10 * 10); - } else { - temp5 = (Integer.parseInt(temp3) / 10 * 10); + if (yrc) { + temp5 = (Integer.parseInt(temp8[0]) / 10 * 10); + if (temp5 > 0 && temp5 + AllMusic.getConfig().KDelay > 0) + temp5 += (AllMusic.getConfig().KDelay / 10 * 10); + res.put(temp5, time.substring(temp2 + 1)); + } else { + try { + temp5 = (Integer.parseInt(temp8[1]) / 10 * 10); + } catch (Exception e) { + AllMusic.log.warning("不支持的Ktv歌词"); + AllMusic.log.warning("请带上音乐ID联系开发者"); + return null; + } + + if (temp5 > 0 && temp5 + AllMusic.getConfig().KDelay > 0) + temp5 += (AllMusic.getConfig().KDelay / 10 * 10); + res.put(now, time.substring(temp2 + 1)); + now += temp5; } - if (temp5 > 0 && temp5 + AllMusic.getConfig().KDelay > 0) - temp5 += (AllMusic.getConfig().KDelay / 10 * 10); - res.put(now, time.substring(temp2 + 1)); - now += temp5; } return res; diff --git a/src/main/java/coloryr/allmusic/objs/api/music/lyric/WLyricOBJ.java b/src/main/java/coloryr/allmusic/objs/api/music/lyric/WLyricOBJ.java index 581b6ea7..12fb86d5 100644 --- a/src/main/java/coloryr/allmusic/objs/api/music/lyric/WLyricOBJ.java +++ b/src/main/java/coloryr/allmusic/objs/api/music/lyric/WLyricOBJ.java @@ -34,6 +34,10 @@ public class WLyricOBJ { return yrc.getLyric(); } + public boolean getVersion(){ + return yrc != null; + } + public boolean isNone() { return nolyric || uncollected; } @@ -58,7 +62,11 @@ class tlyric { class klyric { private String lyric; + private int version; + public int getVersion() { + return version; + } public String getLyric() { return lyric == null ? "" : lyric; } @@ -66,8 +74,13 @@ class klyric class yrc { + private int version; private String lyric; + public int getVersion() { + return version; + } + public String getLyric() { return lyric == null ? "" : lyric; } diff --git a/src/test/java/RunTest.java b/src/test/java/RunTest.java index dde2b95a..8791e42f 100644 --- a/src/test/java/RunTest.java +++ b/src/test/java/RunTest.java @@ -13,7 +13,7 @@ public class RunTest implements IMyLogger { // { // // } - LyricSave obj = AllMusic.getMusicApi().getLyric("26201959"); + LyricSave obj = AllMusic.getMusicApi().getLyric("1449790719"); if (obj.isHaveLyric()) { int time = 0; while (true) {