music:新增歌词接口

This commit is contained in:
Yutousama 2022-07-10 21:00:49 +08:00
parent 3997ee91ac
commit e090e6375e
5 changed files with 29 additions and 1 deletions

View File

@ -189,6 +189,10 @@ public class MusicController {
return null; return null;
} }
} }
@RequestMapping("/nas/music/lrc.do")
public ResponseEntity<FileSystemResource> lrc(String filePath){
return Tools.getFile(musicTools.getMusicLrcMd5(filePath));
}
@RequestMapping("/nas/music/share.do") @RequestMapping("/nas/music/share.do")
@ResponseBody @ResponseBody

View File

@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class) @Import(BTDownloadManager.class)
@SpringBootApplication @SpringBootApplication
public class NasApplication { public class NasApplication {
public static final String version = "1.2.15"; public static final String version = "1.2.16";
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args); SpringApplication.run(NasApplication.class, args);

View File

@ -31,4 +31,6 @@ public interface IMusicToolsService {
byte[] readImage(String path) throws Exception; byte[] readImage(String path) throws Exception;
File getMusicOfMd5(String md5,boolean isDelFile); File getMusicOfMd5(String md5,boolean isDelFile);
File getMusicLrcMd5(String md5);
} }

View File

@ -562,6 +562,23 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
return null; return null;
} }
@Override
public File getMusicLrcMd5(String md5) {
MusicDataExample example=new MusicDataExample();
example.createCriteria().andMd5EqualTo(md5);
List<MusicData> list=musicDataDao.selectByExample(example,false);
if(!list.isEmpty()){
String fileName=list.get(0).getFile();
fileName=fileName.replace(fileName.substring(fileName.lastIndexOf(".")),".lrc");
System.out.println("fileName = " + fileName);
File file=new File(fileName);
if(file.exists()){
return file;
}
}
return null;
}
private byte[] readImageFile(File file) throws Exception { private byte[] readImageFile(File file) throws Exception {
String path = file.getAbsolutePath().replace(file.getName(), ""); String path = file.getAbsolutePath().replace(file.getName(), "");
File img = new File(path, "cover.jpg"); File img = new File(path, "cover.jpg");
@ -583,6 +600,8 @@ public class MusicToolsServiceImpl implements IMusicToolsService {
file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac"); file = new File("Z:\\音乐\\终将成为你\\[OP]君にふれて\\rise.flac");
// file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape"); // file = new File("Z:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape");
com.yutou.nas.utils.Log.i(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file)); com.yutou.nas.utils.Log.i(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file));
new MusicToolsServiceImpl().getMusicLrcMd5("84d3180883e6447c3b86bfc55b05608e");
} }

View File

@ -287,6 +287,9 @@ public class Tools {
* @return 前端获取的文件 * @return 前端获取的文件
*/ */
public static ResponseEntity<FileSystemResource> getFile(File file) { public static ResponseEntity<FileSystemResource> getFile(File file) {
if(file==null){
return null;
}
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
try { try {