mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-21 11:10:07 +08:00
[fix] XliveHeartBeat
This commit is contained in:
parent
7ab42e6fc0
commit
3a2dfff7c9
@ -40,12 +40,31 @@ class Barrage
|
|||||||
self::setLock(30);
|
self::setLock(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取颜文字信息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getEmojiMsg(): string
|
||||||
|
{
|
||||||
|
$emoji_list = [
|
||||||
|
"(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)",
|
||||||
|
"(°∀°)ノ", "( ̄3 ̄)", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "←_←", "→_→",
|
||||||
|
"(<_<)", "(>_>)", "(;¬_¬)", '("▔□▔)/', "(゚Д゚≡゚д゚)!?", "Σ(゚д゚;)", "Σ(  ̄□ ̄||)",
|
||||||
|
"(´;ω;`)", "(/TДT)/", "(^・ω・^ )", "(。・ω・。)", "(● ̄(エ) ̄●)", "ε=ε=(ノ≧∇≦)ノ",
|
||||||
|
"(´・_・`)", "(-_-#)", "( ̄へ ̄)", "( ̄ε(# ̄) Σ", "ヽ(`Д´)ノ", "(#-_-)┯━┯",
|
||||||
|
"(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄",
|
||||||
|
"(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)"
|
||||||
|
];
|
||||||
|
shuffle($emoji_list);
|
||||||
|
return $emoji_list[array_rand($emoji_list)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取随机弹幕
|
* @use 获取一言api消息
|
||||||
* @return \Exception|false|mixed|string|null
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function getMsgInfo()
|
private static function getMsgInfo():string
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 整理一部分API,收集于网络,侵权麻烦联系我删除.
|
* 整理一部分API,收集于网络,侵权麻烦联系我删除.
|
||||||
@ -57,15 +76,13 @@ class Barrage
|
|||||||
'https://api.ly522.com/yan.php?format=text',
|
'https://api.ly522.com/yan.php?format=text',
|
||||||
'https://v1.hitokoto.cn/?encode=text',
|
'https://v1.hitokoto.cn/?encode=text',
|
||||||
'https://api.jysafe.cn/yy/',
|
'https://api.jysafe.cn/yy/',
|
||||||
'https://api.ooopn.com/yan/api.php?type=text',
|
|
||||||
'https://api.imjad.cn/hitokoto/',
|
'https://api.imjad.cn/hitokoto/',
|
||||||
'https://www.ly522.com/hitokoto/',
|
'https://www.ly522.com/hitokoto/',
|
||||||
'https://api.guoch.xyz/',
|
'https://api.guoch.xyz/',
|
||||||
'http://www.ooomg.cn/dutang/',
|
|
||||||
'https://api.gushi.ci/rensheng.txt',
|
'https://api.gushi.ci/rensheng.txt',
|
||||||
'https://api.itswincer.com/hitokoto/v2/',
|
'https://api.itswincer.com/hitokoto/v2/',
|
||||||
'http://api.dsecret.com/yiyan/',
|
// 'http://www.ooomg.cn/dutang/',
|
||||||
'https://api.xygeng.cn/dailywd/api/api.php',
|
// 'http://api.dsecret.com/yiyan/',
|
||||||
];
|
];
|
||||||
shuffle($apis);
|
shuffle($apis);
|
||||||
try {
|
try {
|
||||||
@ -81,7 +98,7 @@ class Barrage
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $e;
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +137,10 @@ class Barrage
|
|||||||
//TODO 短期功能 有需求就修改
|
//TODO 短期功能 有需求就修改
|
||||||
$response = self::sendMsg($info);
|
$response = self::sendMsg($info);
|
||||||
if (isset($response['code']) && $response['code'] == 0) {
|
if (isset($response['code']) && $response['code'] == 0) {
|
||||||
Log::info('活跃弹幕发送成功!');
|
Log::info('弹幕发送成功');
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Log::warning("活跃代码发送失败, CODE -> {$response['code']} MSG -> {$response['msg']} ");
|
Log::warning("弹幕发送失败, CODE -> {$response['code']} MSG -> {$response['msg']} ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ class CapsuleLottery
|
|||||||
* @use 执行任务
|
* @use 执行任务
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private static function workTask()
|
private static function workTask(): bool
|
||||||
{
|
{
|
||||||
if (self::$work_status['work_completed'] == date("Y/m/d")) {
|
if (self::$work_status['work_completed'] == date("Y/m/d")) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -246,7 +246,8 @@ class Judge
|
|||||||
];
|
];
|
||||||
$raw = Curl::get('pc', $url, $payload, $headers);
|
$raw = Curl::get('pc', $url, $payload, $headers);
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
print_r($de_raw);
|
// print_r($de_raw);
|
||||||
|
Log::debug($raw);
|
||||||
$data = $de_raw['data'];
|
$data = $de_raw['data'];
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
Log::info('该用户非风纪委成员');
|
Log::info('该用户非风纪委成员');
|
||||||
|
|||||||
@ -55,6 +55,13 @@ trait XliveHeartBeat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 任务接口
|
||||||
|
* @param int $room_id
|
||||||
|
* @param int $max_time
|
||||||
|
* @param int $max_num
|
||||||
|
* @return int|mixed
|
||||||
|
*/
|
||||||
protected static function xliveHeartBeatTask(int $room_id, int $max_time, int $max_num)
|
protected static function xliveHeartBeatTask(int $room_id, int $max_time, int $max_num)
|
||||||
{
|
{
|
||||||
// 加载依赖
|
// 加载依赖
|
||||||
@ -73,6 +80,7 @@ trait XliveHeartBeat
|
|||||||
Log::warning('直播间信息获取失败');
|
Log::warning('直播间信息获取失败');
|
||||||
return static::$_default;
|
return static::$_default;
|
||||||
}
|
}
|
||||||
|
static::$_room_info = $r_data;
|
||||||
$rdata = $r_data['data'];
|
$rdata = $r_data['data'];
|
||||||
$parent_area_id = $rdata['room_info']['parent_area_id'];
|
$parent_area_id = $rdata['room_info']['parent_area_id'];
|
||||||
$area_id = $rdata['room_info']['area_id'];
|
$area_id = $rdata['room_info']['area_id'];
|
||||||
@ -85,7 +93,7 @@ trait XliveHeartBeat
|
|||||||
$index = static::$_data['id'][2];
|
$index = static::$_data['id'][2];
|
||||||
if ($r_data['code'] != 0) {
|
if ($r_data['code'] != 0) {
|
||||||
if (static::$_retry) {
|
if (static::$_retry) {
|
||||||
Log::warning("心跳失败-{$index} {$r_data['message']}");
|
Log::warning("心跳失败-$index {$r_data['message']}");
|
||||||
static::resetVar();
|
static::resetVar();
|
||||||
static::$_retry -= 1;
|
static::$_retry -= 1;
|
||||||
return static::$_default;
|
return static::$_default;
|
||||||
@ -103,7 +111,7 @@ trait XliveHeartBeat
|
|||||||
//成功在id为{room_id}的直播间发送第{ii}次心跳
|
//成功在id为{room_id}的直播间发送第{ii}次心跳
|
||||||
}
|
}
|
||||||
$minute = round(static::$_count_time / 60);
|
$minute = round(static::$_count_time / 60);
|
||||||
Log::info("已在直播间 {$room_id} 连续观看了 {$minute} 分钟");
|
Log::info("已在直播间 $room_id 连续观看了 $minute 分钟");
|
||||||
return $r_data['heartbeat_interval'];
|
return $r_data['heartbeat_interval'];
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -125,6 +133,10 @@ trait XliveHeartBeat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 心跳迭代
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected static function heartBeatIterator(): array
|
protected static function heartBeatIterator(): array
|
||||||
{
|
{
|
||||||
$rdata = [];
|
$rdata = [];
|
||||||
@ -145,6 +157,7 @@ trait XliveHeartBeat
|
|||||||
static::$_secret_rule = $rdata['secret_rule'];
|
static::$_secret_rule = $rdata['secret_rule'];
|
||||||
static::$_data['id'][2] += 1;
|
static::$_data['id'][2] += 1;
|
||||||
}
|
}
|
||||||
|
Log::debug(json_encode(static::$_data['id'], true));
|
||||||
return [
|
return [
|
||||||
'code' => $r_data['code'],
|
'code' => $r_data['code'],
|
||||||
'message' => $r_data['message'],
|
'message' => $r_data['message'],
|
||||||
@ -178,6 +191,8 @@ trait XliveHeartBeat
|
|||||||
'csrf' => $user_info['token'],
|
'csrf' => $user_info['token'],
|
||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
|
// print_r($payload);
|
||||||
|
Log::debug(json_encode($payload, true));
|
||||||
$raw = Curl::post('pc', $url, $payload, $headers);
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
// {'code':0,'message':'0','ttl':1,'data':{'timestamp':1595342828,'heartbeat_interval':300,'secret_key':'seacasdgyijfhofiuxoannn','secret_rule':[2,5,1,4],'patch_status':2}}
|
// {'code':0,'message':'0','ttl':1,'data':{'timestamp':1595342828,'heartbeat_interval':300,'secret_key':'seacasdgyijfhofiuxoannn','secret_rule':[2,5,1,4],'patch_status':2}}
|
||||||
|
|
||||||
@ -196,6 +211,11 @@ trait XliveHeartBeat
|
|||||||
{
|
{
|
||||||
$url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/X';
|
$url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/X';
|
||||||
$user_info = User::parseCookies();
|
$user_info = User::parseCookies();
|
||||||
|
$headers = [
|
||||||
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
|
'Origin' => 'https://live.bilibili.com',
|
||||||
|
'Referer' => 'https://live.bilibili.com/' . $id[3],
|
||||||
|
];
|
||||||
$payload = [
|
$payload = [
|
||||||
's' => static::$_data['s'],
|
's' => static::$_data['s'],
|
||||||
'id' => json_encode([$id[0], $id[1], $id[2], $id[3]], true),
|
'id' => json_encode([$id[0], $id[1], $id[2], $id[3]], true),
|
||||||
@ -210,7 +230,8 @@ trait XliveHeartBeat
|
|||||||
'visit_id' => ''
|
'visit_id' => ''
|
||||||
];
|
];
|
||||||
// print_r($payload);
|
// print_r($payload);
|
||||||
$raw = Curl::post('pc', $url, $payload, static::$hb_headers);
|
Log::debug(json_encode($payload, true));
|
||||||
|
$raw = Curl::post('pc', $url, $payload, $headers);
|
||||||
# {'code':0,'message':'0','ttl':1,'data':{'heartbeat_interval':300,'timestamp':1595346846,'secret_rule':[2,5,1,4],'secret_key':'seacasdgyijfhofiuxoannn'}}
|
# {'code':0,'message':'0','ttl':1,'data':{'heartbeat_interval':300,'timestamp':1595346846,'secret_rule':[2,5,1,4],'secret_key':'seacasdgyijfhofiuxoannn'}}
|
||||||
return json_decode($raw, true);
|
return json_decode($raw, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user