新增设置动画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 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";
}
}

View File

@ -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");

View File

@ -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<LibsItem> _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<LibsItem> _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);
}
}