From 0da3b9f0d0156037a9ae71584f0f7cb2839829a3 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sat, 2 Apr 2022 22:03:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E5=8A=A8?= =?UTF-8?q?=E7=94=BBmeta=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nas/Controllers/ToolsController.java | 8 ++ .../java/com/yutou/nas/NasApplication.java | 2 +- .../yutou/nas/utils/JellyfinAPIManager.java | 81 ++++++++----------- 3 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/yutou/nas/Controllers/ToolsController.java b/src/main/java/com/yutou/nas/Controllers/ToolsController.java index 63da24b..d5850e7 100644 --- a/src/main/java/com/yutou/nas/Controllers/ToolsController.java +++ b/src/main/java/com/yutou/nas/Controllers/ToolsController.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONArray; import com.yutou.nas.utils.*; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; +import java.io.File; import java.io.IOException; @Controller @@ -44,4 +46,10 @@ public class ToolsController { public JSONArray getAnimItems(){ return new JellyfinAPIManager().getAnimPaths(); } + @ResponseBody + @RequestMapping(value = "/tools/anim/set.do",method = RequestMethod.POST) + public String setAnimMeta(String path,String id){ + new JellyfinAPIManager().init(new File(path),id); + return "1"; + } } diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index bd790de..66184f3 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.9"; + public static final String version="1.2.10"; public static void main(String[] args) { SpringApplication.run(NasApplication.class, args); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); diff --git a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java index 6f4bf9c..06370e7 100644 --- a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java +++ b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java @@ -278,73 +278,60 @@ public class JellyfinAPIManager { return array; } - public void init(File path) { - if (path.isDirectory()) { - File file = new File(path.getAbsolutePath() + File.separator + "info.ini"); - if (!file.exists()) { - try { - file.createNewFile(); - System.out.println("创建:" + file.getAbsolutePath()); - } catch (IOException e) { - e.printStackTrace(); - } - } else { - String id = ConfigTools.loadIni(file, "id"); - if (id != null) { - for (LibsItem item : mediaItem) { - List _temp = getLibsItems(item.getId()); - if (_temp.size() == 1) { - if (item.getInfo().getPath().contains(path.getPath())) { - System.out.println(item.getName() + " " + id); - new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item); + public void init(File path,String id) { + if (id != null) { + for (LibsItem item : mediaItem) { + List _temp = getLibsItems(item.getId()); + if (_temp.size() == 1) { + if (item.getInfo().getPath().contains(path.getPath())) { + System.out.println(item.getName() + " " + id); + new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item); + break; + } + } else { + System.out.println(item.getName() + " > " + _temp.size()); + for (LibsItem libsItem : _temp) { + ItemInfo info = getInfo(libsItem.getId()); + if (info.getPath() != null) { + if (info.getPath().contains(path.getPath())) { + System.out.println("list > " + item.getName() + " " + id); + new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem); break; } } else { - System.out.println(item.getName() + " > " + _temp.size()); - for (LibsItem libsItem : _temp) { - ItemInfo info = getInfo(libsItem.getId()); - if (info.getPath() != null) { - if (info.getPath().contains(path.getPath())) { - System.out.println("list > " + item.getName() + " " + id); - new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem); - break; - } - } else { - String ep_Path = getPathForEpisode(info.getParentID(), info.getId()); - if (ep_Path != null && ep_Path.contains(path.getPath())) { - System.out.println("list > " + item.getName() + " " + id); - new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem); - break; - } - } + String ep_Path = getPathForEpisode(info.getParentID(), info.getId()); + if (ep_Path != null && ep_Path.contains(path.getPath())) { + System.out.println("list > " + item.getName() + " " + id); + new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem); + break; } } - if (item.getInfo().getPath().contains(path.getPath())) { - System.out.println(item.getName() + " " + id); - new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item); - break; - } } } + if (item.getInfo().getPath().contains(path.getPath())) { + System.out.println(item.getName() + " " + id); + new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item); + break; + } } } - for (File file : path.listFiles()) { + /*for (File file : path.listFiles()) { if (file.isDirectory()) { // System.out.println("搜索目录:"+file.getAbsolutePath()); init(file); } - } + }*/ } public static String mainPath = "Z:\\download\\anim\\"; public static void main(String[] args) { - File file = new File("Z:\\download\\anim\\Bangdream☆pico"); + File file = new File("Z:\\download\\anim\\白沙的水族馆"); //new JellyfinAPIManager().search(file.getName(), file); JellyfinAPIManager manager = new JellyfinAPIManager(); - // manager.init(file); - JSONArray search = manager.getAnimPaths(); - System.out.println(search); + manager.init(file,"325281"); + //JSONArray search = manager.getAnimPaths(); + //System.out.println(search); } }