新增日志输出类
修复直播检测不绿的情况
This commit is contained in:
parent
51a0a3d111
commit
44272a609f
16
.mvn/wrapper/MavenWrapperDownloader.java
vendored
16
.mvn/wrapper/MavenWrapperDownloader.java
vendored
@ -47,9 +47,9 @@ public class MavenWrapperDownloader {
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
com.yutou.bilibili.Tools.Log.i("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
com.yutou.bilibili.Tools.Log.i("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
@ -63,7 +63,7 @@ public class MavenWrapperDownloader {
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
com.yutou.bilibili.Tools.Log.i("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
@ -74,22 +74,22 @@ public class MavenWrapperDownloader {
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: " + url);
|
||||
com.yutou.bilibili.Tools.Log.i("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
com.yutou.bilibili.Tools.Log.i(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
com.yutou.bilibili.Tools.Log.i("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
com.yutou.bilibili.Tools.Log.i("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
com.yutou.bilibili.Tools.Log.i("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<meta charset="UTF-8">
|
||||
<title>DD监视器</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="layui-header">
|
||||
<ul class="layui-nav" lay-filter="" style="background-color: #1772B4;">
|
||||
<li class="layui-nav-item">DD监视器</li>
|
||||
<div id="admin" style="display: inline-block; font-size: 0px;">
|
||||
<li class="layui-nav-item"><a href="/html/body/bilibili/upInfo.html">UP管理</a>
|
||||
|
||||
</li>
|
||||
</div>
|
||||
<li class="layui-nav-item">
|
||||
<a href="/html/body/bilibili/realTimeData.html">实时数据</a>
|
||||
</li>
|
||||
<li class="layui-nav-item">
|
||||
<a href="/html/body/bilibili/overview.html">数据统计</a>
|
||||
</li>
|
||||
<li class="layui-nav-item" id='icon'>
|
||||
<a href="javascript:;" id="login"><img src="https://static.hdslb.com/images/akari.jpg" class="layui-nav-img" id="icon_img"><span
|
||||
id='login_text'>登录</span></a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a href="javascript:;" id="logout">退了</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/js/qrcode.min.js"></script>
|
||||
<script>
|
||||
let loginStatus = false;
|
||||
$.post('/user/get/test.do',function (json) {
|
||||
$('#login_text').text(json.data.uname);
|
||||
$('#icon_img').attr("src",json.data.icon);
|
||||
loginStatus=true;
|
||||
|
||||
})
|
||||
$('#login').click(function () {
|
||||
if (loginStatus) {
|
||||
return;
|
||||
}
|
||||
$.post('/login/login.do',function (json) {
|
||||
console.log(json)
|
||||
layer.open({
|
||||
title: "BiliBili客户端扫描登陆",
|
||||
content: "<div id=\"qrcode\"></div>",
|
||||
success: function () {
|
||||
new QRCode(document.getElementById("qrcode"), json.url);
|
||||
},
|
||||
yes: function (index) {
|
||||
layer.close(index)
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
$(document).ready(function () {
|
||||
let mobile = layui.device().mobile;
|
||||
if (mobile) {
|
||||
$('.layui-body').css('left', '0')
|
||||
$('.layui-body').css('top', '150px')
|
||||
$('.layui-body').css('height', '200%')
|
||||
$('#icon').css('float', 'none')
|
||||
|
||||
|
||||
} else {
|
||||
$('.layui-body').css('padding-right', '100px')
|
||||
$('#icon').css('float', 'right')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
</html>
|
@ -202,6 +202,7 @@
|
||||
}
|
||||
for (let i in json.data.live) {
|
||||
$('#' + json.data.live[i].roomid).css('color', '#8FE18F')
|
||||
console.log('绿了:'+json.data.live[i].roomid)
|
||||
}
|
||||
|
||||
$.post('/user/get/test.do',function (json) {
|
||||
|
@ -110,7 +110,7 @@ public class BiliVideoController {
|
||||
File file = new File("ffmpeg_out" + File.separator + time + File.separator + fileName);
|
||||
if (!file.exists())
|
||||
file = new File("live" + File.separator + time + File.separator + fileName);
|
||||
System.out.println(file.getAbsolutePath());
|
||||
com.yutou.bilibili.Tools.Log.i(file.getAbsolutePath());
|
||||
return AppTools.getFile(file);
|
||||
}
|
||||
@ResponseBody
|
||||
|
@ -40,7 +40,7 @@ public class OverviewController {
|
||||
, LiveData.GUARD_BUY}));
|
||||
data.put("price", manager.queryPriceSize(upData.getRoomid(), startTime, endTime));
|
||||
long h = (endTime.getTime() - startTime.getTime()) % (1000 * 24 * 60 * 60) / (1000 * 60 * 60);
|
||||
System.out.println("相差:" + h + "小时");
|
||||
com.yutou.bilibili.Tools.Log.i("相差:" + h + "小时");
|
||||
try {
|
||||
data.put("hprice", data.getInteger("price") / h);
|
||||
} catch (Exception e) {
|
||||
@ -52,7 +52,7 @@ public class OverviewController {
|
||||
List<BilibiliLiveInfo> infos=manager.queryLiveInfo(upData,startTime,endTime);
|
||||
int maxUser=0;
|
||||
for (BilibiliLiveInfo info : infos) {
|
||||
System.out.println(info);
|
||||
com.yutou.bilibili.Tools.Log.i(info);
|
||||
maxUser+=info.getUserindex()+info.getVipuserindex();
|
||||
JSONObject item=new JSONObject();
|
||||
String nowTime = new SimpleDateFormat("HH").format(info.getSubtime());
|
||||
|
@ -10,6 +10,7 @@ import com.yutou.bilibili.BiliBili.Services.IBiliBiliLiveService;
|
||||
import com.yutou.bilibili.BiliBili.Tools.BiliTools;
|
||||
import com.yutou.bilibili.Services.IUserService;
|
||||
import com.yutou.bilibili.Tools.AppTools;
|
||||
import com.yutou.bilibili.Tools.Log;
|
||||
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
||||
import com.yutou.bilibili.mybatis.model.UUser;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -41,7 +42,7 @@ public class UpInfoController {
|
||||
return json;
|
||||
}
|
||||
List<BilibiliUpInfo> upDataList =service.getUpInfo(user.getId(),user.getPower());
|
||||
System.out.println("UP用户数:" + upDataList.size());
|
||||
com.yutou.bilibili.Tools.Log.i("UP用户数:" + upDataList.size());
|
||||
json.put("code", 0);
|
||||
json.put("data", JSONArray.toJSON(upDataList));
|
||||
return json;
|
||||
@ -54,7 +55,7 @@ public class UpInfoController {
|
||||
if (BiliTools.checkout(upData) != null) {
|
||||
upData.setEnable(0);
|
||||
upData = BiliTools.checkout(upData);
|
||||
System.out.println(upData);
|
||||
com.yutou.bilibili.Tools.Log.i(upData);
|
||||
boolean flag = service.addUpInfo(upData);
|
||||
if (flag) {
|
||||
json.put("code", 0);
|
||||
@ -74,7 +75,7 @@ public class UpInfoController {
|
||||
@RequestMapping("/upinfo/set/update.do")
|
||||
public JSONObject update(BilibiliUpInfo upData) {
|
||||
JSONObject json = new JSONObject();
|
||||
System.out.println("old data ="+upData);
|
||||
com.yutou.bilibili.Tools.Log.i("old data ="+upData);
|
||||
BilibiliUpInfo old = service.queryUp(upData);
|
||||
if (!old.getUrl().equals(upData.getUrl())) {
|
||||
upData = BiliTools.checkout(upData);
|
||||
@ -84,7 +85,7 @@ public class UpInfoController {
|
||||
upData.setOfflinelistening(0);
|
||||
}
|
||||
}
|
||||
System.out.println("save data = "+upData);
|
||||
com.yutou.bilibili.Tools.Log.i("save data = "+upData);
|
||||
boolean flag = service.updateUpInfo(upData);
|
||||
if (flag) {
|
||||
LiveController.getInstance().updateUpInfo(upData);
|
||||
@ -101,7 +102,7 @@ public class UpInfoController {
|
||||
@RequestMapping("/upinfo/set/delete.do")
|
||||
public JSONObject delete(BilibiliUpInfo upData) {
|
||||
JSONObject json = new JSONObject();
|
||||
System.out.println(upData);
|
||||
com.yutou.bilibili.Tools.Log.i(upData);
|
||||
boolean flag = service.deleteUp(upData);
|
||||
if (flag) {
|
||||
json.put("code", 0);
|
||||
@ -124,7 +125,6 @@ public class UpInfoController {
|
||||
@RequestMapping("/upinfo/get/liveInfo.do")
|
||||
public JSONObject liveInfo() {
|
||||
List<BilibiliUpInfo> list = service.getUpInfo();
|
||||
List<Live> lives=Live.lives;
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject data = new JSONObject();
|
||||
JSONArray info = new JSONArray();
|
||||
@ -141,7 +141,7 @@ public class UpInfoController {
|
||||
info.add(JSON.toJSON(up));
|
||||
}
|
||||
}
|
||||
for (Live live : lives) {
|
||||
for (Live live : Live.lives) {
|
||||
if(live.geData().getLive()==1){
|
||||
liveArray.add(JSON.toJSON(live.geData()));
|
||||
}
|
||||
|
@ -78,12 +78,13 @@ public class Live implements ApplicationContextAware {
|
||||
info.setUserindex(0);
|
||||
Live.lives.add(this);
|
||||
updateUpInfo();
|
||||
System.out.println("roomId = " + roomId + ", isLogin = " + isLogin);
|
||||
com.yutou.bilibili.Tools.Log.i("roomId = " + roomId + ", isLogin = " + isLogin);
|
||||
}
|
||||
|
||||
private void updateUpInfo() {
|
||||
try {
|
||||
upData = service.queryUp(upData);
|
||||
upData.setLive(1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -102,6 +103,10 @@ public class Live implements ApplicationContextAware {
|
||||
upData.setLive(1);
|
||||
}
|
||||
String url = LiveUtils.getLiveUrl(roomId);
|
||||
if(url==null){
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
HashMap<String, String> header = new HashMap<String, String>();
|
||||
header.put("Sec-WebSocket-Extensions", "permessage-deflate; client_max_window_bits");
|
||||
header.put("Sec-WebSocket-Key", "tORCZd8AI6xIyvqvgvI1Vw==");
|
||||
@ -120,7 +125,7 @@ public class Live implements ApplicationContextAware {
|
||||
@Override
|
||||
public void onOpen(ServerHandshake serverHandshake) {
|
||||
time = System.currentTimeMillis();
|
||||
System.out.println("ws: ok");
|
||||
com.yutou.bilibili.Tools.Log.i("ws: ok");
|
||||
try {
|
||||
likeLive();
|
||||
} catch (Exception e) {
|
||||
@ -147,7 +152,7 @@ public class Live implements ApplicationContextAware {
|
||||
|
||||
@Override
|
||||
public void onClose(int i, String s, boolean b) {
|
||||
System.out.println("连接时间:" + (System.currentTimeMillis() - time));
|
||||
com.yutou.bilibili.Tools.Log.i("连接时间:" + (System.currentTimeMillis() - time));
|
||||
if (upData.getOfflinelistening() == 1) {
|
||||
System.err.println(roomId + " 断开连接,重连...");
|
||||
try {
|
||||
@ -169,7 +174,7 @@ public class Live implements ApplicationContextAware {
|
||||
@Override
|
||||
public void onClosing(int code, String reason, boolean remote) {
|
||||
super.onClosing(code, reason, remote);
|
||||
System.out.println("code = " + code + ", reason = " + reason + ", remote = " + remote);
|
||||
com.yutou.bilibili.Tools.Log.i("code = " + code + ", reason = " + reason + ", remote = " + remote);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -189,7 +194,7 @@ public class Live implements ApplicationContextAware {
|
||||
SaveLive.getInstance().stop(roomId);
|
||||
}
|
||||
Live.lives.remove(this);
|
||||
System.out.printf("退出%d直播间%n", roomId);
|
||||
com.yutou.bilibili.Tools.Log.i("退出"+roomId+"直播间");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +226,7 @@ public class Live implements ApplicationContextAware {
|
||||
json.put("clientver", "2.6.36");
|
||||
json.put("type", 2);
|
||||
json.put("key", http.getJSONObject("data").getString("token"));
|
||||
System.out.println(json.toJSONString());
|
||||
com.yutou.bilibili.Tools.Log.i(json.toJSONString());
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(LiveUtils.toLH(json.toJSONString().length() + 16));
|
||||
outputStream.write(new byte[]{0, 16, 0, 1, 0, 0, 0, 7, 0, 0, 0, 1});
|
||||
@ -251,19 +256,18 @@ public class Live implements ApplicationContextAware {
|
||||
} else {
|
||||
try {
|
||||
JSONObject json = JSONObject.parseObject(new String(bytes, StandardCharsets.UTF_8));
|
||||
System.out.println(json);
|
||||
com.yutou.bilibili.Tools.Log.i(json.toJSONString());
|
||||
} catch (Exception e) {
|
||||
popular = LiveUtils.bytesToInt2(bytes, 0);
|
||||
info.setPopular(popular);
|
||||
}
|
||||
}
|
||||
checkLive();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("----------ERROR----------");
|
||||
System.out.println(new String(data, StandardCharsets.UTF_8));
|
||||
com.yutou.bilibili.Tools.Log.i("----------ERROR----------");
|
||||
com.yutou.bilibili.Tools.Log.i(new String(data, StandardCharsets.UTF_8));
|
||||
LiveUtils.printHex(LiveUtils.dec(data));
|
||||
System.out.println(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()));
|
||||
com.yutou.bilibili.Tools.Log.i(new SimpleDateFormat("HH:mm:ss.SSS").format(new Date()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +297,7 @@ public class Live implements ApplicationContextAware {
|
||||
|
||||
switch (json.getString("cmd")) {
|
||||
case "INTERACT_WORD"://普通用户进直播间
|
||||
// System.out.println(json.getJSONObject("data").getString("uname") + " 进入到直播间");
|
||||
// com.yutou.bilibili.Tools.Log.i(json.getJSONObject("data").getString("uname") + " 进入到直播间");
|
||||
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";
|
||||
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
||||
liveData.setType(LiveData.INTERACT_WORD);
|
||||
@ -317,7 +321,7 @@ public class Live implements ApplicationContextAware {
|
||||
}
|
||||
danmuManager.addLiveData(liveData);*/
|
||||
}
|
||||
System.out.println(json);
|
||||
// com.yutou.bilibili.Tools.Log.i(json.toJSONString());
|
||||
break;
|
||||
case "SEND_GIFT"://送礼
|
||||
data = json.getJSONObject("data");
|
||||
@ -376,7 +380,7 @@ public class Live implements ApplicationContextAware {
|
||||
service.addLiveData(liveData);
|
||||
break;
|
||||
case "ENTRY_EFFECT"://舰长进直播间
|
||||
// System.out.println("[舰长]" + json.getJSONObject("data").getString("uid") + " 进入到直播间");
|
||||
// com.yutou.bilibili.Tools.Log.i("[舰长]" + json.getJSONObject("data").getString("uid") + " 进入到直播间");
|
||||
info.setVipuserindex(info.getVipuserindex() + 1);
|
||||
danmu = "[舰长]" + json.getJSONObject("data").getString("uid") + " 进入到直播间";
|
||||
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
||||
@ -439,10 +443,10 @@ public class Live implements ApplicationContextAware {
|
||||
case "PK_BATTLE_PRE":
|
||||
|
||||
|
||||
//System.out.println(msg);
|
||||
//com.yutou.bilibili.Tools.Log.i(msg);
|
||||
break;
|
||||
default:
|
||||
System.out.println(msg);
|
||||
com.yutou.bilibili.Tools.Log.i(msg);
|
||||
liveData = new BilibiliLiveData();
|
||||
liveData.setType(LiveData.UNKNOWN_MESSAGE);
|
||||
liveData.setUid(-1);
|
||||
@ -458,9 +462,8 @@ public class Live implements ApplicationContextAware {
|
||||
processData(new String(bytes, StandardCharsets.UTF_8), null);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
System.out.println(msg);
|
||||
System.out.println("---------ERROR !!-----");
|
||||
System.out.println();
|
||||
com.yutou.bilibili.Tools.Log.i(msg);
|
||||
com.yutou.bilibili.Tools.Log.i("---------ERROR !!-----");
|
||||
LiveUtils.printHex(bytes);
|
||||
}
|
||||
|
||||
@ -516,7 +519,7 @@ public class Live implements ApplicationContextAware {
|
||||
stop();
|
||||
}
|
||||
try {
|
||||
// System.out.println("-------发送心跳--------");
|
||||
// com.yutou.bilibili.Tools.Log.i("-------发送心跳--------");
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(LiveUtils.toLH("[object Object]".length() + 16));
|
||||
outputStream.write(new byte[]{0, 16, 0, 1, 0, 0, 0, 2, 0, 0, 0, 1});
|
||||
@ -525,8 +528,8 @@ public class Live implements ApplicationContextAware {
|
||||
client.send(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(client.isClosed());
|
||||
System.out.println(client.isOpen());
|
||||
com.yutou.bilibili.Tools.Log.i(client.isClosed());
|
||||
com.yutou.bilibili.Tools.Log.i(client.isOpen());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.yutou.bilibili.BiliBili;
|
||||
|
||||
import com.yutou.bilibili.BiliBili.Datas.BiliBiliUpData;
|
||||
import com.yutou.bilibili.BiliBili.Datas.GiftData;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.bilibili.BiliBili.Services.IBiliBiliLiveService;
|
||||
import com.yutou.bilibili.Tools.AppTools;
|
||||
import com.yutou.bilibili.Tools.Log;
|
||||
import com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@ -20,7 +22,7 @@ import java.util.*;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class LiveUtils {
|
||||
private static String cookie=null;
|
||||
private static String cookie = null;
|
||||
|
||||
public LiveUtils() {
|
||||
|
||||
@ -29,19 +31,21 @@ public class LiveUtils {
|
||||
|
||||
public static String getLiveUrl(int roomId) {
|
||||
JSONObject json = http_get("https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo?id=" + roomId + "&type=0");
|
||||
if (json != null)
|
||||
return "wss://" + json.getJSONObject("data").getJSONArray("host_list").getJSONObject(0).getString("host") + "/sub";
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void printHex(byte[] bytes) {
|
||||
String str = DatatypeConverter.printHexBinary(bytes);
|
||||
for (int i = 0; i < str.length(); i = i + 4) {
|
||||
if (i % 32 == 0 && i != 0) {
|
||||
System.out.println();
|
||||
com.yutou.bilibili.Tools.Log.i("\n");
|
||||
}
|
||||
if (str.length() - i > 4) {
|
||||
System.out.print(str.substring(i, i + 4));
|
||||
} else {
|
||||
System.out.println(str.substring(i));
|
||||
com.yutou.bilibili.Tools.Log.i(str.substring(i));
|
||||
}
|
||||
System.out.print(" ");
|
||||
}
|
||||
@ -100,7 +104,7 @@ public class LiveUtils {
|
||||
list.add(new String(datas.array(), StandardCharsets.UTF_8));
|
||||
} else {
|
||||
try {
|
||||
// System.out.println("datas size = " + size);
|
||||
// com.yutou.bilibili.Tools.Log.i("datas size = " + size);
|
||||
if (size > 1000000000) {
|
||||
try {
|
||||
JSONObject.parseObject(new String(bytes));
|
||||
@ -201,7 +205,7 @@ public class LiveUtils {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new JSONObject();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject http_post(String url, String body) {
|
||||
@ -307,7 +311,11 @@ public class LiveUtils {
|
||||
|
||||
public static boolean isLivePlayer(int roomId) {
|
||||
JSONObject json = http_get("https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" + roomId);
|
||||
System.out.println("直播检测:" + roomId+" > "+(json.getJSONObject("data").getJSONObject("room_info").getInteger("live_status") == 1));
|
||||
if (json == null)
|
||||
return false;
|
||||
BilibiliUpInfo upData = new BilibiliUpInfo();
|
||||
upData.setRoomid(roomId);
|
||||
Log.i("直播检测:" + roomId + " > " + (json.getJSONObject("data").getJSONObject("room_info").getInteger("live_status") == 1) + " 录播器:" + liveContains(upData));
|
||||
return json.getJSONObject("data").getJSONObject("room_info").getInteger("live_status") == 1;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class BiliBiliLiveServiceImpl implements IBiliBiliLiveService {
|
||||
return upInfos;
|
||||
}
|
||||
upInfos = upInfoDao.queryToRoomIds(ids);
|
||||
System.out.println("list = " + upInfos.size());
|
||||
com.yutou.bilibili.Tools.Log.i("list = " + upInfos.size());
|
||||
return upInfos;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ public class BiliTools {
|
||||
}
|
||||
BilibiliUpInfo upData = new BilibiliUpInfo();
|
||||
JSONObject json = LiveUtils.http_get("https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?room_id=" + url.replace("https://live.bilibili.com/", "").split("\\?")[0]);
|
||||
System.out.println(json);
|
||||
com.yutou.bilibili.Tools.Log.i(json);
|
||||
String roomId = json.getJSONObject("data").getJSONObject("room_info").getInteger("room_id") + "";
|
||||
String name = json.getJSONObject("data").getJSONObject("anchor_info").getJSONObject("base_info").getString("uname");
|
||||
System.out.println(roomId);
|
||||
System.out.println(name);
|
||||
com.yutou.bilibili.Tools.Log.i(roomId);
|
||||
com.yutou.bilibili.Tools.Log.i(name);
|
||||
upData.setRoomid(Integer.parseInt(roomId));
|
||||
upData.setName(name);
|
||||
upData.setUrl(url);
|
||||
|
@ -26,11 +26,11 @@ public class LiveT implements ApplicationContextAware {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
System.out.println("初始化2");
|
||||
com.yutou.bilibili.Tools.Log.i("初始化2");
|
||||
}
|
||||
|
||||
public LiveT() {
|
||||
System.out.println("初始化");
|
||||
com.yutou.bilibili.Tools.Log.i("初始化");
|
||||
}
|
||||
|
||||
public void add(int a){
|
||||
|
@ -54,7 +54,7 @@ public class SaveLive {
|
||||
private long timer = 0;
|
||||
|
||||
public void stop(int roomId) {
|
||||
System.out.println("t停止录播:" + roomId + " time=" + (System.currentTimeMillis() - timer));
|
||||
com.yutou.bilibili.Tools.Log.i("t停止录播:" + roomId + " time=" + (System.currentTimeMillis() - timer));
|
||||
saveList.remove(roomId + "");
|
||||
|
||||
if(downloads.containsKey(roomId)){
|
||||
@ -107,7 +107,7 @@ public class SaveLive {
|
||||
super.run();
|
||||
String url = getLiveUrl(roomId);
|
||||
try {
|
||||
System.out.println("开始录制:" + roomId);
|
||||
com.yutou.bilibili.Tools.Log.i("开始录制:" + roomId);
|
||||
HttpURLConnection connection = LiveUtils.getBiliHttpGet(url, LiveUtils.getCookie());
|
||||
heartbeat = new Timer();
|
||||
//Heartbeat beat = new Heartbeat();
|
||||
@ -134,7 +134,7 @@ public class SaveLive {
|
||||
}
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
System.out.println("录制完成:" + roomId + " save = " + isSave + " len = " + len);
|
||||
com.yutou.bilibili.Tools.Log.i("录制完成:" + roomId + " save = " + isSave + " len = " + len);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -151,16 +151,16 @@ public class SaveLive {
|
||||
JSONObject userHear = new JSONObject();
|
||||
JSONObject cookie = JSONObject.parseObject(LiveUtils.getFile("cookies.json"));
|
||||
hearBeat = LiveUtils.http_get("https://api.live.bilibili.com/relation/v1/Feed/heartBeat");
|
||||
System.out.printf(hearBeat+" \t");
|
||||
com.yutou.bilibili.Tools.Log.i(hearBeat+" \t");
|
||||
hearBeat = LiveUtils.http_get(String.format("https://live-trace.bilibili.com/xlive/rdata-interface/v1/heartbeat/webHeartBeat?hb=%s&pf=web", URLEncoder.encode(new String(Base64.getEncoder().encode(String.format("%d|%d|1|0",nextInterval, roomId).getBytes(StandardCharsets.UTF_8))), "UTF-8")));
|
||||
System.out.printf(hearBeat+"\t");
|
||||
com.yutou.bilibili.Tools.Log.i(hearBeat+"\t");
|
||||
nextInterval=hearBeat.getJSONObject("data").getInteger("next_interval");
|
||||
System.out.println("next = "+nextInterval);
|
||||
com.yutou.bilibili.Tools.Log.i("next = "+nextInterval);
|
||||
userHear.put("csrf_token",cookie.getString("bili_jct"));
|
||||
userHear.put("csrf",cookie.getString("bili_jct"));
|
||||
userHear.put("visit_id","");
|
||||
hearBeat=LiveUtils.http_post("https://api.live.bilibili.com/User/userOnlineHeart", HttpTools.toUrlParams(userHear));
|
||||
System.out.println("["+AppTools.getToDayNowTimeToString()+"]"+hearBeat);
|
||||
com.yutou.bilibili.Tools.Log.i("["+AppTools.getToDayNowTimeToString()+"]"+hearBeat);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class APIFilter implements Filter {
|
||||
url = tmp.split(tmp.split("/")[tmp.split("/").length - 1])[0];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("无权限请求:"+tmp);
|
||||
com.yutou.bilibili.Tools.Log.i("无权限请求:"+tmp);
|
||||
return;
|
||||
}
|
||||
JSONArray powers = JSONArray.parseArray(user.getPower());
|
||||
|
@ -163,7 +163,7 @@ public class AppTools {
|
||||
public static String deleteCookie(HttpServletRequest request, HttpServletResponse response, String key) {
|
||||
for (Cookie cookie : request.getCookies()) {
|
||||
if (cookie.getName().equals(key)) {
|
||||
System.out.println("删除key=" + key);
|
||||
com.yutou.bilibili.Tools.Log.i("删除key=" + key);
|
||||
cookie.setMaxAge(0);
|
||||
cookie.setPath("/");
|
||||
cookie.setValue(null);
|
||||
@ -273,7 +273,7 @@ public class AppTools {
|
||||
|
||||
}else{
|
||||
if(srcFileName.equals("Activity.smali")){
|
||||
System.out.println("文件夹已存在:"+destFileName);
|
||||
com.yutou.bilibili.Tools.Log.i("文件夹已存在:"+destFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@ public class ExcelUtils implements ApplicationContextAware {
|
||||
public static File getInstance(int roomId, Date startTime, Date endTime,String fileName) {
|
||||
ExcelUtils utils = new ExcelUtils();
|
||||
long timer=System.currentTimeMillis();
|
||||
System.out.println("开始注入bean");
|
||||
com.yutou.bilibili.Tools.Log.i("开始注入bean");
|
||||
utils.dataDao = getBean(BilibiliLiveDataDao.class);
|
||||
utils.infoDao = getBean(BilibiliLiveInfoDao.class);
|
||||
System.out.println("注入完毕:"+(System.currentTimeMillis()-timer));
|
||||
com.yutou.bilibili.Tools.Log.i("注入完毕:"+(System.currentTimeMillis()-timer));
|
||||
return utils.initTable(roomId, startTime, endTime,fileName);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class ExcelUtils implements ApplicationContextAware {
|
||||
|
||||
private File initTable(int roomId, Date startTime, Date endTime,String fileName) {
|
||||
long timer=System.currentTimeMillis();
|
||||
System.out.println("进入统计:"+timer);
|
||||
com.yutou.bilibili.Tools.Log.i("进入统计:"+timer);
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet liveData = workbook.createSheet("直播数据");
|
||||
Sheet liveInfo = workbook.createSheet("小时统计");
|
||||
@ -66,7 +66,7 @@ public class ExcelUtils implements ApplicationContextAware {
|
||||
createCell(infoRow.createCell(5), "送礼人数");
|
||||
createCell(infoRow.createCell(6), "记录时间");
|
||||
|
||||
System.out.println("表头插入完毕:"+(System.currentTimeMillis()-timer));
|
||||
com.yutou.bilibili.Tools.Log.i("表头插入完毕:"+(System.currentTimeMillis()-timer));
|
||||
List<BilibiliLiveData> dataList = dataDao.queryLiveData(roomId, startTime, endTime, new String[]{
|
||||
INTERACT_WORD,
|
||||
ENTRY_EFFECT,
|
||||
@ -104,7 +104,7 @@ public class ExcelUtils implements ApplicationContextAware {
|
||||
createCell(infoRow.createCell(5), info.getGiftuser());
|
||||
createCell(infoRow.createCell(6), AppTools.getToDayTimeToString(info.getSubtime()));
|
||||
}
|
||||
System.out.println("数据填充完毕:"+(System.currentTimeMillis()-timer));
|
||||
com.yutou.bilibili.Tools.Log.i("数据填充完毕:"+(System.currentTimeMillis()-timer));
|
||||
try {
|
||||
if(!new File("excel").exists()){
|
||||
new File("excel").mkdirs();
|
||||
@ -113,7 +113,7 @@ public class ExcelUtils implements ApplicationContextAware {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
workbook.write(fileOutputStream);
|
||||
workbook.close();
|
||||
System.out.println("文件写入完毕:"+(System.currentTimeMillis()-timer));
|
||||
com.yutou.bilibili.Tools.Log.i("文件写入完毕:"+(System.currentTimeMillis()-timer));
|
||||
file.renameTo(new File("excel"+File.separator+fileName));
|
||||
return file;
|
||||
} catch (Exception e) {
|
||||
|
@ -39,7 +39,7 @@ public class FFmpegUtils {
|
||||
ffmpeg,
|
||||
file.getAbsolutePath(),
|
||||
out.getAbsolutePath() + File.separator + file.getName());
|
||||
System.out.println(exec);
|
||||
com.yutou.bilibili.Tools.Log.i(exec);
|
||||
Process process = Runtime.getRuntime().exec(new String[]{
|
||||
"cmd",
|
||||
"/c",
|
||||
@ -67,13 +67,13 @@ public class FFmpegUtils {
|
||||
int i = -1;
|
||||
while (i != 1) {
|
||||
i = add("D:\\ffmpeg-4.3.1-2020-11-19-full_build\\bin\\ffmpeg.exe", file.getAbsoluteFile(), new File("ffmpeg_out"));
|
||||
System.out.println(i);
|
||||
com.yutou.bilibili.Tools.Log.i(i);
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("转码完成");
|
||||
com.yutou.bilibili.Tools.Log.i("转码完成");
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class HttpTools {
|
||||
str.append(tmp);
|
||||
}
|
||||
|
||||
// System.out.println( "[" + url + "?" + new String(body,StandardCharsets.UTF_8) + "]body:" + str + " (" + connection.getResponseCode() + ")");
|
||||
// com.yutou.bilibili.Tools.Log.i( "[" + url + "?" + new String(body,StandardCharsets.UTF_8) + "]body:" + str + " (" + connection.getResponseCode() + ")");
|
||||
if (networkInterface != null) {
|
||||
try {
|
||||
networkInterface.httpGetData(str.toString(), connection.getResponseCode());
|
||||
@ -130,7 +130,7 @@ public class HttpTools {
|
||||
}
|
||||
});
|
||||
}*/
|
||||
System.out.println(url);
|
||||
com.yutou.bilibili.Tools.Log.i(url);
|
||||
//String str=get(url);
|
||||
}
|
||||
}
|
||||
|
11
src/main/java/com/yutou/bilibili/Tools/Log.java
Normal file
11
src/main/java/com/yutou/bilibili/Tools/Log.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.yutou.bilibili.Tools;
|
||||
|
||||
public class Log {
|
||||
public static void i(Object log){
|
||||
System.out.printf("[%s]%s%n",
|
||||
AppTools.getToDayNowTimeToString(),
|
||||
log
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ public class ServiceTools implements ApplicationContextAware {
|
||||
url = tmp.split(tmp.split("/")[tmp.split("/").length - 1])[0];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("无权限请求:" + tmp);
|
||||
com.yutou.bilibili.Tools.Log.i("无权限请求:" + tmp);
|
||||
return false;
|
||||
}
|
||||
JSONArray powers = JSONArray.parseArray(user.getPower());
|
||||
|
@ -46,7 +46,7 @@ public class TestMain {
|
||||
}
|
||||
String str = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);*/
|
||||
|
||||
System.out.println("["+AppTools.getToDayNowTimeToString()+"]"+hearBeat);
|
||||
com.yutou.bilibili.Tools.Log.i("["+AppTools.getToDayNowTimeToString()+"]"+hearBeat);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public class BiliBiliLiveDatabasesManager extends SQLiteManager {
|
||||
+ ", " + (upData.isEnable() ? 1 : 0)
|
||||
+ ", " + (upData.isSaveDanmu() ? 1 : 0) +
|
||||
");";
|
||||
System.out.println(sql);
|
||||
com.yutou.bilibili.Tools.Log.i(sql);
|
||||
statement.execute(sql);
|
||||
statement.closeOnCompletion();
|
||||
return true;
|
||||
@ -257,7 +257,7 @@ public class BiliBiliLiveDatabasesManager extends SQLiteManager {
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println(sql);
|
||||
com.yutou.bilibili.Tools.Log.i(sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class SQLiteManager {
|
||||
startBatch();
|
||||
JSONArray array=json.getJSONArray("table");
|
||||
for (Object o : array) {
|
||||
System.out.println("创建表:"+((JSONObject)o).getString("name"));
|
||||
com.yutou.bilibili.Tools.Log.i("创建表:"+((JSONObject)o).getString("name"));
|
||||
createSqlOfTable((JSONObject) o);
|
||||
}
|
||||
closeBatch();
|
||||
|
Loading…
Reference in New Issue
Block a user