From 8ef33f382e1c5f01edd6483bd05d8e00cd021e9d Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Wed, 17 Nov 2021 14:17:38 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96jellyfin=E6=90=9C=E5=88=AE?=
=?UTF-8?q?=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 4 +
.../nas/Controllers/MusicController.java | 14 +-
.../com/yutou/nas/Datas/Jellyfin/Chapter.java | 13 ++
.../com/yutou/nas/Datas/Jellyfin/Episode.java | 31 +++
.../yutou/nas/Datas/Jellyfin/EpisodeData.java | 78 +++++++
.../nas/Datas/Jellyfin/ImageBlurHashes.java | 12 ++
.../yutou/nas/Datas/Jellyfin/ImageTags.java | 8 +
.../yutou/nas/Datas/Jellyfin/ItemInfo.java | 57 +++++
.../yutou/nas/Datas/Jellyfin/LibsItem.java | 24 +++
.../yutou/nas/Datas/Jellyfin/MediaSource.java | 37 ++++
.../yutou/nas/Datas/Jellyfin/MediaStream.java | 38 ++++
.../yutou/nas/Datas/Jellyfin/UserData.java | 12 ++
.../java/com/yutou/nas/NasApplication.java | 2 +-
.../com/yutou/nas/bangumi/BangumiTools.java | 93 ++++++---
.../com/yutou/nas/utils/ApplicationInit.java | 136 ++++++------
.../yutou/nas/utils/JellyfinAPIManager.java | 196 +++++++++---------
src/main/java/com/yutou/nas/utils/Log.java | 7 +
.../com/yutou/nas/utils/QQBotManager.java | 1 +
src/main/java/com/yutou/nas/utils/Tools.java | 2 -
19 files changed, 574 insertions(+), 191 deletions(-)
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/Chapter.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/Episode.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/ImageBlurHashes.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/ImageTags.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/LibsItem.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/MediaSource.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/MediaStream.java
create mode 100644 src/main/java/com/yutou/nas/Datas/Jellyfin/UserData.java
diff --git a/pom.xml b/pom.xml
index 3bdcbf0..33bca14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -138,6 +138,10 @@
aliyun-sdk-oss
3.10.2
+
diff --git a/src/main/java/com/yutou/nas/Controllers/MusicController.java b/src/main/java/com/yutou/nas/Controllers/MusicController.java
index cb342cd..845230b 100644
--- a/src/main/java/com/yutou/nas/Controllers/MusicController.java
+++ b/src/main/java/com/yutou/nas/Controllers/MusicController.java
@@ -152,13 +152,18 @@ public class MusicController {
fileName = Tools.base64ToString(fileName);
}
List list = null;
- if (body.getString("type").equals("album")) {
+ if ("album".equals(body.getString("type"))) {
list = musicTools.selectAlbum(fileName);
}
File file;
if (list != null && !list.isEmpty()) {
fileName = list.get(0).getFile();
}
+ if(!fileName.startsWith("/media/yutou/disk_lvm/public/音乐/")
+ ||fileName.endsWith("..")
+ ||fileName.endsWith("../")){
+ return null;
+ }
file = new File(fileName);
if (file.exists()) {
try {
@@ -194,13 +199,18 @@ public class MusicController {
public ResponseEntity play(String filePath, String random) {
String _filePath;
boolean _random;
- _random = !StringUtils.isEmpty(random) && random.equals("true");
+ _random = !StringUtils.isEmpty(random) && "true".equals(random);
_filePath = Tools.base64ToString(filePath);
if (_random) {
List list = musicTools.getMusicList();
MusicData data = list.get(Tools.randomCommon(0, list.size() - 1, 1)[0]);
_filePath = data.getFile();
}
+ if(!_filePath.startsWith("/media/yutou/disk_lvm/public/音乐/")
+ ||_filePath.endsWith("..")
+ ||_filePath.endsWith("../")){
+ return null;
+ }
File file = new File(_filePath);
if (file.exists()) {
return Tools.getFile(file);
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/Chapter.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/Chapter.java
new file mode 100644
index 0000000..5067347
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/Chapter.java
@@ -0,0 +1,13 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import lombok.Data;
+
+
+@Data
+public class Chapter {
+ private long startPositionTicks;
+ private String name;
+ private String imagePath;
+ private String imageDateModified;
+ private String imageTag;
+}
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/Episode.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/Episode.java
new file mode 100644
index 0000000..e25cbb7
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/Episode.java
@@ -0,0 +1,31 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import lombok.Data;
+
+@Data
+public class Episode {
+ private long runTimeTicks;
+ private String seriesID;
+ private UserData userData;
+ private String seasonName;
+ private long parentIndexNumber;
+ private String name;
+ private String videoType;
+ private String container;
+ private String serverID;
+ private String parentBackdropItemID;
+ private String seriesName;
+ private String parentLogoImageTag;
+ private String mediaType;
+ private String seasonID;
+ private ImageBlurHashes imageBlurHashes;
+ private String parentLogoItemID;
+ private ImageTags imageTags;
+ private String seriesPrimaryImageTag;
+ private String type;
+ private Object[] backdropImageTags;
+ private String[] parentBackdropImageTags;
+ private String id;
+ private boolean isFolder;
+ private String locationType;
+}
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java
new file mode 100644
index 0000000..c6c3bba
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java
@@ -0,0 +1,78 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yutou.nas.utils.AppTools;
+import lombok.Data;
+
+import java.io.File;
+
+
+@Data
+public class EpisodeData {
+ private String name;
+ private String serverID;
+ private String id;
+ private String etag;
+ private String dateCreated;
+ private boolean canDelete;
+ private boolean canDownload;
+ private String container;
+ private String sortName;
+ private Object[] externalUrls;
+ private MediaSource[] mediaSources;
+ private String path;
+ private boolean enableMediaSourceDisplay;
+ private Object channelID;
+ private Object[] taglines;
+ private Object[] genres;
+ private long runTimeTicks;
+ private String playAccess;
+ private long parentIndexNumber;
+ private Object[] 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 String parentLogoItemID;
+ private String parentBackdropItemID;
+ private String[] parentBackdropImageTags;
+ private long localTrailerCount;
+ private UserData userData;
+ private String seriesName;
+ private String seriesID;
+ private String seasonID;
+ private long specialFeatureCount;
+ private String displayPreferencesID;
+ private Object[] tags;
+ private double primaryImageAspectRatio;
+ private String seriesPrimaryImageTag;
+ private String seasonName;
+ private MediaStream[] mediaStreams;
+ private String videoType;
+ private ImageTags imageTags;
+ private Object[] backdropImageTags;
+ private Object[] screenshotImageTags;
+ private String parentLogoImageTag;
+ private ImageBlurHashes imageBlurHashes;
+ private String seriesStudio;
+ private Chapter[] chapters;
+ private String locationType;
+ private String mediaType;
+ private Object[] lockedFields;
+ private boolean lockData;
+ private long width;
+ private long height;
+
+ public String getPath() {
+ if (AppTools.isRuntimeSystemOfWindow()) {
+ if (path != null) {
+ path = path.replace("/media/yutou/disk_lvm/public/download/anim/", "Z:\\download\\anim\\").replace("/", File.separator);
+ }
+ }
+ return path;
+ }
+}
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageBlurHashes.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageBlurHashes.java
new file mode 100644
index 0000000..6ebda2f
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageBlurHashes.java
@@ -0,0 +1,12 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class ImageBlurHashes {
+ private Map primary;
+ private Map backdrop;
+ private Map logo;
+}
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageTags.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageTags.java
new file mode 100644
index 0000000..5d3baf6
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/ImageTags.java
@@ -0,0 +1,8 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import lombok.Data;
+
+@Data
+public class ImageTags {
+ private String primary;
+}
\ No newline at end of file
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java
new file mode 100644
index 0000000..cbdf3d7
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/ItemInfo.java
@@ -0,0 +1,57 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import com.yutou.nas.utils.AppTools;
+import lombok.Data;
+
+import java.io.File;
+
+@Data
+public class ItemInfo {
+ private String name;
+ private String serverID;
+ private String id;
+ private String etag;
+ private String dateCreated;
+ private String dateLastMediaAdded;
+ private boolean canDelete;
+ private boolean canDownload;
+ private String sortName;
+ private Object[] externalUrls;
+ private String path;
+ private boolean enableMediaSourceDisplay;
+ private Object channelID;
+ private Object[] taglines;
+ private Object[] genres;
+ private String playAccess;
+ private Object[] remoteTrailers;
+ private boolean isFolder;
+ private String parentID;
+ private String type;
+ private Object[] people;
+ private Object[] studios;
+ private Object[] genreItems;
+ private long localTrailerCount;
+ private UserData userData;
+ private long recursiveItemCount;
+ private long childCount;
+ private long specialFeatureCount;
+ private String displayPreferencesID;
+ private Object[] airDays;
+ private Object[] tags;
+ private double primaryImageAspectRatio;
+ private ImageTags imageTags;
+ private String[] backdropImageTags;
+ private Object[] screenshotImageTags;
+ private String locationType;
+ private Object[] lockedFields;
+ private boolean lockData;
+
+ public String getPath() {
+ if (AppTools.isRuntimeSystemOfWindow()) {
+ if (path != null) {
+ path = path.replace("/media/yutou/disk_lvm/public/download/anim/", "Z:\\download\\anim\\").replace("/", File.separator);
+ }
+ }
+ return path;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/LibsItem.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/LibsItem.java
new file mode 100644
index 0000000..15b019b
--- /dev/null
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/LibsItem.java
@@ -0,0 +1,24 @@
+package com.yutou.nas.Datas.Jellyfin;
+
+import com.yutou.nas.utils.JellyfinAPIManager;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LibsItem {
+ private String name;
+ private String serverID;
+ private String id;
+ private Object channelID;
+ private boolean isFolder;
+ private String type;
+ private UserData userData;
+ private String collectionType;
+ private ImageTags imageTags;
+ private List