新增设置动画meta接口

This commit is contained in:
Yutousama 2022-04-02 22:03:27 +08:00
parent d01cda4d50
commit 0da3b9f0d0
3 changed files with 43 additions and 48 deletions

View File

@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSONArray;
import com.yutou.nas.utils.*; import com.yutou.nas.utils.*;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException; import java.io.IOException;
@Controller @Controller
@ -44,4 +46,10 @@ public class ToolsController {
public JSONArray getAnimItems(){ public JSONArray getAnimItems(){
return new JellyfinAPIManager().getAnimPaths(); 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";
}
} }

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.9"; public static final String version="1.2.10";
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args); SpringApplication.run(NasApplication.class, args);
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");

View File

@ -278,73 +278,60 @@ public class JellyfinAPIManager {
return array; return array;
} }
public void init(File path) { public void init(File path,String id) {
if (path.isDirectory()) { if (id != null) {
File file = new File(path.getAbsolutePath() + File.separator + "info.ini"); for (LibsItem item : mediaItem) {
if (!file.exists()) { List<LibsItem> _temp = getLibsItems(item.getId());
try { if (_temp.size() == 1) {
file.createNewFile(); if (item.getInfo().getPath().contains(path.getPath())) {
System.out.println("创建:" + file.getAbsolutePath()); System.out.println(item.getName() + " " + id);
} catch (IOException e) { new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item);
e.printStackTrace(); break;
} }
} else { } else {
String id = ConfigTools.loadIni(file, "id"); System.out.println(item.getName() + " > " + _temp.size());
if (id != null) { for (LibsItem libsItem : _temp) {
for (LibsItem item : mediaItem) { ItemInfo info = getInfo(libsItem.getId());
List<LibsItem> _temp = getLibsItems(item.getId()); if (info.getPath() != null) {
if (_temp.size() == 1) { if (info.getPath().contains(path.getPath())) {
if (item.getInfo().getPath().contains(path.getPath())) { System.out.println("list > " + item.getName() + " " + id);
System.out.println(item.getName() + " " + id); new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item);
break; break;
} }
} else { } else {
System.out.println(item.getName() + " > " + _temp.size()); String ep_Path = getPathForEpisode(info.getParentID(), info.getId());
for (LibsItem libsItem : _temp) { if (ep_Path != null && ep_Path.contains(path.getPath())) {
ItemInfo info = getInfo(libsItem.getId()); System.out.println("list > " + item.getName() + " " + id);
if (info.getPath() != null) { new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
if (info.getPath().contains(path.getPath())) { break;
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;
}
}
} }
} }
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()) { if (file.isDirectory()) {
// System.out.println("搜索目录:"+file.getAbsolutePath()); // System.out.println("搜索目录:"+file.getAbsolutePath());
init(file); init(file);
} }
} }*/
} }
public static String mainPath = "Z:\\download\\anim\\"; public static String mainPath = "Z:\\download\\anim\\";
public static void main(String[] args) { 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); //new JellyfinAPIManager().search(file.getName(), file);
JellyfinAPIManager manager = new JellyfinAPIManager(); JellyfinAPIManager manager = new JellyfinAPIManager();
// manager.init(file); manager.init(file,"325281");
JSONArray search = manager.getAnimPaths(); //JSONArray search = manager.getAnimPaths();
System.out.println(search); //System.out.println(search);
} }
} }