mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 04:18:56 +08:00
修复对存在错误时间标签的歌词的解析
This commit is contained in:
parent
2fcb560e91
commit
ffe8891202
@ -1,7 +1,5 @@
|
|||||||
package cn.toside.music.mobile.lyric;
|
package cn.toside.music.mobile.lyric;
|
||||||
|
|
||||||
import com.facebook.react.bridge.Promise;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -15,9 +13,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class LyricPlayer {
|
public class LyricPlayer {
|
||||||
final String timeFieldExp = "^(?:\\[[\\d:.]+])+";
|
final String timeFieldExp = "^(?:\\[[\\d:.]+])+";
|
||||||
final String timeExp = "[\\d:.]+";
|
final String timeExp = "\\d{1,3}(:\\d{1,3}){0,2}(?:\\.\\d{1,3})";
|
||||||
final String timeLabelRxp = "^(\\[[\\d:]+\\.)0+(\\d+])";
|
|
||||||
final String timeLabelFixRxp = "(?:\\.0+|0+)$";
|
|
||||||
// HashMap tagRegMap;
|
// HashMap tagRegMap;
|
||||||
Pattern timeFieldPattern;
|
Pattern timeFieldPattern;
|
||||||
Pattern timePattern;
|
Pattern timePattern;
|
||||||
@ -117,6 +113,16 @@ public class LyricPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final String t_rxp_1 = "^0+(\\d+)";
|
||||||
|
final String t_rxp_2 = ":0+(\\d+)";
|
||||||
|
final String t_rxp_3 = "\\.0+(\\d+)";
|
||||||
|
private String formatTimeLabel(String label) {
|
||||||
|
return label.replaceAll(t_rxp_1, "$1")
|
||||||
|
.replaceAll(t_rxp_2, ":$1")
|
||||||
|
.replaceAll(t_rxp_3, ".$1");
|
||||||
|
}
|
||||||
|
|
||||||
private void parseExtendedLyric(HashMap linesMap, String extendedLyric) {
|
private void parseExtendedLyric(HashMap linesMap, String extendedLyric) {
|
||||||
String[] extendedLyricLines = extendedLyric.split("\r\n|\n|\r");
|
String[] extendedLyricLines = extendedLyric.split("\r\n|\n|\r");
|
||||||
for (String translationLine : extendedLyricLines) {
|
for (String translationLine : extendedLyricLines) {
|
||||||
@ -129,9 +135,7 @@ public class LyricPlayer {
|
|||||||
Matcher timeMatchResult = timePattern.matcher(timeField);
|
Matcher timeMatchResult = timePattern.matcher(timeField);
|
||||||
while (timeMatchResult.find()) {
|
while (timeMatchResult.find()) {
|
||||||
String timeStr = timeMatchResult.group();
|
String timeStr = timeMatchResult.group();
|
||||||
if (timeStr.contains(".")) timeStr = timeStr.replaceAll(timeLabelRxp, "$1$2");
|
timeStr = formatTimeLabel(timeStr);
|
||||||
else timeStr += ".0";
|
|
||||||
timeStr = timeStr.replaceAll(timeLabelFixRxp, "");
|
|
||||||
HashMap targetLine = (HashMap) linesMap.get(timeStr);
|
HashMap targetLine = (HashMap) linesMap.get(timeStr);
|
||||||
if (targetLine != null) ((ArrayList<String>) targetLine.get("extendedLyrics")).add(text);
|
if (targetLine != null) ((ArrayList<String>) targetLine.get("extendedLyrics")).add(text);
|
||||||
}
|
}
|
||||||
@ -156,10 +160,7 @@ public class LyricPlayer {
|
|||||||
if (text.length() > 0) {
|
if (text.length() > 0) {
|
||||||
Matcher timeMatchResult = timePattern.matcher(timeField);
|
Matcher timeMatchResult = timePattern.matcher(timeField);
|
||||||
while (timeMatchResult.find()) {
|
while (timeMatchResult.find()) {
|
||||||
String timeStr = timeMatchResult.group();
|
String timeStr = formatTimeLabel(timeMatchResult.group());
|
||||||
if (timeStr.contains(".")) timeStr = timeStr.replaceAll(timeLabelRxp, "$1$2");
|
|
||||||
else timeStr += ".0";
|
|
||||||
timeStr = timeStr.replaceAll(timeLabelFixRxp, "");
|
|
||||||
if (linesMap.containsKey(timeStr)) {
|
if (linesMap.containsKey(timeStr)) {
|
||||||
((ArrayList<String>) ((HashMap) linesMap.get(timeStr)).get("extendedLyrics")).add(text);
|
((ArrayList<String>) ((HashMap) linesMap.get(timeStr)).get("extendedLyrics")).add(text);
|
||||||
continue;
|
continue;
|
||||||
@ -180,13 +181,18 @@ public class LyricPlayer {
|
|||||||
minutes = timeArr[0];
|
minutes = timeArr[0];
|
||||||
seconds = timeArr[1];
|
seconds = timeArr[1];
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
hours = "0";
|
||||||
|
minutes = "0";
|
||||||
|
seconds = timeArr[0];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (seconds.contains(".")) {
|
if (seconds.contains(".")) {
|
||||||
timeArr = seconds.split("\\.");
|
timeArr = seconds.split("\\.");
|
||||||
seconds = timeArr[0];
|
seconds = timeArr[0];
|
||||||
milliseconds = timeArr[1];
|
if (timeArr.length > 1) milliseconds = timeArr[1];
|
||||||
}
|
}
|
||||||
HashMap<String, Object> lineInfo = new HashMap<>();
|
HashMap<String, Object> lineInfo = new HashMap<>();
|
||||||
int time = Integer.parseInt(hours) * 60 * 60 * 1000
|
int time = Integer.parseInt(hours) * 60 * 60 * 1000
|
||||||
|
56
package-lock.json
generated
56
package-lock.json
generated
@ -15,10 +15,10 @@
|
|||||||
"@react-native-community/checkbox": "^0.5.15",
|
"@react-native-community/checkbox": "^0.5.15",
|
||||||
"@react-native-community/slider": "^4.4.2",
|
"@react-native-community/slider": "^4.4.2",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lrc-file-parser": "^2.3.1",
|
"lrc-file-parser": "^2.3.2",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-native": "0.71.5",
|
"react-native": "0.71.7",
|
||||||
"react-native-background-timer": "github:lyswhut/react-native-background-timer#88b1d05b2dcdc5af72bf365bf7ff00eec114d428",
|
"react-native-background-timer": "github:lyswhut/react-native-background-timer#88b1d05b2dcdc5af72bf365bf7ff00eec114d428",
|
||||||
"react-native-exception-handler": "^2.10.10",
|
"react-native-exception-handler": "^2.10.10",
|
||||||
"react-native-fs": "^2.20.0",
|
"react-native-fs": "^2.20.0",
|
||||||
@ -34,8 +34,8 @@
|
|||||||
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
||||||
"@babel/preset-env": "^7.21.4",
|
"@babel/preset-env": "^7.21.4",
|
||||||
"@babel/runtime": "^7.21.0",
|
"@babel/runtime": "^7.21.0",
|
||||||
"@tsconfig/react-native": "^2.0.3",
|
"@tsconfig/react-native": "^3.0.0",
|
||||||
"@types/react": "^18.0.31",
|
"@types/react": "^18.0.38",
|
||||||
"@types/react-native": "^0.70.13",
|
"@types/react-native": "^0.70.13",
|
||||||
"@types/react-native-background-timer": "^2.0.0",
|
"@types/react-native-background-timer": "^2.0.0",
|
||||||
"@types/react-native-vector-icons": "^6.4.13",
|
"@types/react-native-vector-icons": "^6.4.13",
|
||||||
@ -3231,9 +3231,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@tsconfig/react-native": {
|
"node_modules/@tsconfig/react-native": {
|
||||||
"version": "2.0.3",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/react-native/-/react-native-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/react-native/-/react-native-3.0.0.tgz",
|
||||||
"integrity": "sha512-jE58snEKBd9DXfyR4+ssZmYJ/W2mOSnNrvljR0aLyQJL9JKX6vlWELHkRjb3HBbcM9Uy0hZGijXbqEAjOERW2A==",
|
"integrity": "sha512-4NapbL5hywv83w0K7psaQnD15f7vOwrUkKZUxKYExqmkSPOg56+LkVbpCBuHYHJFoX3wyuau/tFxo1XFYogeUw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/istanbul-lib-coverage": {
|
"node_modules/@types/istanbul-lib-coverage": {
|
||||||
@ -3283,9 +3283,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "18.0.33",
|
"version": "18.0.38",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.33.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.38.tgz",
|
||||||
"integrity": "sha512-sHxzVxeanvQyQ1lr8NSHaj0kDzcNiGpILEVt69g9S31/7PfMvNCKLKcsHw4lYKjs3cGNJjXSP4mYzX43QlnjNA==",
|
"integrity": "sha512-ExsidLLSzYj4cvaQjGnQCk4HFfVT9+EZ9XZsQ8Hsrcn8QNgXtpZ3m9vSIC2MWtx7jHictK6wYhQgGh6ic58oOw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
@ -8386,9 +8386,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lrc-file-parser": {
|
"node_modules/lrc-file-parser": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/lrc-file-parser/-/lrc-file-parser-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/lrc-file-parser/-/lrc-file-parser-2.3.2.tgz",
|
||||||
"integrity": "sha512-e3ErKypTV21pMsL5Rg4YwwX/+HGN4xVPebHwvzWYQgQI+FUTxqW/ByhjtVxhOnxSsoHWFWGRWT6Tje8ODE+i/Q=="
|
"integrity": "sha512-iInpWhRdfMBsnre6R3i3IayjgGE0koqncQxEB4X+QMgY7bkp9Kh2z1jqLQKg6LQmHUAte4v3LgFLG3Wz6UCyvw=="
|
||||||
},
|
},
|
||||||
"node_modules/lru-cache": {
|
"node_modules/lru-cache": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
@ -10161,9 +10161,9 @@
|
|||||||
"integrity": "sha512-txfpPCQYiazVdcbMRhatqWKcAxJweUu2wDXvts5/7Wyp6+Y9cHojqXHsLPEckzutfHlxZhG8Oiundbmp8Fd6eQ=="
|
"integrity": "sha512-txfpPCQYiazVdcbMRhatqWKcAxJweUu2wDXvts5/7Wyp6+Y9cHojqXHsLPEckzutfHlxZhG8Oiundbmp8Fd6eQ=="
|
||||||
},
|
},
|
||||||
"node_modules/react-native": {
|
"node_modules/react-native": {
|
||||||
"version": "0.71.5",
|
"version": "0.71.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-native/-/react-native-0.71.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-native/-/react-native-0.71.7.tgz",
|
||||||
"integrity": "sha512-fMptnHXoIPotg7gPYAvjMRnfC6gUSkTJzgaIDQJTY/f5F+g6qph5J1xT9LCuWuNguyQ9dh8b0MZTK5ROvTTV9w==",
|
"integrity": "sha512-Id6iRLS581fJMFGbBl1jP5uSmjExtGOvw5Gvh7694zISXjsRAsFMmU+izs0pyCLqDBoHK7y4BT7WGPGw693nYw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/create-cache-key-function": "^29.2.1",
|
"@jest/create-cache-key-function": "^29.2.1",
|
||||||
"@react-native-community/cli": "10.2.2",
|
"@react-native-community/cli": "10.2.2",
|
||||||
@ -14585,9 +14585,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@tsconfig/react-native": {
|
"@tsconfig/react-native": {
|
||||||
"version": "2.0.3",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/react-native/-/react-native-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/react-native/-/react-native-3.0.0.tgz",
|
||||||
"integrity": "sha512-jE58snEKBd9DXfyR4+ssZmYJ/W2mOSnNrvljR0aLyQJL9JKX6vlWELHkRjb3HBbcM9Uy0hZGijXbqEAjOERW2A==",
|
"integrity": "sha512-4NapbL5hywv83w0K7psaQnD15f7vOwrUkKZUxKYExqmkSPOg56+LkVbpCBuHYHJFoX3wyuau/tFxo1XFYogeUw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/istanbul-lib-coverage": {
|
"@types/istanbul-lib-coverage": {
|
||||||
@ -14637,9 +14637,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/react": {
|
"@types/react": {
|
||||||
"version": "18.0.33",
|
"version": "18.0.38",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.33.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.38.tgz",
|
||||||
"integrity": "sha512-sHxzVxeanvQyQ1lr8NSHaj0kDzcNiGpILEVt69g9S31/7PfMvNCKLKcsHw4lYKjs3cGNJjXSP4mYzX43QlnjNA==",
|
"integrity": "sha512-ExsidLLSzYj4cvaQjGnQCk4HFfVT9+EZ9XZsQ8Hsrcn8QNgXtpZ3m9vSIC2MWtx7jHictK6wYhQgGh6ic58oOw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
@ -18435,9 +18435,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lrc-file-parser": {
|
"lrc-file-parser": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/lrc-file-parser/-/lrc-file-parser-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/lrc-file-parser/-/lrc-file-parser-2.3.2.tgz",
|
||||||
"integrity": "sha512-e3ErKypTV21pMsL5Rg4YwwX/+HGN4xVPebHwvzWYQgQI+FUTxqW/ByhjtVxhOnxSsoHWFWGRWT6Tje8ODE+i/Q=="
|
"integrity": "sha512-iInpWhRdfMBsnre6R3i3IayjgGE0koqncQxEB4X+QMgY7bkp9Kh2z1jqLQKg6LQmHUAte4v3LgFLG3Wz6UCyvw=="
|
||||||
},
|
},
|
||||||
"lru-cache": {
|
"lru-cache": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
@ -19793,9 +19793,9 @@
|
|||||||
"integrity": "sha512-txfpPCQYiazVdcbMRhatqWKcAxJweUu2wDXvts5/7Wyp6+Y9cHojqXHsLPEckzutfHlxZhG8Oiundbmp8Fd6eQ=="
|
"integrity": "sha512-txfpPCQYiazVdcbMRhatqWKcAxJweUu2wDXvts5/7Wyp6+Y9cHojqXHsLPEckzutfHlxZhG8Oiundbmp8Fd6eQ=="
|
||||||
},
|
},
|
||||||
"react-native": {
|
"react-native": {
|
||||||
"version": "0.71.5",
|
"version": "0.71.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-native/-/react-native-0.71.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-native/-/react-native-0.71.7.tgz",
|
||||||
"integrity": "sha512-fMptnHXoIPotg7gPYAvjMRnfC6gUSkTJzgaIDQJTY/f5F+g6qph5J1xT9LCuWuNguyQ9dh8b0MZTK5ROvTTV9w==",
|
"integrity": "sha512-Id6iRLS581fJMFGbBl1jP5uSmjExtGOvw5Gvh7694zISXjsRAsFMmU+izs0pyCLqDBoHK7y4BT7WGPGw693nYw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@jest/create-cache-key-function": "^29.2.1",
|
"@jest/create-cache-key-function": "^29.2.1",
|
||||||
"@react-native-community/cli": "10.2.2",
|
"@react-native-community/cli": "10.2.2",
|
||||||
|
@ -48,10 +48,10 @@
|
|||||||
"@react-native-community/checkbox": "^0.5.15",
|
"@react-native-community/checkbox": "^0.5.15",
|
||||||
"@react-native-community/slider": "^4.4.2",
|
"@react-native-community/slider": "^4.4.2",
|
||||||
"iconv-lite": "^0.6.3",
|
"iconv-lite": "^0.6.3",
|
||||||
"lrc-file-parser": "^2.3.1",
|
"lrc-file-parser": "^2.3.2",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-native": "0.71.5",
|
"react-native": "0.71.7",
|
||||||
"react-native-background-timer": "github:lyswhut/react-native-background-timer#88b1d05b2dcdc5af72bf365bf7ff00eec114d428",
|
"react-native-background-timer": "github:lyswhut/react-native-background-timer#88b1d05b2dcdc5af72bf365bf7ff00eec114d428",
|
||||||
"react-native-exception-handler": "^2.10.10",
|
"react-native-exception-handler": "^2.10.10",
|
||||||
"react-native-fs": "^2.20.0",
|
"react-native-fs": "^2.20.0",
|
||||||
@ -67,8 +67,8 @@
|
|||||||
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
||||||
"@babel/preset-env": "^7.21.4",
|
"@babel/preset-env": "^7.21.4",
|
||||||
"@babel/runtime": "^7.21.0",
|
"@babel/runtime": "^7.21.0",
|
||||||
"@tsconfig/react-native": "^2.0.3",
|
"@tsconfig/react-native": "^3.0.0",
|
||||||
"@types/react": "^18.0.31",
|
"@types/react": "^18.0.38",
|
||||||
"@types/react-native": "^0.70.13",
|
"@types/react-native": "^0.70.13",
|
||||||
"@types/react-native-background-timer": "^2.0.0",
|
"@types/react-native-background-timer": "^2.0.0",
|
||||||
"@types/react-native-vector-icons": "^6.4.13",
|
"@types/react-native-vector-icons": "^6.4.13",
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
- 修复mg搜索不显示时长的问题(@Folltoshe)
|
- 修复mg搜索不显示时长的问题(@Folltoshe)
|
||||||
- 修复mg评论加载失败的问题(@Folltoshe)
|
- 修复mg评论加载失败的问题(@Folltoshe)
|
||||||
- 修复在Android 5.1下报错的问题
|
- 修复在Android 5.1下报错的问题
|
||||||
|
- 修复对存在错误时间标签的歌词的解析
|
||||||
|
|
||||||
### 其他
|
### 其他
|
||||||
|
|
||||||
- 更新kg、tx、wy等平台排行榜列表
|
- 更新kg、tx、wy等平台排行榜列表
|
||||||
|
- 更新react native到v0.71.7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user