修复fastjson的代码
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<File> 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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<String, String> 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<LibsItem> 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<LibsItem> list = JSONArray.parseArray(items.toJSONString(), LibsItem.class);
|
||||
List<LibsItem> 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<LibsItem> 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<Episode> 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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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已被封禁");
|
||||
|
||||
Reference in New Issue
Block a user