diff --git a/src/main/java/com/yutou/nas/Controllers/MusicController.java b/src/main/java/com/yutou/nas/Controllers/MusicController.java index a1350f7..5df8b3c 100644 --- a/src/main/java/com/yutou/nas/Controllers/MusicController.java +++ b/src/main/java/com/yutou/nas/Controllers/MusicController.java @@ -189,6 +189,10 @@ public class MusicController { return null; } } + @RequestMapping("/nas/music/lrc.do") + public ResponseEntity lrc(String filePath){ + return Tools.getFile(musicTools.getMusicLrcMd5(filePath)); + } @RequestMapping("/nas/music/share.do") @ResponseBody diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index f09406f..5263e2b 100644 --- a/src/main/java/com/yutou/nas/NasApplication.java +++ b/src/main/java/com/yutou/nas/NasApplication.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import; @Import(BTDownloadManager.class) @SpringBootApplication 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) { SpringApplication.run(NasApplication.class, args); diff --git a/src/main/java/com/yutou/nas/Services/IMusicToolsService.java b/src/main/java/com/yutou/nas/Services/IMusicToolsService.java index bfea4e4..17d271f 100644 --- a/src/main/java/com/yutou/nas/Services/IMusicToolsService.java +++ b/src/main/java/com/yutou/nas/Services/IMusicToolsService.java @@ -31,4 +31,6 @@ public interface IMusicToolsService { byte[] readImage(String path) throws Exception; File getMusicOfMd5(String md5,boolean isDelFile); + + File getMusicLrcMd5(String md5); } diff --git a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java index 3cddfd2..5fcdda5 100644 --- a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java +++ b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java @@ -562,6 +562,23 @@ public class MusicToolsServiceImpl implements IMusicToolsService { return null; } + @Override + public File getMusicLrcMd5(String md5) { + MusicDataExample example=new MusicDataExample(); + example.createCriteria().andMd5EqualTo(md5); + List 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 { String path = file.getAbsolutePath().replace(file.getName(), ""); 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:\\音乐\\周董\\2012 十二新作\\03 公公偏头痛.ape"); com.yutou.nas.utils.Log.i(new MusicToolsServiceImpl().getMetadataOfFFmpeg(file)); + + new MusicToolsServiceImpl().getMusicLrcMd5("84d3180883e6447c3b86bfc55b05608e"); } diff --git a/src/main/java/com/yutou/nas/utils/Tools.java b/src/main/java/com/yutou/nas/utils/Tools.java index e8a6f6d..be5546b 100644 --- a/src/main/java/com/yutou/nas/utils/Tools.java +++ b/src/main/java/com/yutou/nas/utils/Tools.java @@ -287,6 +287,9 @@ public class Tools { * @return 前端获取的文件 */ public static ResponseEntity getFile(File file) { + if(file==null){ + return null; + } HttpHeaders headers = new HttpHeaders(); headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); try {