63 lines
1.7 KiB
Java
63 lines
1.7 KiB
Java
package com.yutou.bilibili.BiliBili;
|
|
|
|
import com.yutou.bilibili.BiliBili.Tools.SaveLive;
|
|
import com.yutou.bilibili.Tools.AppTools;
|
|
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import java.io.File;
|
|
import java.util.Timer;
|
|
|
|
public class LiveController {
|
|
private static LiveController controller;
|
|
private Timer timer;
|
|
|
|
public static LiveController getInstance() {
|
|
if (controller == null) {
|
|
controller = new LiveController();
|
|
}
|
|
return controller;
|
|
}
|
|
|
|
private LiveController() {
|
|
init();
|
|
}
|
|
|
|
private void init() {
|
|
|
|
}
|
|
|
|
public void updateUpInfo(BilibiliUpInfo data) {
|
|
Live live = LiveUtils.liveContains(data);
|
|
if (live != null) {
|
|
live.setSaveDanmo(data.getSavedanmu() == 1);
|
|
boolean saveLive=SaveLive.getInstance().checkLive(data.getRoomid());
|
|
if(data.getSavelive()==1){
|
|
if(!saveLive){
|
|
SaveLive.getInstance().addLive(live);
|
|
}
|
|
}else{
|
|
if(saveLive){
|
|
SaveLive.getInstance().stop(data.getRoomid());
|
|
}
|
|
}
|
|
}
|
|
if (data.getEnable()==1||data.getOfflinelistening()==1) {
|
|
if (live == null) {
|
|
try {
|
|
live=new Live();
|
|
live.add(data.getRoomid(), !StringUtils.isEmpty(AppTools.readFile(new File("cookies.json"))));
|
|
live.start();
|
|
} catch (Exception e) {
|
|
com.yutou.bilibili.Tools.Log.e(e);
|
|
}
|
|
}
|
|
} else {
|
|
if (live != null) {
|
|
live.stop();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|