Compare commits
No commits in common. "903ba44bbb37cb726b4fea1a60d4231a450c154e" and "b5c2153ad0f631199cd5b2026a4dcea235fc79e8" have entirely different histories.
903ba44bbb
...
b5c2153ad0
@ -15,9 +15,7 @@
|
|||||||
<script type="text/html" id="toolbarDemo">
|
<script type="text/html" id="toolbarDemo">
|
||||||
<div class="layui-btn-container">
|
<div class="layui-btn-container">
|
||||||
<button class="layui-btn layui-btn-sm" onclick="createRoom()">添加新房间</button>
|
<button class="layui-btn layui-btn-sm" onclick="createRoom()">添加新房间</button>
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="editArray">批量编辑</button>
|
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="deleteArray">批量删除</button>
|
|
||||||
<button class="layui-btn layui-btn-sm layui-bg-red" lay-event="deleteAll">全部删除</button>
|
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="toolDemo">
|
<script type="text/html" id="toolDemo">
|
||||||
@ -48,15 +46,6 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function editArrayRoom(array) {
|
|
||||||
layer.open({
|
|
||||||
type: 2,
|
|
||||||
title: "批量编辑",
|
|
||||||
area: ['600px', '500px'],
|
|
||||||
content: '/html/ui/createConfig.html?array=' + array
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
layui.use(['table', 'dropdown'], function () {
|
layui.use(['table', 'dropdown'], function () {
|
||||||
@ -116,56 +105,10 @@
|
|||||||
var id = obj.config.id;
|
var id = obj.config.id;
|
||||||
var checkStatus = table.checkStatus(id);
|
var checkStatus = table.checkStatus(id);
|
||||||
var othis = lay(this);
|
var othis = lay(this);
|
||||||
var data = checkStatus.data;
|
|
||||||
var array = data.map(function (item) {
|
|
||||||
return item.live_room_id
|
|
||||||
})
|
|
||||||
var arrayName = data.map(function (item) {
|
|
||||||
return item.anchorName
|
|
||||||
})
|
|
||||||
switch (obj.event) {
|
switch (obj.event) {
|
||||||
case 'deleteArray':
|
case 'getCheckData':
|
||||||
if (array.length === 0) {
|
var data = checkStatus.data;
|
||||||
layer.msg('没有数据', { icon: 2 })
|
layer.alert(layui.util.escape(JSON.stringify(data)));
|
||||||
return
|
|
||||||
}
|
|
||||||
layer.confirm('确定删除 ' + arrayName + "?", { icon: 3 }, function () {
|
|
||||||
var loadIndex = showLoadingDialog();
|
|
||||||
deleteArrayRoomConfig(array)
|
|
||||||
.then(json => {
|
|
||||||
layer.close(loadIndex)
|
|
||||||
layer.msg(json.data, { icon: 1 });
|
|
||||||
table.reloadData('roomList', {}, false)
|
|
||||||
})
|
|
||||||
|
|
||||||
}, function () {
|
|
||||||
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'editArray':
|
|
||||||
if (array.length === 0) {
|
|
||||||
layer.msg('没有数据', { icon: 2 })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
editArrayRoom(array)
|
|
||||||
break;
|
|
||||||
case 'deleteAll':
|
|
||||||
layer.confirm('确定删除所有配置?', { icon: 3 }, function () {
|
|
||||||
var loadIndex = showLoadingDialog();
|
|
||||||
deleteAllRoomConfig()
|
|
||||||
.then(json => {
|
|
||||||
layer.close(loadIndex)
|
|
||||||
if (json.status === -1) {
|
|
||||||
layer.msg(json.message, { icon: 2 });
|
|
||||||
} else {
|
|
||||||
layer.msg(json.data, { icon: 1 });
|
|
||||||
}
|
|
||||||
table.reloadData('roomList', {}, false)
|
|
||||||
})
|
|
||||||
|
|
||||||
}, function () {
|
|
||||||
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -24,11 +24,7 @@
|
|||||||
<script type="text/html" id="toolDemo">
|
<script type="text/html" id="toolDemo">
|
||||||
<div class="layui-clear-space">
|
<div class="layui-clear-space">
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
|
<a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
|
||||||
<!-- <a class="layui-btn layui-btn-xs" lay-event="input">导入关注</a> -->
|
<a class="layui-btn layui-btn-xs" lay-event="input">导入关注</a>
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="more">
|
|
||||||
导入
|
|
||||||
<i class="layui-icon layui-icon-down"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
@ -147,28 +143,8 @@
|
|||||||
var checkStatus = table.checkStatus(id);
|
var checkStatus = table.checkStatus(id);
|
||||||
var othis = lay(this);
|
var othis = lay(this);
|
||||||
switch (obj.event) {
|
switch (obj.event) {
|
||||||
case 'more':
|
case 'input':
|
||||||
dropdown.render({
|
|
||||||
elem: this, // 触发事件的 DOM 对象
|
|
||||||
show: true, // 外部事件触发即显示
|
|
||||||
data: [{
|
|
||||||
title: '关注列表',
|
|
||||||
id: 'follow'
|
|
||||||
}, {
|
|
||||||
title: '正在开播',
|
|
||||||
id: 'live'
|
|
||||||
}],
|
|
||||||
click: function (menudata) {
|
|
||||||
if (menudata.id === 'follow') {
|
|
||||||
onClickInput(data.uid)
|
onClickInput(data.uid)
|
||||||
} else if (menudata.id === 'live') {
|
|
||||||
onClickFollow(data.uid)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
align: 'right', // 右对齐弹出
|
|
||||||
style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' // 设置额外样式
|
|
||||||
})
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -196,33 +172,10 @@
|
|||||||
window.location.href = url.toString();
|
window.location.href = url.toString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
function onClickFollow(uid) {
|
|
||||||
layer.open({
|
|
||||||
type: 2, // page 层类型
|
|
||||||
area: ['650px', '400px'],
|
|
||||||
title: '选择主播',
|
|
||||||
shade: 0.6, // 遮罩透明度
|
|
||||||
shadeClose: false, // 点击遮罩区域,关闭弹层
|
|
||||||
maxmin: true, // 允许全屏最小化
|
|
||||||
anim: 1, // 0-6 的动画形式,-1 不开启
|
|
||||||
// btn: ['确定', '取消'],
|
|
||||||
content: '/html/ui/userFollowLive.html?uid=' + uid,
|
|
||||||
yes: function (index, layero) {
|
|
||||||
var iframeWin = window[layero.find('iframe')[0]['name']];
|
|
||||||
var anchorRoomId = iframeWin.$('#anchorRoomId')[0].value;
|
|
||||||
if (!hasString(anchorRoomId)) {
|
|
||||||
layer.msg("请选择")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let url = new URL(window.location.href);
|
|
||||||
url.searchParams.set('roomId', anchorRoomId);
|
|
||||||
window.location.href = url.toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -42,18 +42,15 @@
|
|||||||
<input type="checkbox" id="danmuCheckBox" title="弹幕" lay-skin="tag" lay-filter="danmuCheckBox" on checked>
|
<input type="checkbox" id="danmuCheckBox" title="弹幕" lay-skin="tag" lay-filter="danmuCheckBox" on checked>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layui-col-xs4" style="text-align: center;">
|
<div class="layui-col-xs5" style="text-align: center;">
|
||||||
<div id="slider" lay-options="{value: 100,input:true}"></div>
|
<div id="slider" lay-options="{value: 100,input:true}"></div>
|
||||||
<span>弹幕透明度</span>
|
<span>弹幕透明度</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-xs2" style="text-align: right; align-self: center;">
|
|
||||||
弹幕装载数:<span id="danmuSize">你猜</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-row">
|
<div class="layui-row">
|
||||||
<div class="layui-col-xs2"> </div>
|
<div class="layui-col-xs2"> </div>
|
||||||
<div class="layui-col-xs7" style="width: auto; height: 50%;">
|
<div class="layui-col-xs7">
|
||||||
<canvas id="giftChart" style="width: 100%; height: 100%;"></canvas>
|
<canvas id="giftChart" height="200"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-bottom: 10vh;"></div>
|
<div style="margin-bottom: 10vh;"></div>
|
||||||
@ -235,7 +232,6 @@
|
|||||||
initChart(roomId, options.id)
|
initChart(roomId, options.id)
|
||||||
|
|
||||||
});
|
});
|
||||||
var chartView = null;
|
|
||||||
function initChart(roomId, videoId) {
|
function initChart(roomId, videoId) {
|
||||||
getVideoGiftInfo(roomId, videoId)
|
getVideoGiftInfo(roomId, videoId)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@ -252,10 +248,8 @@
|
|||||||
lables.push(item.gift_name+"\n"+item.total_price/100+"¥")
|
lables.push(item.gift_name+"\n"+item.total_price/100+"¥")
|
||||||
values.push(item.total_gift_num)
|
values.push(item.total_gift_num)
|
||||||
});
|
});
|
||||||
if(chartView!==null){
|
|
||||||
chartView.destroy()
|
new Chart($('#giftChart').get(0), {
|
||||||
}
|
|
||||||
chartView = new Chart($('#giftChart').get(0), {
|
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
data: {
|
data: {
|
||||||
labels: lables,
|
labels: lables,
|
||||||
@ -319,8 +313,7 @@
|
|||||||
}
|
}
|
||||||
function playVideo(url) {
|
function playVideo(url) {
|
||||||
var video = document.getElementById('videoElement');
|
var video = document.getElementById('videoElement');
|
||||||
var videoSrc = window.location.origin + url;
|
var videoSrc = url;
|
||||||
console.log('url = ' + videoSrc)
|
|
||||||
var hls = new Hls();
|
var hls = new Hls();
|
||||||
hls.loadSource(videoSrc);
|
hls.loadSource(videoSrc);
|
||||||
hls.attachMedia(video);
|
hls.attachMedia(video);
|
||||||
@ -335,7 +328,6 @@
|
|||||||
getDanmu(getParam('roomId'), videoId)
|
getDanmu(getParam('roomId'), videoId)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
barrageRenderer.setBarrages(data.data.danmu);
|
barrageRenderer.setBarrages(data.data.danmu);
|
||||||
$('#danmuSize').get(0).innerHTML = data.data.danmu.length
|
|
||||||
initSC(data.data.superChat)
|
initSC(data.data.superChat)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@
|
|||||||
<div class="layui-form-item" pane>
|
<div class="layui-form-item" pane>
|
||||||
<label class="layui-form-label">录制日期</label>
|
<label class="layui-form-label">录制日期</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="week_1" title="周一" lay-skin="tag">
|
<input type="checkbox" checked name="week_1" title="周一" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_2" title="周二" lay-skin="tag">
|
<input type="checkbox" checked name="week_2" title="周二" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_3" title="周三" lay-skin="tag">
|
<input type="checkbox" checked name="week_3" title="周三" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_4" title="周四" lay-skin="tag">
|
<input type="checkbox" checked name="week_4" title="周四" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_5" title="周五" lay-skin="tag">
|
<input type="checkbox" checked name="week_5" title="周五" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_6" title="周六" lay-skin="tag">
|
<input type="checkbox" checked name="week_6" title="周六" lay-skin="tag">
|
||||||
<input type="checkbox" name="week_7" title="周日" lay-skin="tag">
|
<input type="checkbox" checked name="week_7" title="周日" lay-skin="tag">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
@ -98,7 +98,6 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
var roomId = getParam("roomId");
|
var roomId = getParam("roomId");
|
||||||
var editArray = getParam("array")
|
|
||||||
|
|
||||||
layui.use(['form', 'laytpl', 'laydate'], function () {
|
layui.use(['form', 'laytpl', 'laydate'], function () {
|
||||||
var form = layui.form;
|
var form = layui.form;
|
||||||
@ -124,11 +123,8 @@
|
|||||||
}
|
}
|
||||||
field.weeks = weeks;
|
field.weeks = weeks;
|
||||||
console.log(field)
|
console.log(field)
|
||||||
if (editArray === null) {
|
|
||||||
var loadIndex=showLoadingDialog();
|
|
||||||
addRoomConfig(field)
|
addRoomConfig(field)
|
||||||
.then(json => {
|
.then(json => {
|
||||||
layer.close(loadIndex)
|
|
||||||
layer.msg(json.message, function () {
|
layer.msg(json.message, function () {
|
||||||
if (json.status == 100) {
|
if (json.status == 100) {
|
||||||
close()
|
close()
|
||||||
@ -136,23 +132,6 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
var array = []
|
|
||||||
editArray.split(',').forEach(element => {
|
|
||||||
array.push(element)
|
|
||||||
});
|
|
||||||
var loadIndex=showLoadingDialog();
|
|
||||||
setArrayRoomConfig(array, field)
|
|
||||||
.then(json => {
|
|
||||||
layer.close(loadIndex)
|
|
||||||
layer.msg(json.message, function () {
|
|
||||||
if (json.status == 100) {
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false; // 阻止默认 form 跳转
|
return false; // 阻止默认 form 跳转
|
||||||
});
|
});
|
||||||
@ -176,9 +155,6 @@
|
|||||||
$('#btn_reset').get(0).disabled = true;
|
$('#btn_reset').get(0).disabled = true;
|
||||||
editRoom()
|
editRoom()
|
||||||
}
|
}
|
||||||
if (editArray !== null) {
|
|
||||||
editArrayRoom()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function getUserInfo() {
|
function getUserInfo() {
|
||||||
getBiliAllUser()
|
getBiliAllUser()
|
||||||
@ -213,14 +189,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function editArrayRoom() {
|
|
||||||
$('#btn_reset').get(0).disabled = true;
|
|
||||||
$('#url').get(0).disabled = true;
|
|
||||||
var result = {
|
|
||||||
'url': editArray
|
|
||||||
};
|
|
||||||
form.val('form-filter', result);
|
|
||||||
}
|
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
@ -46,7 +46,7 @@
|
|||||||
elem: '#followList',
|
elem: '#followList',
|
||||||
url: '/live/config/follow?userId=' + userId,
|
url: '/live/config/follow?userId=' + userId,
|
||||||
toolbar: '#toolbarDemo',
|
toolbar: '#toolbarDemo',
|
||||||
height: 'full',
|
height: '350px',
|
||||||
totalRow: true, // 开启合计行
|
totalRow: true, // 开启合计行
|
||||||
page: true,
|
page: true,
|
||||||
response: {
|
response: {
|
||||||
|
@ -1,132 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="zh-CN">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<link rel="stylesheet" href="/layui/css/layui.css">
|
|
||||||
</head>
|
|
||||||
<table class="layui-hide" id="followList" lay-filter="followTable"></table>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
<script src="/layui/layui.js"></script>
|
|
||||||
<script src="/js/jquery-3.2.1.js"></script>
|
|
||||||
<script src="/js/CommonConfig.js"></script>
|
|
||||||
<script src="/js/httpUtils.js"></script>
|
|
||||||
|
|
||||||
<script type="text/html" id="toolbarDemo">
|
|
||||||
<div class="layui-btn-container">
|
|
||||||
<button class="layui-btn layui-btn-sm" lay-event="select">配置选择项</button>
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
<script type="text/html" id="toolDemo">
|
|
||||||
<div class="layui-clear-space">
|
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="add">添加</a>
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var userId = getParam("uid");
|
|
||||||
|
|
||||||
layui.use(function () {
|
|
||||||
var laytpl = layui.laytpl;
|
|
||||||
var table = layui.table;
|
|
||||||
|
|
||||||
|
|
||||||
table.render({
|
|
||||||
elem: '#followList',
|
|
||||||
url: '/live/config/followLive?userId=' + userId,
|
|
||||||
toolbar: '#toolbarDemo',
|
|
||||||
height: 'full',
|
|
||||||
totalRow: false, // 开启合计行
|
|
||||||
page: false,
|
|
||||||
response: {
|
|
||||||
statusCode: 100 // 重新规定成功的状态码为 200,table 组件默认为 0
|
|
||||||
},
|
|
||||||
parseData: function (res) {
|
|
||||||
return {
|
|
||||||
"code": res.status, //解析接口状态
|
|
||||||
"msg": res.message, //解析提示文本
|
|
||||||
"data": res.data, //解析数据列表
|
|
||||||
"count": res.count
|
|
||||||
};
|
|
||||||
},
|
|
||||||
cols: [[
|
|
||||||
{ type: 'checkbox', fixed: 'left' },
|
|
||||||
{ field: 'uname', title: '用户名', width: 150, fixed: 'left' },
|
|
||||||
{ field: 'uid', title: 'UID', width: 150, sort: true, templet: '<div><a href="https://space.bilibili.com/{{= d.uid}}" target="_blank">{{= d.uid}}</a>' },
|
|
||||||
{ field: 'room_id', title: '房间号', width: 150, sort: true, templet: '<div><a href="https://live.bilibili.com/{{= d.room_id}}" target="_blank">{{= d.room_id}}</a>' },
|
|
||||||
{ field: 'face', title: '头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.face }}\',this);" style="width: 30px;height: 30px;"></div>' },
|
|
||||||
{ field: 'title', title: '标题', width: 150, },
|
|
||||||
{ fixed: "right", title: "操作", width: 50, align: "center", toolbar: "#toolDemo" }
|
|
||||||
]],
|
|
||||||
done: function () {
|
|
||||||
onDone()
|
|
||||||
},
|
|
||||||
error: function (res, msg) {
|
|
||||||
console.log(res, msg)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
function onDone() {
|
|
||||||
table.on('toolbar(followTable)', function (obj) {
|
|
||||||
if (obj.event === 'select') {
|
|
||||||
var data = table.checkStatus(obj.config.id).data;
|
|
||||||
console.log(data)
|
|
||||||
var array = []
|
|
||||||
data.forEach(item => {
|
|
||||||
array.push({
|
|
||||||
"roomId": item.room_id,
|
|
||||||
"uname": item.uname
|
|
||||||
})
|
|
||||||
});
|
|
||||||
var loadIndex = layer.msg('配置中', {
|
|
||||||
icon: 16,
|
|
||||||
shade: 0.6
|
|
||||||
});
|
|
||||||
addFollowRoomList(JSON.stringify(array))
|
|
||||||
.then(json => {
|
|
||||||
layer.close(loadIndex)
|
|
||||||
layer.msg("已成功配置" + json.count + "个房间")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
table.on('tool(followTable)', function (obj) {
|
|
||||||
if (obj.event === 'add') {
|
|
||||||
var loadIndex = layer.msg('配置中', {
|
|
||||||
icon: 16,
|
|
||||||
shade: 0.6
|
|
||||||
});
|
|
||||||
var array = []
|
|
||||||
array.push({
|
|
||||||
"roomId": obj.data.room_id,
|
|
||||||
"uname": obj.data.uname
|
|
||||||
})
|
|
||||||
addFollowRoomList(JSON.stringify(array))
|
|
||||||
.then(data => {
|
|
||||||
layer.close(loadIndex)
|
|
||||||
layer.msg("已成功配置" + data.count + "个房间")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
function openTips(message, mid) {
|
|
||||||
layer.alert(message, {
|
|
||||||
title: "提示",
|
|
||||||
btn: ['打开配置页', '前往UP主页', '取消'],
|
|
||||||
btnAlign: 'c', // 按钮居中显示
|
|
||||||
btn1: function () {
|
|
||||||
window.open("/html/body/live.html?type=createRoom", '_blank')
|
|
||||||
},
|
|
||||||
btn2: function () {
|
|
||||||
window.open("https://space.bilibili.com/" + mid, '_blank')
|
|
||||||
},
|
|
||||||
btn3: function () {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
</script>
|
|
@ -59,12 +59,9 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<div style="overflow: hidden;position: relative; width: 100%; height: 100%; padding-bottom: 52%;">
|
<img src="#" onerror="showTmpImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%; object-fit: cover;"/><br>
|
||||||
<img src="#" onerror="showTmpImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="max-width: 100%; max-height: 100%; object-fit: cover; display: block; margin: auto; position: absolute; "/><br>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <img src="#" onerror="showImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br> -->
|
<!-- <img src="#" onerror="showImage('{{= item.cover}}',this)" onclick="toLive('{{= item.roomId}}')" style="width: 100%; height: 100%;"/><br> -->
|
||||||
<span style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; ">{{= item.title}}</span> <br>
|
{{= item.title}}<br>
|
||||||
<p>开播时长:{{= item.liveTime}}</p>
|
<p>开播时长:{{= item.liveTime}}</p>
|
||||||
直播录制状态:
|
直播录制状态:
|
||||||
{{# if(item.downloadVideo){ }}
|
{{# if(item.downloadVideo){ }}
|
||||||
|
@ -14,25 +14,10 @@ function get(url) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function post(url,formData,isJSON) {
|
function post(url,formData,isJSON) {
|
||||||
return sendPost(url,true,formData,isJSON)
|
return fetch(url, {
|
||||||
}
|
|
||||||
function sendPost(url, isFormData, formData, isJSON) {
|
|
||||||
var obj = {};
|
|
||||||
if (isFormData) {
|
|
||||||
obj = {
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData
|
body: formData
|
||||||
}
|
})
|
||||||
} else {
|
|
||||||
obj = {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(formData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fetch(url, obj)
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Network response was not ok");
|
throw new Error("Network response was not ok");
|
||||||
@ -117,23 +102,10 @@ function getHttpTmpImage(url) {
|
|||||||
return blob;
|
return blob;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function addRoomConfig(config) {
|
function addRoomConfig(json){
|
||||||
const formData = buildFormData(config)
|
const formData=buildFormData(json)
|
||||||
return post("/live/config/set",formData,true)
|
return post("/live/config/set",formData,true)
|
||||||
}
|
}
|
||||||
function setArrayRoomConfig(rooms, config) {
|
|
||||||
var json = {
|
|
||||||
"config": config,
|
|
||||||
"array": rooms
|
|
||||||
}
|
|
||||||
return sendPost("/live/config/set/array", false, json, true)
|
|
||||||
}
|
|
||||||
function deleteArrayRoomConfig(rooms) {
|
|
||||||
return sendPost("/live/config/delete/array", false,rooms, true)
|
|
||||||
}
|
|
||||||
function deleteAllRoomConfig() {
|
|
||||||
return get("/live/config/delete/all")
|
|
||||||
}
|
|
||||||
function getRoomConfig(roomId){
|
function getRoomConfig(roomId){
|
||||||
return get("/live/config/get?roomId="+roomId)
|
return get("/live/config/get?roomId="+roomId)
|
||||||
}
|
}
|
||||||
@ -157,11 +129,6 @@ function addFollowList(uid, array) {
|
|||||||
formData.append("array", array);
|
formData.append("array", array);
|
||||||
return post("/live/config/follow/addList?uid="+uid,formData,true)
|
return post("/live/config/follow/addList?uid="+uid,formData,true)
|
||||||
}
|
}
|
||||||
function addFollowRoomList(array) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("array", array);
|
|
||||||
return post("/live/config/follow/roomId/addList", formData, true)
|
|
||||||
}
|
|
||||||
//----------------直播配置相关接口end
|
//----------------直播配置相关接口end
|
||||||
//----------------首页相关接口
|
//----------------首页相关接口
|
||||||
function getAllLive(page,limit){
|
function getAllLive(page,limit){
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -66,9 +66,5 @@ public interface LiveApi {
|
|||||||
@POST("/room/v1/Room/get_status_info_by_uids")
|
@POST("/room/v1/Room/get_status_info_by_uids")
|
||||||
Call<HttpBody<Map<String,LiveAnchorInfo>>> getLiveRoomStatus(@Body
|
Call<HttpBody<Map<String,LiveAnchorInfo>>> getLiveRoomStatus(@Body
|
||||||
JSONObject uids);
|
JSONObject uids);
|
||||||
@GET("/xlive/web-ucenter/v1/xfetter/GetWebList")
|
|
||||||
Call<HttpBody<FollowLive>> getUserFollowLive(
|
|
||||||
@Query("hit_ab")boolean hit_ab,
|
|
||||||
@Query("_")long time
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
package com.yutou.biliapi.bean.live;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
|
||||||
import com.yutou.common.okhttp.BaseBean;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class FollowLive extends BaseBean {
|
|
||||||
|
|
||||||
@JSONField(name = "rooms")
|
|
||||||
List<Room> rooms;
|
|
||||||
@JSONField(name = "list")
|
|
||||||
List<Room> list;
|
|
||||||
|
|
||||||
@lombok.Data
|
|
||||||
public static class Room {
|
|
||||||
@JSONField(name = "title")
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
@JSONField(name = "room_id")
|
|
||||||
private String roomId;
|
|
||||||
|
|
||||||
@JSONField(name = "uid")
|
|
||||||
private String uid;
|
|
||||||
|
|
||||||
@JSONField(name = "online")
|
|
||||||
private int online;
|
|
||||||
|
|
||||||
@JSONField(name = "live_time")
|
|
||||||
private String liveTime;
|
|
||||||
|
|
||||||
@JSONField(name = "live_status")
|
|
||||||
private int liveStatus;
|
|
||||||
|
|
||||||
@JSONField(name = "short_id")
|
|
||||||
private int shortId;
|
|
||||||
|
|
||||||
@JSONField(name = "area")
|
|
||||||
private int area;
|
|
||||||
|
|
||||||
@JSONField(name = "area_name")
|
|
||||||
private String areaName;
|
|
||||||
|
|
||||||
@JSONField(name = "area_v2_id")
|
|
||||||
private int areaV2Id;
|
|
||||||
|
|
||||||
@JSONField(name = "area_v2_name")
|
|
||||||
private String areaV2Name;
|
|
||||||
|
|
||||||
@JSONField(name = "area_v2_parent_name")
|
|
||||||
private String areaV2ParentName;
|
|
||||||
|
|
||||||
@JSONField(name = "area_v2_parent_id")
|
|
||||||
private int areaV2ParentId;
|
|
||||||
|
|
||||||
@JSONField(name = "uname")
|
|
||||||
private String uname;
|
|
||||||
|
|
||||||
@JSONField(name = "face")
|
|
||||||
private String face;
|
|
||||||
|
|
||||||
@JSONField(name = "tag_name")
|
|
||||||
private String tagName;
|
|
||||||
|
|
||||||
@JSONField(name = "tags")
|
|
||||||
private String tags;
|
|
||||||
|
|
||||||
@JSONField(name = "cover_from_user")
|
|
||||||
private String coverFromUser;
|
|
||||||
|
|
||||||
@JSONField(name = "keyframe")
|
|
||||||
private String keyframe;
|
|
||||||
|
|
||||||
@JSONField(name = "lock_till")
|
|
||||||
private String lockTill;
|
|
||||||
|
|
||||||
@JSONField(name = "hidden_till")
|
|
||||||
private String hiddenTill;
|
|
||||||
|
|
||||||
@JSONField(name = "broadcast_type")
|
|
||||||
private int broadcastType;
|
|
||||||
|
|
||||||
@JSONField(name = "is_encrypt")
|
|
||||||
private boolean isEncrypt;
|
|
||||||
|
|
||||||
@JSONField(name = "link")
|
|
||||||
private String link;
|
|
||||||
|
|
||||||
@JSONField(name = "nickname")
|
|
||||||
private String nickname;
|
|
||||||
|
|
||||||
@JSONField(name = "roomname")
|
|
||||||
private String roomName;
|
|
||||||
|
|
||||||
@JSONField(name = "roomid")
|
|
||||||
private String roomId2;
|
|
||||||
|
|
||||||
@JSONField(name = "liveTime")
|
|
||||||
private long liveTimeLong;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -14,8 +14,6 @@ public class LiveVideoDatabaseBean extends AbsDatabasesBean {
|
|||||||
String roomInfoJson;
|
String roomInfoJson;
|
||||||
@JSONField(name = "start_time")
|
@JSONField(name = "start_time")
|
||||||
Date startTime;
|
Date startTime;
|
||||||
@JSONField(name = "stop_time")
|
|
||||||
Date stopTime;
|
|
||||||
@JSONField(name = "path")
|
@JSONField(name = "path")
|
||||||
String path;
|
String path;
|
||||||
|
|
||||||
|
@ -118,6 +118,8 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getGiftInfo(long startTimeLong, long endTimeLong) {
|
public JSONObject getGiftInfo(long startTimeLong, long endTimeLong) {
|
||||||
|
String startTime = DateFormatUtils.getInstance().format(startTimeLong);
|
||||||
|
String endTime = DateFormatUtils.getInstance().format(endTimeLong);
|
||||||
String giftSql = "WITH filtered_gifts AS (" +
|
String giftSql = "WITH filtered_gifts AS (" +
|
||||||
"SELECT " +
|
"SELECT " +
|
||||||
"`gift_name`," +
|
"`gift_name`," +
|
||||||
@ -130,8 +132,8 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
"FROM " +
|
"FROM " +
|
||||||
"`gift` " +
|
"`gift` " +
|
||||||
"WHERE " +
|
"WHERE " +
|
||||||
"`sql_time` >= '" + startTimeLong + "' " +
|
"`sql_time` >= '" + startTime + "' " +
|
||||||
"AND `sql_time` <= '" + endTimeLong + "' " +
|
"AND `sql_time` <= '" + endTime + "' " +
|
||||||
"GROUP BY " +
|
"GROUP BY " +
|
||||||
"`gift_name`, `coin_type`" +
|
"`gift_name`, `coin_type`" +
|
||||||
")" +
|
")" +
|
||||||
@ -145,10 +147,10 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
"GROUP BY " +
|
"GROUP BY " +
|
||||||
"`gift_name`, `icon`;";
|
"`gift_name`, `icon`;";
|
||||||
String guardSql = "SELECT `gift_name`, SUM(`num`) AS `total_num`,SUM(`price`*`num`) as `total_price`" +
|
String guardSql = "SELECT `gift_name`, SUM(`num`) AS `total_num`,SUM(`price`*`num`) as `total_price`" +
|
||||||
"FROM `guardBuy` where `sql_time` >= '" + startTimeLong + "' and `sql_time` <= '" + endTimeLong + "'" +
|
"FROM `guardBuy` where `sql_time` >= '" + startTime + "' and `sql_time` <= '" + endTime + "'" +
|
||||||
"GROUP BY `gift_name`;";
|
"GROUP BY `gift_name`;";
|
||||||
String superChatSql = "SELECT SUM(`price`*100) as `total_price`, count(`price`) as `total_count`" +
|
String superChatSql = "SELECT SUM(`price`*100) as `total_price`, count(`price`) as `total_count`" +
|
||||||
"FROM `superChat` where `sql_time` >= '" + startTimeLong + "' and `sql_time` <= '" + endTimeLong + "';";
|
"FROM `superChat` where `sql_time` >= '" + startTime + "' and `sql_time` <= '" + endTime + "';";
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONArray giftInfo = get(giftSql);
|
JSONArray giftInfo = get(giftSql);
|
||||||
JSONArray guardInfo = get(guardSql);
|
JSONArray guardInfo = get(guardSql);
|
||||||
@ -175,14 +177,15 @@ public class BiliLiveDatabase extends SQLiteManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createInfo(LiveVideoDatabaseBean bean) {
|
private void createInfo(LiveVideoDatabaseBean bean) {
|
||||||
if (get(bean.getTableName(), " `sql_time` = '" + bean.getSql_time().getTime() + "'", LiveVideoDatabaseBean.class).isEmpty()) {
|
String format = DateFormatUtils.getInstance().format(bean.getSql_time());
|
||||||
|
if (get(bean.getTableName(), " `sql_time` = '" + format + "'", LiveVideoDatabaseBean.class).isEmpty()) {
|
||||||
add(bean);
|
add(bean);
|
||||||
} else {
|
} else {
|
||||||
update(bean);
|
update(bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends AbsDatabasesBean> List<T> getOfTime(Long startTime, Long endTime, Class<T> clazz) {
|
public <T extends AbsDatabasesBean> List<T> getOfTime(String startTime, String endTime, Class<T> clazz) {
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String where = null;
|
String where = null;
|
||||||
|
@ -2,11 +2,9 @@ package com.yutou.bilibili.Controllers;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.yutou.biliapi.bean.live.FollowLive;
|
|
||||||
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
||||||
import com.yutou.biliapi.bean.login.LoginUserDatabaseBean;
|
import com.yutou.biliapi.bean.login.LoginUserDatabaseBean;
|
||||||
import com.yutou.biliapi.bean.user.UserFollowingsBean;
|
import com.yutou.biliapi.bean.user.UserFollowingsBean;
|
||||||
import com.yutou.bilibili.Tools.DateFormatUtils;
|
|
||||||
import com.yutou.bilibili.Tools.Tools;
|
import com.yutou.bilibili.Tools.Tools;
|
||||||
import com.yutou.bilibili.datas.ResultData;
|
import com.yutou.bilibili.datas.ResultData;
|
||||||
import com.yutou.bilibili.datas.ReturnCode;
|
import com.yutou.bilibili.datas.ReturnCode;
|
||||||
@ -19,13 +17,13 @@ import org.springframework.core.io.FileSystemResource;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/live/config/")
|
@RequestMapping("/live/config/")
|
||||||
@ -48,17 +46,6 @@ public class LiveConfigController {
|
|||||||
return ResultData.success(bean, bean.getTotal());
|
return ResultData.success(bean, bean.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
|
||||||
@RequestMapping("followLive")
|
|
||||||
public JSONObject getFollowLive(String userId) {
|
|
||||||
List<FollowLive.Room> followLive = userService.getUserFollowLive(userId);
|
|
||||||
if (followLive == null) {
|
|
||||||
return ResultData.fail(ReturnCode.RC999);
|
|
||||||
}
|
|
||||||
followLive.forEach(item -> item.setLiveTime(DateFormatUtils.getInstance().convertSeconds(Long.parseLong(item.getLiveTime()))));
|
|
||||||
return ResultData.success(followLive, followLive.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("follow/add")
|
@RequestMapping("follow/add")
|
||||||
public JSONObject addFollow(String uid, String anchorId) {
|
public JSONObject addFollow(String uid, String anchorId) {
|
||||||
@ -95,20 +82,6 @@ public class LiveConfigController {
|
|||||||
return ResultData.success(userService.followAll(uid,list));
|
return ResultData.success(userService.followAll(uid,list));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
|
||||||
@RequestMapping("follow/roomId/addList")
|
|
||||||
public JSONObject addFollowListToRoomId(String array) {
|
|
||||||
if (!StringUtils.hasText(array)) {
|
|
||||||
return ResultData.fail(ReturnCode.RC500);
|
|
||||||
}
|
|
||||||
JSONArray jsonArray = JSONArray.parseArray(array);
|
|
||||||
List<LiveConfigDatabaseBean> list = jsonArray.stream().map(o -> {
|
|
||||||
JSONObject jsonObject = (JSONObject) o;
|
|
||||||
return configService.addConfig(jsonObject.getString("roomId"), new LiveConfigDatabaseBean());
|
|
||||||
}).toList();
|
|
||||||
return ResultData.success(list, list.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("follow/check")
|
@RequestMapping("follow/check")
|
||||||
public JSONObject checkFollow(String userId) {
|
public JSONObject checkFollow(String userId) {
|
||||||
@ -137,49 +110,6 @@ public class LiveConfigController {
|
|||||||
return ResultData.success(ReturnCode.RC100);
|
return ResultData.success(ReturnCode.RC100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "set/array", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public JSONObject addArrayConfig(@RequestBody JSONObject jsonObject) {
|
|
||||||
JSONObject config=jsonObject.getJSONObject("config");
|
|
||||||
LiveConfigDatabaseBean bean = config.to(LiveConfigDatabaseBean.class);
|
|
||||||
if (!bean.verifyLiveTimer()) {
|
|
||||||
return ResultData.fail(ReturnCode.RC999.getCode(), "视频录制时间格式错误");
|
|
||||||
}
|
|
||||||
if (!bean.verifyDanmuTimer()) {
|
|
||||||
return ResultData.fail(ReturnCode.RC999.getCode(), "弹幕录制时间格式错误");
|
|
||||||
}
|
|
||||||
if("on".equals(config.getString("recordDanmu"))){
|
|
||||||
bean.setRecordDanmu(true);
|
|
||||||
}
|
|
||||||
if("on".equals(config.getString("recordLive"))){
|
|
||||||
bean.setRecordLive(true);
|
|
||||||
}
|
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("array");
|
|
||||||
List<LiveConfigDatabaseBean> list = jsonArray.stream().map(roomId -> configService.addConfig(roomId.toString(), bean)).toList();
|
|
||||||
int countNull = list.stream().filter(Objects::isNull).toList().size();
|
|
||||||
return ResultData.success("成功配置" + (list.size() - countNull) + "个直播间");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "delete/array", method = RequestMethod.POST)
|
|
||||||
@ResponseBody
|
|
||||||
public JSONObject deleteArrayConfig(@RequestBody JSONArray jsonArray) {
|
|
||||||
List<Boolean> list = jsonArray.stream().map(roomId -> configService.deleteConfig(roomId.toString())).toList();
|
|
||||||
int countNull = list.stream().filter(it -> !it).toList().size();
|
|
||||||
return ResultData.success("成功删除" + (list.size() - countNull) + "个直播间");
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "delete/all", method = RequestMethod.GET)
|
|
||||||
@ResponseBody
|
|
||||||
public JSONObject deleteAllConfig() {
|
|
||||||
for (LiveConfigDatabaseBean bean : configService.getAllConfig()) {
|
|
||||||
configService.deleteConfig(bean.getRoomId());
|
|
||||||
}
|
|
||||||
if (configService.getAllConfig().isEmpty()) {
|
|
||||||
return ResultData.success("成功删除");
|
|
||||||
} else {
|
|
||||||
return ResultData.fail(-1, "删除失败,剩余:" + configService.getAllConfig().size() + "个直播间");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "set", method = RequestMethod.POST)
|
@RequestMapping(value = "set", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -25,7 +25,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -110,13 +109,6 @@ public class VideoFileController {
|
|||||||
@RequestMapping("/video/play")
|
@RequestMapping("/video/play")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JSONObject getVideoUrl(String roomId, String videoId) {
|
public JSONObject getVideoUrl(String roomId, String videoId) {
|
||||||
String url = videoService.getVideoPlay(roomId, videoId);
|
return ResultData.success("/live/"+videoService.getVideoPlay(roomId, videoId));
|
||||||
/* String[] split = url.split("/");
|
|
||||||
StringBuilder sb=new StringBuilder();
|
|
||||||
for (String s : split) {
|
|
||||||
sb.append(URLEncoder.encode(s,StandardCharsets.UTF_8)).append("/");
|
|
||||||
}
|
|
||||||
sb.setLength(sb.length()-1);*/
|
|
||||||
return ResultData.success("/live"+url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,17 +76,6 @@ public class DateFormatUtils {
|
|||||||
Date time = parse(date, format);
|
Date time = parse(date, format);
|
||||||
return format(time, format);
|
return format(time, format);
|
||||||
}
|
}
|
||||||
public String convertSeconds(long totalSeconds) {
|
|
||||||
// 计算总小时数
|
|
||||||
long hours = totalSeconds / 3600;
|
|
||||||
// 剩余的秒数
|
|
||||||
long remainingSecondsAfterHours = totalSeconds % 3600;
|
|
||||||
// 计算分钟数
|
|
||||||
long minutes = remainingSecondsAfterHours / 60;
|
|
||||||
// 最后剩余的秒数
|
|
||||||
long seconds = remainingSecondsAfterHours % 60;
|
|
||||||
return String.format("%d小时%d分%d秒", hours, minutes, seconds);
|
|
||||||
}
|
|
||||||
public String formatMillis(long millis) {
|
public String formatMillis(long millis) {
|
||||||
Duration duration = Duration.ofMillis(millis);
|
Duration duration = Duration.ofMillis(millis);
|
||||||
int seconds = (int) (duration.getSeconds() % 60);
|
int seconds = (int) (duration.getSeconds() % 60);
|
||||||
|
@ -59,21 +59,18 @@ public class LiveDanmuService {
|
|||||||
|
|
||||||
public void saveDanmuXML(LiveVideoDatabaseBean videoDatabaseBean, BiliLiveDatabase database) {
|
public void saveDanmuXML(LiveVideoDatabaseBean videoDatabaseBean, BiliLiveDatabase database) {
|
||||||
File videoFile = new File(videoDatabaseBean.getPath());
|
File videoFile = new File(videoDatabaseBean.getPath());
|
||||||
long videoTime;
|
long videoTime = FFmpegUtils.getVideoTime(videoFile) + videoDatabaseBean.getStartTime().getTime();
|
||||||
if (videoDatabaseBean.getStopTime() == null) {
|
|
||||||
videoTime = System.currentTimeMillis();
|
|
||||||
} else {
|
|
||||||
videoTime = videoDatabaseBean.getStopTime().getTime();
|
|
||||||
}
|
|
||||||
Log.i("开始时间:" + videoDatabaseBean.getStartTime().getTime());
|
Log.i("开始时间:" + videoDatabaseBean.getStartTime().getTime());
|
||||||
Log.i("结束时间:" + videoTime);
|
Log.i("结束时间:" + videoTime);
|
||||||
List<LiveDanmuDatabaseBean> danmus = database.getOfTime(videoDatabaseBean.getStartTime().getTime(), videoTime, LiveDanmuDatabaseBean.class);
|
String startTime = DateFormatUtils.getInstance().format(videoDatabaseBean.getStartTime());
|
||||||
|
String endTime = DateFormatUtils.getInstance().format(videoTime);
|
||||||
|
List<LiveDanmuDatabaseBean> danmus = database.getOfTime(startTime, endTime, LiveDanmuDatabaseBean.class);
|
||||||
Log.i("弹幕数量:" + danmus.size());
|
Log.i("弹幕数量:" + danmus.size());
|
||||||
AssTools assTools = new AssTools(videoFile.getName().replace(".m3u8", ""), videoDatabaseBean.getStartTime());
|
AssTools assTools = new AssTools(videoFile.getName().replace(".flv", ""), videoDatabaseBean.getStartTime());
|
||||||
for (LiveDanmuDatabaseBean dm : danmus) {
|
for (LiveDanmuDatabaseBean dm : danmus) {
|
||||||
assTools.addDanmu(dm.createDanmuData());
|
assTools.addDanmu(dm.createDanmuData());
|
||||||
}
|
}
|
||||||
assTools.saveDanmu(videoFile.getAbsolutePath().replace(".m3u8", ".ass"));
|
assTools.saveDanmu(videoFile.getAbsolutePath().replace(".flv", ".ass"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toTimeString(long videoTime) {
|
public String toTimeString(long videoTime) {
|
||||||
@ -93,10 +90,19 @@ public class LiveDanmuService {
|
|||||||
if (videoBean == null) {
|
if (videoBean == null) {
|
||||||
return new LiveVideoDanmu();
|
return new LiveVideoDanmu();
|
||||||
}
|
}
|
||||||
|
File videoFile = new File(videoBean.getPath().replace(".flv", ".mp4"));
|
||||||
|
if (!videoFile.exists()) {
|
||||||
|
videoFile = new File(videoBean.getPath());
|
||||||
|
}
|
||||||
|
long videoTime = FFmpegUtils.getVideoTime(videoFile);
|
||||||
long startTime = Long.parseLong(videoId);
|
long startTime = Long.parseLong(videoId);
|
||||||
long endTime = videoBean.getStopTime() == null ? System.currentTimeMillis() : videoBean.getStopTime().getTime();
|
long endTime = Long.parseLong(videoId) + videoTime;
|
||||||
List<LiveDanmuDatabaseBean> danmuList = liveDatabase.getOfTime(startTime, endTime, LiveDanmuDatabaseBean.class);
|
// videoTime = 0;
|
||||||
List<LiveSuperChatDatabaseBean> superChatList = liveDatabase.getOfTime(startTime, endTime, LiveSuperChatDatabaseBean.class);
|
if (videoTime == 0) {
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
List<LiveDanmuDatabaseBean> danmuList = liveDatabase.getOfTime(DateFormatUtils.getInstance().format(startTime), DateFormatUtils.getInstance().format(endTime), LiveDanmuDatabaseBean.class);
|
||||||
|
List<LiveSuperChatDatabaseBean> superChatList = liveDatabase.getOfTime(DateFormatUtils.getInstance().format(startTime), DateFormatUtils.getInstance().format(endTime), LiveSuperChatDatabaseBean.class);
|
||||||
for (LiveDanmuDatabaseBean bean : danmuList) {
|
for (LiveDanmuDatabaseBean bean : danmuList) {
|
||||||
LiveVideoDanmu.Danmu danmu = createDanmu(bean, startTime);
|
LiveVideoDanmu.Danmu danmu = createDanmu(bean, startTime);
|
||||||
danmus.getDanmu().add(danmu);
|
danmus.getDanmu().add(danmu);
|
||||||
|
@ -113,8 +113,16 @@ public class LiveService {
|
|||||||
if (videoBean == null) {
|
if (videoBean == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
long startTime = videoBean.getStartTime().getTime();
|
File videoFile = new File(videoBean.getPath().replace(".flv", ".mp4"));
|
||||||
long endTime = videoBean.getStopTime() == null ? System.currentTimeMillis() : videoBean.getStopTime().getTime();
|
if (!videoFile.exists()) {
|
||||||
|
videoFile = new File(videoBean.getPath());
|
||||||
|
}
|
||||||
|
long videoTime = FFmpegUtils.getVideoTime(videoFile);
|
||||||
|
long startTime = Long.parseLong(videoId);
|
||||||
|
long endTime = Long.parseLong(videoId) + videoTime;
|
||||||
|
if(videoTime==0){
|
||||||
|
endTime=System.currentTimeMillis();
|
||||||
|
}
|
||||||
return database.getGiftInfo(startTime, endTime);
|
return database.getGiftInfo(startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.yutou.bilibili.services;
|
package com.yutou.bilibili.services;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.yutou.biliapi.api.UserApi;
|
import com.yutou.biliapi.api.UserApi;
|
||||||
import com.yutou.biliapi.bean.live.FollowLive;
|
|
||||||
import com.yutou.biliapi.bean.live.SpiBean;
|
import com.yutou.biliapi.bean.live.SpiBean;
|
||||||
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
import com.yutou.biliapi.bean.live.database.LiveConfigDatabaseBean;
|
||||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||||
@ -9,7 +9,7 @@ import com.yutou.biliapi.bean.user.UserFollowingsBean;
|
|||||||
import com.yutou.biliapi.bean.user.UserHomeInfoBean;
|
import com.yutou.biliapi.bean.user.UserHomeInfoBean;
|
||||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||||
import com.yutou.biliapi.net.BiliLiveNetApiManager;
|
import com.yutou.biliapi.net.BiliCookieManager;
|
||||||
import com.yutou.biliapi.net.BiliUserNetApiManager;
|
import com.yutou.biliapi.net.BiliUserNetApiManager;
|
||||||
import com.yutou.biliapi.net.WebSignManager;
|
import com.yutou.biliapi.net.WebSignManager;
|
||||||
import com.yutou.bilibili.datas.ResultData;
|
import com.yutou.bilibili.datas.ResultData;
|
||||||
@ -34,14 +34,6 @@ public class LiveUserService {
|
|||||||
@Resource
|
@Resource
|
||||||
LiveConfigService configService;
|
LiveConfigService configService;
|
||||||
|
|
||||||
public List<FollowLive.Room> getUserFollowLive(String userId) {
|
|
||||||
try {
|
|
||||||
FollowLive followLive = BiliLiveNetApiManager.getInstance().getApi(userId).getUserFollowLive(true, System.currentTimeMillis()).execute().body().getData();
|
|
||||||
return followLive.getRooms();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public UserFollowingsBean getUserFollowings(String userId, int page, int num) {
|
public UserFollowingsBean getUserFollowings(String userId, int page, int num) {
|
||||||
LoginCookieDatabaseBean cookie = userLoginService.getCookie(userId);
|
LoginCookieDatabaseBean cookie = userLoginService.getCookie(userId);
|
||||||
UserApi api = BiliUserNetApiManager.getInstance().getUserApi(cookie);
|
UserApi api = BiliUserNetApiManager.getInstance().getUserApi(cookie);
|
||||||
|
@ -120,7 +120,7 @@ public class LiveVideoDownloadService {
|
|||||||
File rootPath;
|
File rootPath;
|
||||||
LiveConfigDatabaseBean config;
|
LiveConfigDatabaseBean config;
|
||||||
BiliLiveDatabase database;
|
BiliLiveDatabase database;
|
||||||
LiveVideoDatabaseBean videoDatabaseBean = null;
|
LiveVideoDatabaseBean videoDatabaseBean;
|
||||||
LiveRoomInfo roomInfo;
|
LiveRoomInfo roomInfo;
|
||||||
|
|
||||||
public VideoTask(LiveConfigDatabaseBean bean, LiveRoomInfo roomInfo) {
|
public VideoTask(LiveConfigDatabaseBean bean, LiveRoomInfo roomInfo) {
|
||||||
@ -136,8 +136,8 @@ public class LiveVideoDownloadService {
|
|||||||
String time = DateUtils.format(new Date().getTime(), DATE_FORMAT_10_DASH);
|
String time = DateUtils.format(new Date().getTime(), DATE_FORMAT_10_DASH);
|
||||||
rootPath = new File(bean.getRecordPath() + File.separator + bean.getAnchorName() + File.separator + time + File.separator + "[" +
|
rootPath = new File(bean.getRecordPath() + File.separator + bean.getAnchorName() + File.separator + time + File.separator + "[" +
|
||||||
DateUtils.format(new Date(),
|
DateUtils.format(new Date(),
|
||||||
"HH-mm-ss") + "]" + roomInfo.getTitle());
|
"yyyy-MM-dd HH-mm-ss") + "]" + roomInfo.getTitle());
|
||||||
savePath = rootPath.getAbsolutePath() + File.separator + roomInfo.getTitle() + ".m3u8";
|
savePath = rootPath.getAbsolutePath() + File.separator + roomInfo.getTitle() + "-%04d.ts";
|
||||||
if (!rootPath.exists()) {
|
if (!rootPath.exists()) {
|
||||||
rootPath.mkdirs();
|
rootPath.mkdirs();
|
||||||
}
|
}
|
||||||
@ -148,14 +148,14 @@ public class LiveVideoDownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void stop() {
|
private void stop() {
|
||||||
videoRecord.kill(bean.getRoomId());
|
videoRecord.kill(bean.getRoomId().toString());
|
||||||
api.getRoomInfo(config.getRoomId()).enqueue(new HttpCallback<LiveRoomInfo>() {
|
api.getRoomInfo(config.getRoomId().toString()).enqueue(new HttpCallback<LiveRoomInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Headers headers, int code, String status, LiveRoomInfo response, String rawResponse) {
|
public void onResponse(Headers headers, int code, String status, LiveRoomInfo response, String rawResponse) {
|
||||||
if (response.getLiveStatus() == 1) {
|
if (response.getLiveStatus() == 1) {
|
||||||
LiveVideoDownloadService.this.start(bean, false);
|
LiveVideoDownloadService.this.start(bean, false);
|
||||||
} else {
|
} else {
|
||||||
LiveVideoDownloadService.this.stop(bean.getRoomId(), false);
|
LiveVideoDownloadService.this.stop(bean.getRoomId().toString(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,19 +289,20 @@ public class LiveVideoDownloadService {
|
|||||||
// .withNotSymbolParam("-bufsize", "10M")
|
// .withNotSymbolParam("-bufsize", "10M")
|
||||||
.withNotSymbolParam("-f", "segment")
|
.withNotSymbolParam("-f", "segment")
|
||||||
.withNotSymbolParam("-segment_time", "60")
|
.withNotSymbolParam("-segment_time", "60")
|
||||||
.withNotSymbolParam("-segment_format", "mpegts")
|
.withNotSymbolParam("-segment_format", "flv")
|
||||||
.withNotSymbolParam("-map", "0")
|
.withParam("-segment_list", rootPath + File.separator + roomInfo.getTitle() + ".m3u8")
|
||||||
.withParam("-segment_list", savePath)
|
|
||||||
.withNotSymbolParam("-c", "copy")
|
.withNotSymbolParam("-c", "copy")
|
||||||
.withNotSymbolParam("-bsf:a", "aac_adtstoasc")
|
.withNotSymbolParam("-bsf:a", "aac_adtstoasc")
|
||||||
// .withNotSymbolParam("-loglevel", "debug")
|
// .withNotSymbolParam("-loglevel", "debug")
|
||||||
.withNotSymbolParam("-y", "")
|
.withNotSymbolParam("-y", "")
|
||||||
|
//-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2
|
||||||
|
|
||||||
// .withNotSymbolParam("-progress",new File("cache",config.getRoomId()+".txt").getAbsolutePath()); //输出进度日志,暂时没啥用
|
// .withNotSymbolParam("-progress",new File("cache",config.getRoomId()+".txt").getAbsolutePath()); //输出进度日志,暂时没啥用
|
||||||
;
|
;
|
||||||
if (ck != null) {
|
if (ck != null) {
|
||||||
// builder = builder.withParam("-cookies", cookie);
|
// builder = builder.withParam("-cookies", cookie);
|
||||||
}
|
}
|
||||||
FFmpegUtils command = builder.build(config.getRoomId(), ffmpegPath, url, savePath.replace(".m3u8","-%04d.ts"));
|
FFmpegUtils command = builder.build(config.getRoomId(), ffmpegPath, url, savePath);
|
||||||
Log.i(command.getCommandDecode());
|
Log.i(command.getCommandDecode());
|
||||||
try {
|
try {
|
||||||
command.start(new DownloadInterface() {
|
command.start(new DownloadInterface() {
|
||||||
@ -334,10 +335,6 @@ public class LiveVideoDownloadService {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
task = null;
|
task = null;
|
||||||
}
|
}
|
||||||
if (videoDatabaseBean != null) {
|
|
||||||
videoDatabaseBean.setStopTime(new Date());
|
|
||||||
database.addLiveInfo(videoDatabaseBean);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -380,10 +380,11 @@ public abstract class SQLiteManager {
|
|||||||
protected <T extends AbsDatabasesBean> boolean delete(T t) {
|
protected <T extends AbsDatabasesBean> boolean delete(T t) {
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
try {
|
try {
|
||||||
|
String id = DateUtils.format(t.getSql_time(), "yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
statement = getConnection().createStatement();
|
statement = getConnection().createStatement();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("DELETE FROM `").append(t.getTableName()).append("` ");
|
sb.append("DELETE FROM `").append(t.getTableName()).append("` ");
|
||||||
sb.append(" WHERE `sql_time` = ").append("'").append(t.getSql_time().getTime()).append("'");
|
sb.append(" WHERE `sql_time` = ").append("'").append(id).append("'");
|
||||||
int ret = statement.executeUpdate(sb.toString());
|
int ret = statement.executeUpdate(sb.toString());
|
||||||
return ret != 0;
|
return ret != 0;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -182,6 +182,7 @@ public class FFmpegUtils extends AbsVideoRecord {
|
|||||||
process.exitValue();
|
process.exitValue();
|
||||||
return (long) (Double.parseDouble(data) * 1000);
|
return (long) (Double.parseDouble(data) * 1000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.e(e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user