修复音乐无法访问文件夹内的文件
更新QQbot版本
This commit is contained in:
parent
326bcfbf9e
commit
4b91b65d43
2
pom.xml
2
pom.xml
@ -96,7 +96,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.mamoe</groupId>
|
<groupId>net.mamoe</groupId>
|
||||||
<artifactId>mirai-core-jvm</artifactId>
|
<artifactId>mirai-core-jvm</artifactId>
|
||||||
<version>2.5.0</version> <!-- 替换版本为你需要的版本 -->
|
<version>2.6.7</version> <!-- 替换版本为你需要的版本 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
@ -46,13 +46,13 @@ public class MusicController {
|
|||||||
public String getMusicListOfPath(@RequestBody JSONObject body) {
|
public String getMusicListOfPath(@RequestBody JSONObject body) {
|
||||||
String path = body.getString("path");
|
String path = body.getString("path");
|
||||||
boolean type = body.containsKey("type") ? body.getBoolean("type") : false;
|
boolean type = body.containsKey("type") ? body.getBoolean("type") : false;
|
||||||
com.yutou.nas.utils.Log.i("接收到地址:" + path);
|
|
||||||
if (StringUtils.isEmpty(path)
|
if (StringUtils.isEmpty(path)
|
||||||
|| path.equals("root")
|
|| "root".equals(path)
|
||||||
|| !path.contains(defaultMusicPath)
|
|| !path.contains(defaultMusicPath)
|
||||||
) {
|
) {
|
||||||
path = defaultMusicPath;
|
path = defaultMusicPath;
|
||||||
}
|
}
|
||||||
|
com.yutou.nas.utils.Log.i("接收到地址:" + path);
|
||||||
|
|
||||||
//path=path.replace(defaultMusicPath+File.separator,"");
|
//path=path.replace(defaultMusicPath+File.separator,"");
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
|
@ -56,7 +56,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
|||||||
if (isScan) {
|
if (isScan) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ConfigTools.load(ConfigTools.CONFIG, "musicScan",boolean.class,false)) {
|
if (!ConfigTools.load(ConfigTools.CONFIG, "musicScan",boolean.class,false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
musicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
|
||||||
@ -112,9 +112,9 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
|||||||
List<MusicData> list = new ArrayList<>();
|
List<MusicData> list = new ArrayList<>();
|
||||||
List<MusicData> main = new ArrayList<>();
|
List<MusicData> main = new ArrayList<>();
|
||||||
MusicDataExample example = new MusicDataExample();
|
MusicDataExample example = new MusicDataExample();
|
||||||
String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/";
|
String replacement = "windows".equals(ConfigTools.load(ConfigTools.CONFIG, "os")) ? "\\\\" : "/";
|
||||||
String tmpPath = path;
|
String tmpPath = path;
|
||||||
if (isDir) {
|
if (new File(path).isDirectory()) {
|
||||||
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%");
|
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%");
|
||||||
main = musicDataDao.selectByExample(example);
|
main = musicDataDao.selectByExample(example);
|
||||||
}
|
}
|
||||||
@ -125,9 +125,10 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
|||||||
.replace("]", "\\]");
|
.replace("]", "\\]");
|
||||||
main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$"));
|
main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$"));
|
||||||
|
|
||||||
if (!path.equals(AppData.defaultMusicPath) && !path.equals("root")) {
|
if (!path.equals(AppData.defaultMusicPath) && !"root".equals(path)) {
|
||||||
MusicData t2 = new MusicData();
|
MusicData t2 = new MusicData();
|
||||||
t2.setTitle("返回");
|
t2.setTitle("返回");
|
||||||
|
t2.setTrack("-1");
|
||||||
if (main.isEmpty()) {
|
if (main.isEmpty()) {
|
||||||
t2.setFile("root");
|
t2.setFile("root");
|
||||||
} else {
|
} else {
|
||||||
@ -186,6 +187,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
try {
|
try {
|
||||||
if(getMusicData(file.getAbsolutePath())==null) {
|
if(getMusicData(file.getAbsolutePath())==null) {
|
||||||
|
// System.out.println(data);
|
||||||
musicDataDao.insert(data);
|
musicDataDao.insert(data);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -270,7 +272,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
|
|||||||
}
|
}
|
||||||
data.setFile(file.getAbsolutePath());
|
data.setFile(file.getAbsolutePath());
|
||||||
data.setIsdir(file.isDirectory() ? 1 : 0);
|
data.setIsdir(file.isDirectory() ? 1 : 0);
|
||||||
data.setLastdir(file.getParentFile().getParent());
|
data.setLastdir(file.getParentFile().getParent());//这里是设置上一级目录
|
||||||
|
|
||||||
AudioHeader header = audioFile.getAudioHeader();
|
AudioHeader header = audioFile.getAudioHeader();
|
||||||
data.setBitrate(header.getBitRate());
|
data.setBitrate(header.getBitRate());
|
||||||
|
Loading…
Reference in New Issue
Block a user