修复Jellyfin异常问题

This commit is contained in:
Yutousama 2022-05-04 10:58:17 +08:00
parent 51c15f4a34
commit 2f1ba2acb9
5 changed files with 58 additions and 30 deletions

View File

@ -69,6 +69,13 @@
<artifactId>fastjson2</artifactId> <artifactId>fastjson2</artifactId>
<version>2.0.2</version> <version>2.0.2</version>
</dependency> </dependency>
<!-- <dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/fastjson2-2.0.3.jar</systemPath>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch --> <!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency> <dependency>
<groupId>com.jcraft</groupId> <groupId>com.jcraft</groupId>

View File

@ -1,9 +1,11 @@
package com.yutou.nas.Datas.Jellyfin; package com.yutou.nas.Datas.Jellyfin;
import com.alibaba.fastjson2.JSONArray;
import com.yutou.nas.utils.AppTools; import com.yutou.nas.utils.AppTools;
import lombok.Data; import lombok.Data;
import java.io.File; import java.io.File;
import java.util.List;
@Data @Data
public class ItemInfo { public class ItemInfo {
@ -13,38 +15,37 @@ public class ItemInfo {
private String etag; private String etag;
private String dateCreated; private String dateCreated;
private String dateLastMediaAdded; private String dateLastMediaAdded;
private boolean canDelete;
private boolean canDownload;
private String sortName;
private Object[] externalUrls;
private String path; private String path;
private boolean enableMediaSourceDisplay; private String sortName;
private Object channelID;
private Object[] taglines;
private Object[] genres;
private String playAccess;
private Object[] remoteTrailers;
private boolean isFolder;
private String parentID; private String parentID;
private String playAccess;
private String type; private String type;
private Object[] people; private String displayPreferencesID;
private Object[] studios; private String locationType;
private Object[] genreItems;
private long localTrailerCount; private long localTrailerCount;
private UserData userData;
private long recursiveItemCount; private long recursiveItemCount;
private long childCount; private long childCount;
private long specialFeatureCount; private long specialFeatureCount;
private String displayPreferencesID; private boolean canDownload;
private Object[] airDays; private boolean canDelete;
private Object[] tags; private boolean enableMediaSourceDisplay;
private double primaryImageAspectRatio; private boolean isFolder;
private ImageTags imageTags;
private String[] backdropImageTags;
private Object[] screenshotImageTags;
private String locationType;
private Object[] lockedFields;
private boolean lockData; private boolean lockData;
private double primaryImageAspectRatio;
private Object channelID;
private Object[] externalUrls;
private Object[] remoteTrailers;
private Object[] genreItems;
private Object[] airDays;
private Object[] screenshotImageTags;
private Object[] lockedFields;
private List<Studios> studios;
private List<People> people;
private JSONArray backdropImageTags;
private JSONArray genres;
private JSONArray taglines;
private JSONArray tags;
public String getPath() { public String getPath() {
if (AppTools.isRuntimeSystemOfWindow()) { if (AppTools.isRuntimeSystemOfWindow()) {

View File

@ -0,0 +1,11 @@
package com.yutou.nas.Datas.Jellyfin;
import lombok.Data;
@Data
public class People {
private String name;
private String id;
private String role;
private String type;
}

View File

@ -0,0 +1,9 @@
package com.yutou.nas.Datas.Jellyfin;
import lombok.Data;
@Data
public class Studios {
private String id;
private String name;
}

View File

@ -44,7 +44,7 @@ public class JellyfinAPIManager {
public ItemInfo getInfo(String id) { public ItemInfo getInfo(String id) {
String http = HttpTools.https_get("http://192.168.31.88:8096/Users/"+userId+"/Items/" + id, getHeader()); String http = HttpTools.https_get("http://192.168.31.88:8096/Users/"+userId+"/Items/" + id, getHeader());
return JSON.parseObject(http, ItemInfo.class); return JSON.parseObject(http).toJavaObject(ItemInfo.class);
} }
public List<LibsItem> getAllItem() { public List<LibsItem> getAllItem() {
@ -52,7 +52,7 @@ public class JellyfinAPIManager {
JSONObject json = JSON.parseObject(http); JSONObject json = JSON.parseObject(http);
JSONArray items = json.getJSONArray("Items"); JSONArray items = json.getJSONArray("Items");
List<LibsItem> list = JSON.parseArray(items.toJSONString(), LibsItem.class); List<LibsItem> list =items.toJavaList(LibsItem.class);
for (LibsItem item : list) { for (LibsItem item : list) {
item.setInfo(getInfo(item.getId())); item.setInfo(getInfo(item.getId()));
} }
@ -63,7 +63,7 @@ public class JellyfinAPIManager {
String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/"+userId+"/Items?ParentId=" + id, getHeader()); String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/"+userId+"/Items?ParentId=" + id, getHeader());
JSONObject json = JSON.parseObject(httpText); JSONObject json = JSON.parseObject(httpText);
JSONArray items = json.getJSONArray("Items"); JSONArray items = json.getJSONArray("Items");
return JSON.parseArray(items.toJSONString(), LibsItem.class); return items.toJavaList(LibsItem.class);
} }
public JSONObject getItemShows(String id) { public JSONObject getItemShows(String id) {
@ -333,8 +333,8 @@ public class JellyfinAPIManager {
File file = new File("Z:\\download\\anim\\白沙的水族馆"); 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,"325281"); // manager.init(file,"325281");
//JSONArray search = manager.getAnimPaths(); JSONArray search = manager.getAnimPaths();
//System.out.println(search); System.out.println(search);
} }
} }