新增获取动画信息接口
This commit is contained in:
parent
71e18e03b9
commit
d01cda4d50
@ -1,9 +1,7 @@
|
|||||||
package com.yutou.nas.Controllers;
|
package com.yutou.nas.Controllers;
|
||||||
|
|
||||||
import com.yutou.nas.utils.HttpTools;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.yutou.nas.utils.RedisTools;
|
import com.yutou.nas.utils.*;
|
||||||
import com.yutou.nas.utils.StringUtils;
|
|
||||||
import com.yutou.nas.utils.Tools;
|
|
||||||
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.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -41,4 +39,9 @@ public class ToolsController {
|
|||||||
Tools.sendServer(title, msg);
|
Tools.sendServer(title, msg);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/tools/anim/items.do")
|
||||||
|
public JSONArray getAnimItems(){
|
||||||
|
return new JellyfinAPIManager().getAnimPaths();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.8";
|
public static final String version="1.2.9";
|
||||||
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");
|
||||||
|
@ -69,37 +69,41 @@ public class JellyfinAPIManager {
|
|||||||
), getHeader());
|
), getHeader());
|
||||||
return JSONObject.parseObject(data);
|
return JSONObject.parseObject(data);
|
||||||
}
|
}
|
||||||
public JSONObject getEpisodesForJson(String parentID,String id){
|
|
||||||
|
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",
|
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Episodes?seasonId=%s&userId=e8a13675bb64466dbd81f1e5985ef8c7",
|
||||||
parentID,
|
parentID,
|
||||||
id
|
id
|
||||||
), getHeader());
|
), getHeader());
|
||||||
return JSONObject.parseObject(data);
|
return JSONObject.parseObject(data);
|
||||||
}
|
}
|
||||||
public List<Episode> getEpisodes(String parentId,String id){
|
|
||||||
JSONObject json=getEpisodesForJson(parentId, id);
|
public List<Episode> getEpisodes(String parentId, String id) {
|
||||||
JSONArray episodes=json.getJSONArray("Items");
|
JSONObject json = getEpisodesForJson(parentId, id);
|
||||||
|
JSONArray episodes = json.getJSONArray("Items");
|
||||||
return JSONArray.parseArray(episodes.toJSONString(), Episode.class);
|
return JSONArray.parseArray(episodes.toJSONString(), Episode.class);
|
||||||
}
|
}
|
||||||
public JSONObject getEpisodesDataForJson(String id){
|
|
||||||
|
public JSONObject getEpisodesDataForJson(String id) {
|
||||||
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items/%s",
|
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items/%s",
|
||||||
id
|
id
|
||||||
), getHeader());
|
), getHeader());
|
||||||
return JSONObject.parseObject(data);
|
return JSONObject.parseObject(data);
|
||||||
}
|
}
|
||||||
public EpisodeData getEpisodeData(String id){
|
|
||||||
|
public EpisodeData getEpisodeData(String id) {
|
||||||
return JSONObject.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class);
|
return JSONObject.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class);
|
||||||
}
|
}
|
||||||
public String getPathForEpisode(String parentId,String id){
|
|
||||||
List<Episode> list=getEpisodes(parentId, id);
|
public String getPathForEpisode(String parentId, String id) {
|
||||||
if(!list.isEmpty()){
|
List<Episode> list = getEpisodes(parentId, id);
|
||||||
|
if (!list.isEmpty()) {
|
||||||
return getEpisodeData(list.get(0).getId()).getPath();
|
return getEpisodeData(list.get(0).getId()).getPath();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void uploadImage(File image, String id, String model) {
|
public void uploadImage(File image, String id, String model) {
|
||||||
try {
|
try {
|
||||||
HashMap<String, String> header = getHeader();
|
HashMap<String, String> header = getHeader();
|
||||||
@ -202,12 +206,6 @@ public class JellyfinAPIManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void testItem(String id) {
|
public void testItem(String id) {
|
||||||
JellyfinAPIManager manager = new JellyfinAPIManager();
|
JellyfinAPIManager manager = new JellyfinAPIManager();
|
||||||
LibsItem item = manager.getLibs("番剧");
|
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) {
|
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) {
|
public void init(File path) {
|
||||||
@ -277,46 +292,26 @@ public class JellyfinAPIManager {
|
|||||||
String id = ConfigTools.loadIni(file, "id");
|
String id = ConfigTools.loadIni(file, "id");
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
for (LibsItem item : mediaItem) {
|
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());
|
List<LibsItem> _temp = getLibsItems(item.getId());
|
||||||
if(_temp.size()==1){
|
if (_temp.size() == 1) {
|
||||||
if (item.getInfo().getPath().contains(path.getPath())) {
|
if (item.getInfo().getPath().contains(path.getPath())) {
|
||||||
System.out.println(item.getName()+" "+id);
|
System.out.println(item.getName() + " " + id);
|
||||||
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)),item);
|
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
System.out.println(item.getName()+" > "+_temp.size());
|
System.out.println(item.getName() + " > " + _temp.size());
|
||||||
for (LibsItem libsItem : _temp) {
|
for (LibsItem libsItem : _temp) {
|
||||||
ItemInfo info = getInfo(libsItem.getId());
|
ItemInfo info = getInfo(libsItem.getId());
|
||||||
if(info.getPath()!=null) {
|
if (info.getPath() != null) {
|
||||||
if (info.getPath().contains(path.getPath())) {
|
if (info.getPath().contains(path.getPath())) {
|
||||||
System.out.println("list > " + item.getName() + " " + id);
|
System.out.println("list > " + item.getName() + " " + id);
|
||||||
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
|
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
String ep_Path=getPathForEpisode(info.getParentID(),info.getId());
|
String ep_Path = getPathForEpisode(info.getParentID(), info.getId());
|
||||||
if(ep_Path!=null&&ep_Path.contains(path.getPath())){
|
if (ep_Path != null && ep_Path.contains(path.getPath())) {
|
||||||
System.out.println("list > " + item.getName() + " " + id);
|
System.out.println("list > " + item.getName() + " " + id);
|
||||||
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
|
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), libsItem);
|
||||||
break;
|
break;
|
||||||
@ -324,11 +319,11 @@ public class JellyfinAPIManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* if (item.getInfo().getPath().contains(path.getPath())) {
|
if (item.getInfo().getPath().contains(path.getPath())) {
|
||||||
//System.out.println(item.getName()+" "+id);
|
System.out.println(item.getName() + " " + id);
|
||||||
// new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)),item);
|
new JellyfinAPIManager().saveJellyfinMetaData(BangumiTools.getBangumiInfo(Integer.parseInt(id)), item);
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,9 +340,11 @@ public class JellyfinAPIManager {
|
|||||||
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\\");
|
File file = new File("Z:\\download\\anim\\Bangdream☆pico");
|
||||||
//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);
|
||||||
|
JSONArray search = manager.getAnimPaths();
|
||||||
|
System.out.println(search);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user