新增获取动画信息接口

This commit is contained in:
Yutousama 2022-04-02 21:45:20 +08:00
parent 71e18e03b9
commit d01cda4d50
3 changed files with 59 additions and 59 deletions

View File

@ -1,9 +1,7 @@
package com.yutou.nas.Controllers;
import com.yutou.nas.utils.HttpTools;
import com.yutou.nas.utils.RedisTools;
import com.yutou.nas.utils.StringUtils;
import com.yutou.nas.utils.Tools;
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.ResponseBody;
@ -41,4 +39,9 @@ public class ToolsController {
Tools.sendServer(title, msg);
return "ok";
}
@ResponseBody
@RequestMapping("/tools/anim/items.do")
public JSONArray getAnimItems(){
return new JellyfinAPIManager().getAnimPaths();
}
}

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

View File

@ -69,6 +69,7 @@ public class JellyfinAPIManager {
), getHeader());
return JSONObject.parseObject(data);
}
public JSONObject getEpisodesForJson(String parentID, String id) {
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Episodes?seasonId=%s&userId=e8a13675bb64466dbd81f1e5985ef8c7",
parentID,
@ -76,20 +77,24 @@ public class JellyfinAPIManager {
), getHeader());
return JSONObject.parseObject(data);
}
public List<Episode> getEpisodes(String parentId, String id) {
JSONObject json = getEpisodesForJson(parentId, id);
JSONArray episodes = json.getJSONArray("Items");
return JSONArray.parseArray(episodes.toJSONString(), Episode.class);
}
public JSONObject getEpisodesDataForJson(String id) {
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items/%s",
id
), getHeader());
return JSONObject.parseObject(data);
}
public EpisodeData getEpisodeData(String id) {
return JSONObject.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class);
}
public String getPathForEpisode(String parentId, String id) {
List<Episode> list = getEpisodes(parentId, id);
if (!list.isEmpty()) {
@ -99,7 +104,6 @@ public class JellyfinAPIManager {
}
public void uploadImage(File image, String id, String model) {
try {
HashMap<String, String> header = getHeader();
@ -202,12 +206,6 @@ public class JellyfinAPIManager {
}
public void testItem(String id) {
JellyfinAPIManager manager = new JellyfinAPIManager();
LibsItem item = manager.getLibs("番剧");
@ -257,10 +255,27 @@ public class JellyfinAPIManager {
}
}
public void search(String name, File path) {
public JSONArray getAnimPaths() {
JSONArray array = new JSONArray();
for (LibsItem item : mediaItem) {
System.out.println(item.getName() + " > " + item.getInfo().getPath());
JSONObject json = new JSONObject();
json.put("name", item.getInfo().getName());
List<LibsItem> list = getLibsItems(item.getId());
json.put("size",list.size());
JSONArray _items = new JSONArray();
if (list.size() > 1) {
for (LibsItem libsItem : list) {
JSONObject _item = new JSONObject();
_item.put("name", libsItem.getName());
_item.put("path", getInfo(libsItem.getId()).getPath());
_items.add(_item);
}
json.put("path",_items);
}
json.put("root",item.getInfo().getPath());
array.add(json);
}
return array;
}
public void init(File path) {
@ -277,26 +292,6 @@ public class JellyfinAPIManager {
String id = ConfigTools.loadIni(file, "id");
if (id != null) {
for (LibsItem item : mediaItem) {
/*if (item.getName().equals("你遭难了吗?")) {
// System.out.println(item.getName()+" "+item.getId());
//System.out.println(getItemShows(item.getId()));
List<LibsItem> _temp = getLibsItems(item.getId());
System.out.println(item.getInfo().getPath() + " " + _temp.size());
if (_temp.size() > 1) {
for (LibsItem libsItem : _temp) {
ItemInfo info = getInfo(libsItem.getId());
if (info.getPath()==null){
System.out.println(getPathForEpisode(info.getParentID(),info.getId())+" > "+path.getPath());
//System.out.println(getPathForEpisode(info.getParentID(),info.getId()).contains(path.getPath()));
}
}
}
System.exit(0);
break;
}*/
List<LibsItem> _temp = getLibsItems(item.getId());
if (_temp.size() == 1) {
if (item.getInfo().getPath().contains(path.getPath())) {
@ -324,11 +319,11 @@ public class JellyfinAPIManager {
}
}
}
/* if (item.getInfo().getPath().contains(path.getPath())) {
//System.out.println(item.getName()+" "+id);
// new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)),item);
if (item.getInfo().getPath().contains(path.getPath())) {
System.out.println(item.getName() + " " + id);
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item);
break;
}*/
}
}
}
}
@ -345,9 +340,11 @@ public class JellyfinAPIManager {
public static String mainPath = "Z:\\download\\anim\\";
public static void main(String[] args) {
File file = new File("Z:\\download\\anim\\");
File file = new File("Z:\\download\\anim\\Bangdream☆pico");
//new JellyfinAPIManager().search(file.getName(), file);
JellyfinAPIManager manager = new JellyfinAPIManager();
manager.init(file);
// manager.init(file);
JSONArray search = manager.getAnimPaths();
System.out.println(search);
}
}