This commit is contained in:
yutou 2021-05-13 12:00:24 +08:00
parent 017a01a0b8
commit d3a3a6e6ba
3 changed files with 14 additions and 25 deletions

View File

@ -10,6 +10,7 @@ import com.yutou.bilibili.BiliBili.Tools.SaveLive;
import com.yutou.bilibili.QQBot.QQBotManager;
import com.yutou.bilibili.Tools.AppTools;
import com.yutou.bilibili.Tools.Log;
import com.yutou.bilibili.Tools.RedisTools;
import com.yutou.bilibili.Tools.Tools;
import com.yutou.bilibili.interfaces.DownloadInterface;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveData;
@ -613,21 +614,14 @@ public class Live implements ApplicationContextAware {
}
public GiftData getGiftData(int id) {
for (GiftData data : LiveUtils.LiveGiftConfig.giftDataList) {
if (data.getId() == id) {
return data;
}
}
JSONObject item=JSONObject.parseObject(RedisTools.get("bili_gift_"+id,2));
GiftData data = new GiftData();
BilibiliLiveData liveData = service.queryGiftOfId(id);
if (liveData == null) {
return null;
}
data.setName(liveData.getGiftname());
data.setPrice(liveData.getPrice());
data.setIcon("");
data.setDesc("这是阿B没有收录的礼物金额可能不准无法判别为免费礼物");
data.setRights("?");
data.setPrice(item.getInteger("price"));
data.setName(item.getString("name"));
data.setId(item.getInteger("id"));
data.setRights(item.getString("rights"));
data.setIcon(item.getString("img_basic"));
data.setDesc(item.getString("desc"));
return data;
}
}

View File

@ -9,6 +9,7 @@ import com.yutou.bilibili.BiliBili.Services.IBiliBiliLiveService;
import com.yutou.bilibili.BiliBili.Tools.SaveLive;
import com.yutou.bilibili.Tools.AppTools;
import com.yutou.bilibili.Tools.Log;
import com.yutou.bilibili.Tools.RedisTools;
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
import org.springframework.util.StringUtils;
@ -389,7 +390,6 @@ public class LiveUtils {
@Resource
IBiliBiliLiveService service;
private static LiveGiftConfig config;
public static List<GiftData> giftDataList = new ArrayList<>();
public static LiveGiftConfig getInstance() {
if (config == null) {
@ -403,19 +403,14 @@ public class LiveUtils {
}
public void init() {
giftDataList = new ArrayList<>();
JSONObject json = http_get("https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/giftConfig?platform=pc");
if(json==null){
return;
}
JSONArray list = json.getJSONObject("data").getJSONArray("list");
for (Object o : list) {
JSONObject item = (JSONObject) o;
GiftData data = new GiftData();
data.setPrice(item.getInteger("price"));
data.setName(item.getString("name"));
data.setId(item.getInteger("id"));
data.setRights(item.getString("rights"));
data.setIcon(item.getString("img_basic"));
data.setDesc(item.getString("desc"));
giftDataList.add(data);
RedisTools.set(2,"bili_gift_"+item.getInteger("id"),item.toJSONString());
}
}

View File

@ -27,7 +27,7 @@ public class Log {
}
public static void i(String timer,int roomId,Object log){
String logFlag=RedisTools.get("live-log",1);
if(logFlag!=null&&logFlag.equals("true")) {
if("true".equals(logFlag)) {
getLogger("[" + timer.replace(":", "_") + "]" + roomId).log(Level.INFO, log.toString());
}
}