From 953f1336a8e115160031d97da320d4513def92c2 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 20 May 2021 21:16:02 +0800 Subject: [PATCH] update --- src/main/java/com/yutou/bilibili/BiliBili/Live.java | 3 ++- src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java | 3 +++ .../BiliBili/Services/impl/BiliBiliLiveServiceImpl.java | 6 ++++-- src/main/java/com/yutou/bilibili/BilibiliApplication.java | 2 +- src/main/java/com/yutou/bilibili/Test/TestController.java | 2 ++ src/main/java/com/yutou/bilibili/Tools/Log.java | 6 ++++-- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Live.java b/src/main/java/com/yutou/bilibili/BiliBili/Live.java index 2c848fc..9e0cc10 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/Live.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/Live.java @@ -174,6 +174,7 @@ public class Live implements ApplicationContextAware { heartBeattimer.schedule(new sendHeartbeat(), 2000, 20000); init = false; } + Log.i(AppTools.getToDayTimeToString(startTime),roomId,LiveUtils.getHex(bytes.array()).substring(0,16)); decompress(bytes.array()); } @@ -331,7 +332,7 @@ public class Live implements ApplicationContextAware { * @param msg 数据json * @param bytes 原始hex数据 */ - public synchronized void processData(String msg, byte[] bytes) { + public void processData(String msg, byte[] bytes) { try { JSONObject json = JSONObject.parseObject(msg); JSONObject data; diff --git a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java index 77117d9..2b86ef1 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/LiveUtils.java @@ -52,6 +52,9 @@ public class LiveUtils { } } } + public static String getHex(byte[] bytes){ + return DatatypeConverter.printHexBinary(bytes); + } public static byte[] dec(byte[] data) { byte[] output = new byte[0]; diff --git a/src/main/java/com/yutou/bilibili/BiliBili/Services/impl/BiliBiliLiveServiceImpl.java b/src/main/java/com/yutou/bilibili/BiliBili/Services/impl/BiliBiliLiveServiceImpl.java index 8c0ecc5..377a64a 100644 --- a/src/main/java/com/yutou/bilibili/BiliBili/Services/impl/BiliBiliLiveServiceImpl.java +++ b/src/main/java/com/yutou/bilibili/BiliBili/Services/impl/BiliBiliLiveServiceImpl.java @@ -66,8 +66,9 @@ public class BiliBiliLiveServiceImpl implements IBiliBiliLiveService { @Override public BilibiliUpInfo queryUp(BilibiliUpInfo data) { - if (data.getRoomid() == null) + if (data.getRoomid() == null) { return null; + } return queryUpToRoomId(data.getRoomid()); } @@ -124,6 +125,7 @@ public class BiliBiliLiveServiceImpl implements IBiliBiliLiveService { if (!isLive()) { return false; } + return liveDataDao.insert(data) > 0; } @@ -235,7 +237,7 @@ public class BiliBiliLiveServiceImpl implements IBiliBiliLiveService { public boolean isLive() { String flag = configService.getConfig(Config.BILI_LIVE_FLAG); if (flag != null) { - return !flag.equals("0"); + return !"0".equals(flag); } return true; } diff --git a/src/main/java/com/yutou/bilibili/BilibiliApplication.java b/src/main/java/com/yutou/bilibili/BilibiliApplication.java index 7702d51..9774f7c 100644 --- a/src/main/java/com/yutou/bilibili/BilibiliApplication.java +++ b/src/main/java/com/yutou/bilibili/BilibiliApplication.java @@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import; @SpringBootApplication public class BilibiliApplication { - public static String version="0.7"; + public static String version="0.7.1"; public static void main(String[] args) { QQBotManager.getInstance().init(); diff --git a/src/main/java/com/yutou/bilibili/Test/TestController.java b/src/main/java/com/yutou/bilibili/Test/TestController.java index 9428f0c..5fc25f7 100644 --- a/src/main/java/com/yutou/bilibili/Test/TestController.java +++ b/src/main/java/com/yutou/bilibili/Test/TestController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yutou.bilibili.BiliBili.Live; +import com.yutou.bilibili.BiliBili.LiveUtils; import com.yutou.bilibili.BiliBili.Tools.LiveT; import com.yutou.bilibili.BiliBili.Tools.SaveLive; import org.springframework.stereotype.Controller; @@ -29,6 +30,7 @@ public class TestController { JSONObject item=new JSONObject(); item.put("info", JSON.toJSON(live.getInfo())); item.put("data",JSON.toJSON(live.geData())); + item.put("isLive", LiveUtils.isLivePlayer(live.getInfo().getRoomid())); array.add(item); } json.put("array",array); diff --git a/src/main/java/com/yutou/bilibili/Tools/Log.java b/src/main/java/com/yutou/bilibili/Tools/Log.java index 5c9d85a..d092d99 100644 --- a/src/main/java/com/yutou/bilibili/Tools/Log.java +++ b/src/main/java/com/yutou/bilibili/Tools/Log.java @@ -10,8 +10,9 @@ import java.util.logging.Logger; public class Log { private static Logger logger; public static void i(Object log) { - if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) + if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) { return; + } System.out.printf("[%s]%s%n", AppTools.getToDayNowTimeToString(), log @@ -20,8 +21,9 @@ public class Log { } public static void e(Exception e) { - if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) + if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "logout"))) { return; + } i(e.getMessage()); e.printStackTrace(); }