add新增过滤纯音乐

This commit is contained in:
Yutousama 2022-11-14 13:39:32 +08:00
parent a39d99eeb6
commit 3509de8cef
3 changed files with 55 additions and 44 deletions

View File

@ -47,20 +47,21 @@ public class MusicController {
public String getMusicListOfPath(@RequestBody JSONObject body) {
String path = body.getString("path");
boolean type = body.containsKey("type") ? body.getBoolean("type") : false;
boolean filter = body.containsKey("filter") ? body.getBoolean("filter") : false;
if (StringUtils.isEmpty(path)
|| "root".equals(path)
|| !path.contains(defaultMusicPath)
) {
path = defaultMusicPath;
}
com.yutou.nas.utils.Log.i("接收到地址:" + path);
com.yutou.nas.utils.Log.i("接收到地址:" + body);
//path=path.replace(defaultMusicPath+File.separator,"");
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("scan", musicTools.isScan());
json.put("size", musicTools.getLength());
json.put("data", JSON.toJSON(musicTools.getPath(path, type, true)));
json.put("data", JSON.toJSON(musicTools.getPath(path, type, true, filter)));
return json.toJSONString();
}
@ -189,6 +190,7 @@ public class MusicController {
return null;
}
}
@RequestMapping("/nas/music/lrc.do")
public ResponseEntity<FileSystemResource> lrc(String filePath) {
return Tools.getFile(musicTools.getMusicLrcMd5(filePath));

View File

@ -12,6 +12,7 @@ public interface IMusicToolsService {
void scanMusic();
List<MusicData> getPath(String path, boolean isDir,boolean delPath);
List<MusicData> getPath(String path, boolean isDir,boolean delPath,boolean filter);
MusicData getMusicDataOfMd5(String md5,boolean isDelFile);
MusicData getMusicData(String path,boolean isDelFile);

View File

@ -97,6 +97,10 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
}
}
@Override
public List<MusicData> getPath(String path, boolean isDir, boolean delPath) {
return getPath(path, isDir, delPath, false);
}
/**
* 获取指定目录下的音乐
@ -106,7 +110,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
* @return 音乐列表
*/
@Override
public List<MusicData> getPath(String path, boolean isDir,boolean delPath) {
public List<MusicData> getPath(String path, boolean isDir, boolean delPath, boolean filter) {
List<MusicData> list = new ArrayList<>();
List<MusicData> main = new ArrayList<>();
MusicDataExample example = new MusicDataExample();
@ -116,7 +120,11 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
tmpPath = AppData.defaultMusicPath;
}
if (isDir) {
if (filter) {
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%").andTitleNotLike("instrumental");
} else {
example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%");
}
main = musicDataDao.selectByExample(example, delPath);
}
tmpPath = tmpPath.replace(File.separator, replacement)
@ -155,7 +163,6 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
}
public List<MusicData> getAllAlbum() {
return musicDataDao.selectAllAlbum();
}
@ -220,6 +227,7 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
}
return null;
}
@Override
public MusicData getMusicDataOfMd5(String md5, boolean isDelFile) {
MusicDataExample example = new MusicDataExample();