From 893afd295c662d7aca0822940f3bbb40b978a478 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 4 May 2022 11:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DJellyfin=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yutou/nas/Datas/Jellyfin/EpisodeData.java | 32 ++++++++++--------- .../yutou/nas/Datas/Jellyfin/ItemInfo.java | 2 ++ .../yutou/nas/utils/JellyfinAPIManager.java | 14 ++++---- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java index 27e7cfc..e4fc5ce 100644 --- a/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java +++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java @@ -1,10 +1,12 @@ package com.yutou.nas.Datas.Jellyfin; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.yutou.nas.utils.AppTools; import lombok.Data; import java.io.File; +import java.util.List; @Data @@ -18,28 +20,28 @@ public class EpisodeData { private boolean canDownload; private String container; private String sortName; - private Object[] externalUrls; - private MediaSource[] mediaSources; + private JSONArray externalUrls; + private List mediaSources; private String path; private boolean enableMediaSourceDisplay; private Object channelID; - private Object[] taglines; - private Object[] genres; + private JSONArray taglines; + private JSONArray genres; private long runTimeTicks; private String playAccess; private long parentIndexNumber; - private Object[] remoteTrailers; + private JSONArray remoteTrailers; private JSONObject providerIDS; private boolean isHD; private boolean isFolder; private String parentID; private String type; - private Object[] people; - private Object[] studios; - private Object[] genreItems; + private List people; + private List studios; + private JSONArray genreItems; private String parentLogoItemID; private String parentBackdropItemID; - private String[] parentBackdropImageTags; + private JSONArray parentBackdropImageTags; private long localTrailerCount; private UserData userData; private String seriesName; @@ -47,22 +49,22 @@ public class EpisodeData { private String seasonID; private long specialFeatureCount; private String displayPreferencesID; - private Object[] tags; + private JSONArray tags; private double primaryImageAspectRatio; private String seriesPrimaryImageTag; private String seasonName; - private MediaStream[] mediaStreams; + private List mediaStreams; private String videoType; private ImageTags imageTags; - private Object[] backdropImageTags; - private Object[] screenshotImageTags; + private JSONArray backdropImageTags; + private JSONArray screenshotImageTags; private String parentLogoImageTag; private ImageBlurHashes imageBlurHashes; private String seriesStudio; - private Chapter[] chapters; + private List chapters; private String locationType; private String mediaType; - private Object[] lockedFields; + private JSONArray lockedFields; private boolean lockData; private long width; private long height; diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java index 0118d14..e6ff5cb 100644 --- a/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java +++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java @@ -1,6 +1,7 @@ package com.yutou.nas.Datas.Jellyfin; import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.annotation.JSONField; import com.yutou.nas.utils.AppTools; import lombok.Data; @@ -17,6 +18,7 @@ public class ItemInfo { private String dateLastMediaAdded; private String path; private String sortName; + @JSONField(name = "ParentId") private String parentID; private String playAccess; private String type; diff --git a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java index b8bec3a..ca08429 100644 --- a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java +++ b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java @@ -84,7 +84,7 @@ public class JellyfinAPIManager { public List getEpisodes(String parentId, String id) { JSONObject json = getEpisodesForJson(parentId, id); JSONArray episodes = json.getJSONArray("Items"); - return JSON.parseArray(episodes.toJSONString(), Episode.class); + return episodes.toJavaList(Episode.class); } public JSONObject getEpisodesDataForJson(String id) { @@ -95,7 +95,7 @@ public class JellyfinAPIManager { } public EpisodeData getEpisodeData(String id) { - return JSON.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class); + return getEpisodesDataForJson(id).toJavaObject(EpisodeData.class); } public String getPathForEpisode(String parentId, String id) { @@ -177,12 +177,10 @@ public class JellyfinAPIManager { metadata.put("Taglines", new JSONArray()); HashMap headers = getHeader(); headers.put("Content-Type", "application/json"); - System.out.println(metadata.toString().replace("\"null\"", "null")); String ret = HttpTools.http_post("http://192.168.31.88:8096/Items/" + item.getId() , metadata.toString().replace("\"null\"", "null").getBytes(StandardCharsets.UTF_8) , 4 , headers); - System.out.println(ret); HttpTools.download( info.getJSONObject("images").getString("large").replace("http:", "https:"), item.getName() + "_poster.jpg", @@ -330,11 +328,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\\夏日重现"); //new JellyfinAPIManager().search(file.getName(), file); JellyfinAPIManager manager = new JellyfinAPIManager(); - // manager.init(file,"325281"); - JSONArray search = manager.getAnimPaths(); - System.out.println(search); + manager.init(file,"326895"); + // JSONArray search = manager.getAnimPaths(); + // System.out.println(search); } }