From 9bfe05b1196fde0b22d28c153a189d207ca30b50 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Tue, 3 May 2022 20:08:51 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfastjson=E7=9A=84=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 4 +--
.../yutou/nas/Controllers/DoorController.java | 2 +-
.../yutou/nas/Controllers/HHDController.java | 2 +-
.../nas/Controllers/MusicController.java | 17 ++++-----
.../Controllers/MusicFavoritesController.java | 7 ++--
.../java/com/yutou/nas/Controllers/QQBot.java | 2 +-
.../nas/Controllers/ToolsController.java | 2 +-
.../com/yutou/nas/Controllers/UpdateIp.java | 5 +--
.../yutou/nas/Datas/Jellyfin/EpisodeData.java | 2 +-
.../yutou/nas/Datas/Jellyfin/MediaSource.java | 2 +-
.../java/com/yutou/nas/NasApplication.java | 2 +-
.../Services/impl/MusicToolsServiceImpl.java | 2 +-
.../nas/Services/impl/VideoToolsService.java | 2 +-
.../nas/bangumi/AnimationController.java | 11 +++---
.../com/yutou/nas/bangumi/AnimationData.java | 11 +++---
.../com/yutou/nas/bangumi/BangumiTools.java | 11 +++---
src/main/java/com/yutou/nas/other/tools.java | 7 ++--
.../yutou/nas/utils/BTDownloadManager.java | 11 +++---
.../java/com/yutou/nas/utils/ConfigTools.java | 7 ++--
.../com/yutou/nas/utils/DepotManager.java | 9 ++---
.../java/com/yutou/nas/utils/HttpTools.java | 2 +-
.../yutou/nas/utils/JellyfinAPIManager.java | 35 ++++++++++---------
.../com/yutou/nas/utils/QQBotManager.java | 2 +-
.../java/com/yutou/nas/utils/RedisTools.java | 5 +--
src/main/java/com/yutou/nas/utils/Tools.java | 5 +--
25 files changed, 90 insertions(+), 77 deletions(-)
diff --git a/pom.xml b/pom.xml
index eed999c..6bdf711 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,8 +65,8 @@
- com.alibaba
- fastjson
+ com.alibaba.fastjson2
+ fastjson2
2.0.2
diff --git a/src/main/java/com/yutou/nas/Controllers/DoorController.java b/src/main/java/com/yutou/nas/Controllers/DoorController.java
index 33ff93b..8aec74d 100644
--- a/src/main/java/com/yutou/nas/Controllers/DoorController.java
+++ b/src/main/java/com/yutou/nas/Controllers/DoorController.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.RedisTools;
import com.yutou.nas.utils.StringUtils;
import com.yutou.nas.utils.Tools;
diff --git a/src/main/java/com/yutou/nas/Controllers/HHDController.java b/src/main/java/com/yutou/nas/Controllers/HHDController.java
index 177afb2..8bc1653 100644
--- a/src/main/java/com/yutou/nas/Controllers/HHDController.java
+++ b/src/main/java/com/yutou/nas/Controllers/HHDController.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.QQBotManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
diff --git a/src/main/java/com/yutou/nas/Controllers/MusicController.java b/src/main/java/com/yutou/nas/Controllers/MusicController.java
index 17e3648..a1350f7 100644
--- a/src/main/java/com/yutou/nas/Controllers/MusicController.java
+++ b/src/main/java/com/yutou/nas/Controllers/MusicController.java
@@ -1,7 +1,8 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Services.impl.MusicToolsServiceImpl;
import com.yutou.nas.mybatis.model.MusicData;
import com.yutou.nas.utils.ConfigTools;
@@ -37,7 +38,7 @@ public class MusicController {
json.put("code", 0);
json.put("scan", musicTools.isScan());
json.put("size", musicTools.getLength());
- json.put("data", JSONArray.toJSON(musicTools.getMusicList(true)));
+ json.put("data", JSON.toJSON(musicTools.getMusicList(true)));
return json.toJSONString();
}
@@ -59,7 +60,7 @@ public class MusicController {
json.put("code", 0);
json.put("scan", musicTools.isScan());
json.put("size", musicTools.getLength());
- json.put("data", JSONArray.toJSON(musicTools.getPath(path, type, true)));
+ json.put("data", JSON.toJSON(musicTools.getPath(path, type, true)));
return json.toJSONString();
}
@@ -70,9 +71,9 @@ public class MusicController {
JSONObject json = new JSONObject();
json.put("code", 0);
if (StringUtils.isEmpty(album)) {
- json.put("data", JSONArray.toJSON(musicTools.getAllAlbum()));
+ json.put("data", JSON.toJSON(musicTools.getAllAlbum()));
} else {
- json.put("data", JSONArray.toJSON(musicTools.selectAlbum(album, true)));
+ json.put("data", JSON.toJSON(musicTools.selectAlbum(album, true)));
}
return json.toJSONString();
}
@@ -84,9 +85,9 @@ public class MusicController {
JSONObject json = new JSONObject();
json.put("code", 0);
if (StringUtils.isEmpty(artist)) {
- json.put("data", JSONArray.toJSON(musicTools.getAllArtist()));
+ json.put("data", JSON.toJSON(musicTools.getAllArtist()));
} else {
- json.put("data", JSONArray.toJSON(musicTools.selectArtist(artist, true)));
+ json.put("data", JSON.toJSON(musicTools.selectArtist(artist, true)));
}
return json.toJSONString();
}
diff --git a/src/main/java/com/yutou/nas/Controllers/MusicFavoritesController.java b/src/main/java/com/yutou/nas/Controllers/MusicFavoritesController.java
index d610337..5aacbb5 100644
--- a/src/main/java/com/yutou/nas/Controllers/MusicFavoritesController.java
+++ b/src/main/java/com/yutou/nas/Controllers/MusicFavoritesController.java
@@ -1,7 +1,8 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.mybatis.dao.MusicDataDao;
import com.yutou.nas.mybatis.dao.MusicFavoritesDao;
import com.yutou.nas.mybatis.dao.MusicFavoritesDirDao;
@@ -152,7 +153,7 @@ public class MusicFavoritesController {
}
list.clear();
json.put("code", 0);
- json.put("data", JSONArray.toJSON(dataList));
+ json.put("data", JSON.toJSON(dataList));
} catch (Exception e) {
e.printStackTrace();
json.put("code", -1);
diff --git a/src/main/java/com/yutou/nas/Controllers/QQBot.java b/src/main/java/com/yutou/nas/Controllers/QQBot.java
index 0d71cba..769f275 100644
--- a/src/main/java/com/yutou/nas/Controllers/QQBot.java
+++ b/src/main/java/com/yutou/nas/Controllers/QQBot.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.utils.QQBotManager;
import com.yutou.nas.utils.Tools;
diff --git a/src/main/java/com/yutou/nas/Controllers/ToolsController.java b/src/main/java/com/yutou/nas/Controllers/ToolsController.java
index d5850e7..59a64f4 100644
--- a/src/main/java/com/yutou/nas/Controllers/ToolsController.java
+++ b/src/main/java/com/yutou/nas/Controllers/ToolsController.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson2.JSONArray;
import com.yutou.nas.utils.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
diff --git a/src/main/java/com/yutou/nas/Controllers/UpdateIp.java b/src/main/java/com/yutou/nas/Controllers/UpdateIp.java
index 5ef5bc3..9dbae79 100644
--- a/src/main/java/com/yutou/nas/Controllers/UpdateIp.java
+++ b/src/main/java/com/yutou/nas/Controllers/UpdateIp.java
@@ -1,6 +1,7 @@
package com.yutou.nas.Controllers;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.RedisTools;
import com.yutou.nas.utils.Tools;
import org.springframework.stereotype.Controller;
@@ -60,7 +61,7 @@ public class UpdateIp {
if(isNas){
String adminAddress= RedisTools.get("adminAddress");
if(adminAddress!=null) {
- JSONObject json=JSONObject.parseObject(adminAddress);
+ JSONObject json= JSON.parseObject(adminAddress);
line = "proxy_pass http://" +ip+":"+json.getInteger("port")+"/;";
}else{
line = line.replace(testIp, ip);
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 c6c3bba..27e7cfc 100644
--- a/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/EpisodeData.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Datas.Jellyfin;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.AppTools;
import lombok.Data;
diff --git a/src/main/java/com/yutou/nas/Datas/Jellyfin/MediaSource.java b/src/main/java/com/yutou/nas/Datas/Jellyfin/MediaSource.java
index 59356e7..aef51cf 100644
--- a/src/main/java/com/yutou/nas/Datas/Jellyfin/MediaSource.java
+++ b/src/main/java/com/yutou/nas/Datas/Jellyfin/MediaSource.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Datas.Jellyfin;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
@Data
diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java
index a3c88ab..e299394 100644
--- a/src/main/java/com/yutou/nas/NasApplication.java
+++ b/src/main/java/com/yutou/nas/NasApplication.java
@@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import;
@Import(BTDownloadManager.class)
@SpringBootApplication
public class NasApplication {
- public static final String version="1.2.12";
+ public static final String version="1.2.13";
public static void main(String[] args) {
SpringApplication.run(NasApplication.class, args);
AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir");
diff --git a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java
index 97b49c3..5c40bec 100644
--- a/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java
+++ b/src/main/java/com/yutou/nas/Services/impl/MusicToolsServiceImpl.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Services.impl;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Datas.AppData;
import com.yutou.nas.mybatis.dao.MusicDataDao;
import com.yutou.nas.mybatis.model.MusicData;
diff --git a/src/main/java/com/yutou/nas/Services/impl/VideoToolsService.java b/src/main/java/com/yutou/nas/Services/impl/VideoToolsService.java
index 2fb6d46..1bdf927 100644
--- a/src/main/java/com/yutou/nas/Services/impl/VideoToolsService.java
+++ b/src/main/java/com/yutou/nas/Services/impl/VideoToolsService.java
@@ -1,6 +1,6 @@
package com.yutou.nas.Services.impl;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Services.IVideoToolsService;
import com.yutou.nas.bangumi.BangumiTools;
import com.yutou.nas.interfaces.ObjectInterface;
diff --git a/src/main/java/com/yutou/nas/bangumi/AnimationController.java b/src/main/java/com/yutou/nas/bangumi/AnimationController.java
index 44b9388..806a22f 100644
--- a/src/main/java/com/yutou/nas/bangumi/AnimationController.java
+++ b/src/main/java/com/yutou/nas/bangumi/AnimationController.java
@@ -1,7 +1,8 @@
package com.yutou.nas.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.mybatis.dao.BangumiItemDao;
import com.yutou.nas.mybatis.dao.BangumiListDao;
import com.yutou.nas.mybatis.model.BangumiItem;
@@ -67,7 +68,7 @@ public class AnimationController {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSONArray.toJSON(listDao.selectByExample(new BangumiListExample())));
+ json.put("data", JSON.toJSON(listDao.selectByExample(new BangumiListExample())));
return json.toJSONString();
}
@ResponseBody
@@ -107,7 +108,7 @@ public class AnimationController {
example.createCriteria().andBidEqualTo(type);
json.put("code", 0);
json.put("msg", "ok");
- json.put("data", JSONArray.toJSON(itemDao.selectByExample(example)));
+ json.put("data", JSON.toJSON(itemDao.selectByExample(example)));
return json.toJSONString();
}
@ResponseBody
@@ -128,7 +129,7 @@ public class AnimationController {
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
}
- JSONArray array= (JSONArray) JSONArray.toJSON(list);
+ JSONArray array= (JSONArray) JSON.toJSON(list);
return array.toJSONString();
}
}
diff --git a/src/main/java/com/yutou/nas/bangumi/AnimationData.java b/src/main/java/com/yutou/nas/bangumi/AnimationData.java
index 00ab0bd..f8d8f4e 100644
--- a/src/main/java/com/yutou/nas/bangumi/AnimationData.java
+++ b/src/main/java/com/yutou/nas/bangumi/AnimationData.java
@@ -1,7 +1,8 @@
package com.yutou.nas.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.HttpTools;
import java.net.URLEncoder;
@@ -25,7 +26,7 @@ public class AnimationData {
com.yutou.nas.utils.Log.i(String.format(animUrl, "" + index, title,type,team));
com.yutou.nas.utils.Log.i(rss2jsonUrl + URLEncoder.encode(String.format(animUrl, "" + index, title,type,team), "UTF-8") +String.format( "&api_key=%s&count=500",rss2jsonApi_2));
String js= HttpTools.get(rss2jsonUrl+ URLEncoder.encode(String.format(animUrl,""+index,title,type,team),"UTF-8")+String.format( "&api_key=%s&count=500",rss2jsonApi_2));
- JSONObject json=JSONObject.parseObject(js);
+ JSONObject json= JSON.parseObject(js);
if(json.getString("status").equals("ok")){
return json.getJSONArray("items");
}
@@ -37,9 +38,9 @@ public class AnimationData {
public int nameToValue(String name,boolean isTeam){
JSONArray array;
if(isTeam){
- array=JSONArray.parseArray(team);
+ array=JSON.parseArray(team);
}else{
- array=JSONArray.parseArray(type);
+ array=JSON.parseArray(type);
}
for (Object o : array) {
JSONObject json= (JSONObject) o;
diff --git a/src/main/java/com/yutou/nas/bangumi/BangumiTools.java b/src/main/java/com/yutou/nas/bangumi/BangumiTools.java
index 34b75e7..529aa25 100644
--- a/src/main/java/com/yutou/nas/bangumi/BangumiTools.java
+++ b/src/main/java/com/yutou/nas/bangumi/BangumiTools.java
@@ -1,7 +1,8 @@
package com.yutou.nas.bangumi;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.utils.*;
import java.text.ParseException;
@@ -22,7 +23,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
- JSONArray main = JSONArray.parseArray(str);
+ JSONArray main = JSON.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
@@ -57,7 +58,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
- return JSONObject.parseObject(str);
+ return JSON.parseObject(str);
}
public static JSONArray getPeople(int id) {
@@ -114,7 +115,7 @@ public class BangumiTools {
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, key));
- return JSONObject.parseObject(str);
+ return JSON.parseObject(str);
}
/**
diff --git a/src/main/java/com/yutou/nas/other/tools.java b/src/main/java/com/yutou/nas/other/tools.java
index e6d4877..bbe8d32 100644
--- a/src/main/java/com/yutou/nas/other/tools.java
+++ b/src/main/java/com/yutou/nas/other/tools.java
@@ -1,7 +1,8 @@
package com.yutou.nas.other;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.NasApplication;
import com.yutou.nas.Services.IVideoToolsService;
import com.yutou.nas.utils.AppTools;
@@ -79,7 +80,7 @@ public class tools {
}
if (request.getCookies() != null) {
for (Cookie cookie : request.getCookies()) {
- JSONObject ck = JSONObject.parseObject(JSONObject.toJSONString(cookie));
+ JSONObject ck = JSON.parseObject(JSON.toJSONString(cookie));
cookies.add(ck);
}
}
diff --git a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java
index a3d635c..dc8f131 100644
--- a/src/main/java/com/yutou/nas/utils/BTDownloadManager.java
+++ b/src/main/java/com/yutou/nas/utils/BTDownloadManager.java
@@ -1,7 +1,8 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Services.IBangumiService;
import com.yutou.nas.bangumi.AnimationData;
import com.yutou.nas.mybatis.model.BangumiItem;
@@ -63,7 +64,7 @@ public class BTDownloadManager implements ApplicationContextAware {
String url = getRSSUrl(item);
String _json = HttpTools.get(url);
if (!StringUtils.isEmpty(_json)) {
- JSONObject json = JSONObject.parseObject(_json);
+ JSONObject json = JSON.parseObject(_json);
download(item, json);
} else {
QQBotManager.getInstance().sendMessage(item.getTitle() + "\n下载失败\n"+getDmhyUrl(item));
@@ -153,7 +154,7 @@ public class BTDownloadManager implements ApplicationContextAware {
if (StringUtils.isEmpty(_title)) {
return new JSONArray();
}
- return JSONArray.parseArray(_title);
+ return JSON.parseArray(_title);
}
private boolean isDownload(String title, String key) {
@@ -162,7 +163,7 @@ public class BTDownloadManager implements ApplicationContextAware {
if (StringUtils.isEmpty(_title)) {
return false;
} else {
- array = JSONArray.parseArray(_title);
+ array = JSON.parseArray(_title);
}
return array.contains(key);
}
diff --git a/src/main/java/com/yutou/nas/utils/ConfigTools.java b/src/main/java/com/yutou/nas/utils/ConfigTools.java
index d2ca2ff..71b20c6 100644
--- a/src/main/java/com/yutou/nas/utils/ConfigTools.java
+++ b/src/main/java/com/yutou/nas/utils/ConfigTools.java
@@ -1,6 +1,7 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import java.io.*;
import java.util.HashSet;
@@ -45,7 +46,7 @@ public class ConfigTools {
String src = readFile(file);
if (src != null) {
try {
- JSONObject json = JSONObject.parseObject(src);
+ JSONObject json = JSON.parseObject(src);
return json.getObject(key, t);
} catch (Exception e) {
}
@@ -81,7 +82,7 @@ public class ConfigTools {
if (src == null) {
src = "{}";
}
- JSONObject json = JSONObject.parseObject(src);
+ JSONObject json = JSON.parseObject(src);
json.put(key, data);
saveFile(file, json.toJSONString());
return false;
diff --git a/src/main/java/com/yutou/nas/utils/DepotManager.java b/src/main/java/com/yutou/nas/utils/DepotManager.java
index 7b004fd..94e1262 100644
--- a/src/main/java/com/yutou/nas/utils/DepotManager.java
+++ b/src/main/java/com/yutou/nas/utils/DepotManager.java
@@ -1,7 +1,8 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.utils.StringUtils;
@@ -22,12 +23,12 @@ public class DepotManager {
public void run() {
String str = HttpTools.get("http://tools.yutou233.cn/nas/depot/list.do?token=" + HttpTools.serverKey);
if (!StringUtils.isEmpty(str)) {
- JSONObject json = JSONObject.parseObject(str);
+ JSONObject json = JSON.parseObject(str);
if (json.getInteger("code") == 1) {
JSONArray array = json.getJSONArray("data");
for (Object o : array) {
List list = new ArrayList<>();
- JSONObject item = JSONObject.parseObject(o.toString());
+ JSONObject item = JSON.parseObject(o.toString());
scanFile(new File(item.getString("path")), new DownloadInterface() {
@Override
public void onDownload(File file) {
diff --git a/src/main/java/com/yutou/nas/utils/HttpTools.java b/src/main/java/com/yutou/nas/utils/HttpTools.java
index 02e74d2..659b5f5 100644
--- a/src/main/java/com/yutou/nas/utils/HttpTools.java
+++ b/src/main/java/com/yutou/nas/utils/HttpTools.java
@@ -1,6 +1,6 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.utils.Interfaces.NetworkInterface;
diff --git a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java
index 06370e7..b85ab5e 100644
--- a/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java
+++ b/src/main/java/com/yutou/nas/utils/JellyfinAPIManager.java
@@ -1,7 +1,8 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Datas.Jellyfin.Episode;
import com.yutou.nas.Datas.Jellyfin.EpisodeData;
import com.yutou.nas.Datas.Jellyfin.ItemInfo;
@@ -25,13 +26,13 @@ public class JellyfinAPIManager {
public LibsItem getLibs(String key) {
HashMap header = getHeader();
String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items", header);
- JSONObject json = JSONObject.parseObject(httpText);
+ JSONObject json = JSON.parseObject(httpText);
if (key == null) {
return null;
}
JSONArray items = json.getJSONArray("Items");
for (Object o : items) {
- LibsItem item = JSONObject.parseObject(o.toString(), LibsItem.class);
+ LibsItem item = JSON.parseObject(o.toString(), LibsItem.class);
if (item.getName().equals(key)) {
return item;
}
@@ -41,15 +42,15 @@ public class JellyfinAPIManager {
public ItemInfo getInfo(String id) {
String http = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items/" + id, getHeader());
- return JSONObject.parseObject(http, ItemInfo.class);
+ return JSON.parseObject(http, ItemInfo.class);
}
public List getAllItem() {
String http = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items?SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Series&Recursive=true&Fields=PrimaryImageAspectRatio%2CBasicSyncInfo&ImageTypeLimit=1&EnableImageTypes=Primary%2CBackdrop%2CBanner%2CThumb&ParentId=28e774baf8f2fd279e7d58da9890a7d2", getHeader());
- JSONObject json = JSONObject.parseObject(http);
+ JSONObject json = JSON.parseObject(http);
JSONArray items = json.getJSONArray("Items");
- List list = JSONArray.parseArray(items.toJSONString(), LibsItem.class);
+ List list = JSON.parseArray(items.toJSONString(), LibsItem.class);
for (LibsItem item : list) {
item.setInfo(getInfo(item.getId()));
}
@@ -58,16 +59,16 @@ public class JellyfinAPIManager {
public List getLibsItems(String id) {
String httpText = HttpTools.https_get("http://192.168.31.88:8096/Users/e8a13675bb64466dbd81f1e5985ef8c7/Items?ParentId=" + id, getHeader());
- JSONObject json = JSONObject.parseObject(httpText);
+ JSONObject json = JSON.parseObject(httpText);
JSONArray items = json.getJSONArray("Items");
- return JSONArray.parseArray(items.toJSONString(), LibsItem.class);
+ return JSON.parseArray(items.toJSONString(), LibsItem.class);
}
public JSONObject getItemShows(String id) {
String data = HttpTools.https_get(String.format("http://192.168.31.88:8096/Shows/%s/Seasons?userId=e8a13675bb64466dbd81f1e5985ef8c7",
id
), getHeader());
- return JSONObject.parseObject(data);
+ return JSON.parseObject(data);
}
public JSONObject getEpisodesForJson(String parentID, String id) {
@@ -75,24 +76,24 @@ public class JellyfinAPIManager {
parentID,
id
), getHeader());
- return JSONObject.parseObject(data);
+ return JSON.parseObject(data);
}
public List getEpisodes(String parentId, String id) {
JSONObject json = getEpisodesForJson(parentId, id);
JSONArray episodes = json.getJSONArray("Items");
- return JSONArray.parseArray(episodes.toJSONString(), Episode.class);
+ return JSON.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);
+ return JSON.parseObject(data);
}
public EpisodeData getEpisodeData(String id) {
- return JSONObject.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class);
+ return JSON.parseObject(getEpisodesDataForJson(id).toString(), EpisodeData.class);
}
public String getPathForEpisode(String parentId, String id) {
@@ -227,19 +228,19 @@ public class JellyfinAPIManager {
System.out.println(_json.getString("Name"));
if (_json.getString("Name").equals("第一季")) {
- LibsItem _item = JSONObject.parseObject(_json.toJSONString(), LibsItem.class);
+ LibsItem _item = JSON.parseObject(_json.toJSONString(), LibsItem.class);
manager.saveJellyfinMetaData(
BangumiTools.getBangumiInfo(1424),
_item
);
} else if (_json.getString("Name").equals("第二季")) {
- LibsItem _item = JSONObject.parseObject(_json.toJSONString(), LibsItem.class);
+ LibsItem _item = JSON.parseObject(_json.toJSONString(), LibsItem.class);
manager.saveJellyfinMetaData(
BangumiTools.getBangumiInfo(3774),
_item
);
} else if (_json.getString("Name").contains("[剧场版]")) {
- LibsItem _item = JSONObject.parseObject(_json.toJSONString(), LibsItem.class);
+ LibsItem _item = JSON.parseObject(_json.toJSONString(), LibsItem.class);
manager.saveJellyfinMetaData(
BangumiTools.getBangumiInfo(12426),
_item
diff --git a/src/main/java/com/yutou/nas/utils/QQBotManager.java b/src/main/java/com/yutou/nas/utils/QQBotManager.java
index e45db1c..c425299 100644
--- a/src/main/java/com/yutou/nas/utils/QQBotManager.java
+++ b/src/main/java/com/yutou/nas/utils/QQBotManager.java
@@ -1,6 +1,6 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
diff --git a/src/main/java/com/yutou/nas/utils/RedisTools.java b/src/main/java/com/yutou/nas/utils/RedisTools.java
index 8ba2fd6..854536f 100644
--- a/src/main/java/com/yutou/nas/utils/RedisTools.java
+++ b/src/main/java/com/yutou/nas/utils/RedisTools.java
@@ -1,6 +1,7 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.interfaces.ObjectInterface;
import redis.clients.jedis.Jedis;
@@ -270,7 +271,7 @@ public class RedisTools {
public static void bot(String value) {
switch (value) {
case "getip":
- JSONObject json = JSONObject.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
+ JSONObject json = JSON.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
String ip = json.getString("ip");
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
break;
diff --git a/src/main/java/com/yutou/nas/utils/Tools.java b/src/main/java/com/yutou/nas/utils/Tools.java
index 74b1717..e8a6f6d 100644
--- a/src/main/java/com/yutou/nas/utils/Tools.java
+++ b/src/main/java/com/yutou/nas/utils/Tools.java
@@ -1,6 +1,7 @@
package com.yutou.nas.utils;
-import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
import com.yutou.nas.Controllers.UpdateIp;
import com.yutou.nas.interfaces.DownloadInterface;
import com.yutou.nas.interfaces.ObjectInterface;
@@ -206,7 +207,7 @@ public class Tools {
public static int checkWebLogin(HttpServletRequest request) {
JSONArray array = new JSONArray();
if (RedisTools.get("bean") != null) {
- array = JSONArray.parseArray(RedisTools.get("bean"));
+ array = JSON.parseArray(RedisTools.get("bean"));
}
if (array.contains(Tools.getRemoteAddress(request))) {
com.yutou.nas.utils.Log.i("IP已被封禁");