修复直播状态

This commit is contained in:
Yutousama 2022-04-11 19:02:24 +08:00
parent d9ec693694
commit 78abe9a16b

View File

@ -53,6 +53,7 @@ public class LiveUtils {
} }
} }
} }
public static String getHex(byte[] bytes) { public static String getHex(byte[] bytes) {
return DatatypeConverter.printHexBinary(bytes); return DatatypeConverter.printHexBinary(bytes);
} }
@ -351,13 +352,19 @@ public class LiveUtils {
return http_get("https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" + roomId + "&protocol=0,1&format=0,1,2&codec=0,1&qn=10000&platform=web&ptype=8"); return http_get("https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" + roomId + "&protocol=0,1&format=0,1,2&codec=0,1&qn=10000&platform=web&ptype=8");
} }
public static boolean getLiveState(int roomId) { public static boolean getLiveState(int roomId) {
return liveStateMap.get(roomId); return liveStateMap.get(roomId);
} }
public static void reloadLiveState(int roomId) { public static void reloadLiveState(int roomId) {
JSONObject json = getLiveInfo(roomId); JSONObject json = getLiveInfo(roomId);
if (json != null) { if (json != null) {
try {
liveStateMap.put(roomId, json.getJSONObject("data").getInteger("live_status") == 1); liveStateMap.put(roomId, json.getJSONObject("data").getInteger("live_status") == 1);
} catch (Exception e) {
System.out.println("json = " + json);
}
} }
} }