[fix] FetchMedalList

This commit is contained in:
Lkeme 2022-01-04 17:41:19 +08:00
parent b0bb6a3e7f
commit 3194b4023a
6 changed files with 35 additions and 22 deletions

View File

@ -30,6 +30,7 @@
```notice
---- 免费的东西总是得不到人的珍惜。
---- 只有花大价钱去买到的东西,才会令人信任。
---- 本项目仅供学习交流使用,请勿用于非法用途!* 3
```
## 👤游客访问

View File

@ -3,8 +3,8 @@ bili_version: 0.0.1
# Android
bili_a:
package: "tv.danmaku.bili"
version: "6.51.0"
build: "6510400"
version: "6.55.0"
build: "6550400"
channel: "bili"
device: "phone"
mobi_app: "android"

View File

@ -149,7 +149,7 @@ class GiftSend
if ($vo['corner_mark'] == '永久') {
continue;
}
array_push($new_bag_list, $vo);
$new_bag_list[] = $vo;
}
}
return $new_bag_list;
@ -165,7 +165,7 @@ class GiftSend
$expire_gift_list = [];
foreach ($bag_list as $gift) {
if ($gift['expire_at'] >= time() && $gift['expire_at'] <= time() + 3600) {
array_push($expire_gift_list, $gift);
$expire_gift_list[] = $gift;
}
}
return $expire_gift_list;
@ -180,7 +180,8 @@ class GiftSend
$data = Live::fetchMedalList();
$fans_medals = [];
foreach ($data as $vo) {
if (!isset($vo['roomid'])) continue;
// 过滤主站勋章
if (!isset($vo['roomid']) || $vo['roomid'] == 0) continue;
$fans_medals[(string)$vo['roomid']] = $vo;
}
// 基于配置

View File

@ -332,37 +332,48 @@ class Live
* @param int $page_size
* @return array
*/
public static function fetchMedalList(int $page_size = 10): array
public static function fetchMedalList(int $page_size = 50): array
{
$metal_list = [];
for ($i = 1; $i <= 100; $i++) {
// https://live.bilibili.com/p/html/live-app-fansmedal-manange/index.html
// $url = 'https://api.live.bilibili.com/fans_medal/v5/live_fans_medal/iApiMedal';
$url = 'https://api.live.bilibili.com/i/api/medal';
// TODO size变小 需要优化获取逻辑 可能会412
$url = 'https://api.live.bilibili.com/xlive/app-ucenter/v1/fansMedal/panel';
$payload = [
'page' => $i,
'pageSize' => $page_size
'page_size' => $page_size
];
$raw = Curl::get('app', $url, Sign::common($payload));
$de_raw = json_decode($raw, true);
// {"code":0,"message":"0","ttl":1,"data":{"list":[],"special_list":[],"bottom_bar":null,"page_info":{"number":0,"current_page":1,"has_more":false,"next_page":2,"next_light_status":2},"total_number":0,"has_medal":0}}
if (isset($data['code']) && $data['code']) {
Log::warning('获取勋章列表失败!', ['msg' => $data['message']]);
return $metal_list;
}
if (empty($de_raw['data']['fansMedalList'])) {
return $metal_list;
}
if (isset($de_raw['data']['fansMedalList'])) {
foreach ($de_raw['data']['fansMedalList'] as $vo) {
array_push($metal_list, $vo);
// list special_list
$keys = ['list', 'special_list'];
foreach ($keys as $key) {
if (isset($de_raw['data'][$key])) {
foreach ($de_raw['data'][$key] as $vo) {
// 部分主站勋章没有直播间
if (isset($vo['room_info']['room_id'])) {
$vo['medal']['roomid'] = $vo['room_info']['room_id'];
} else {
$vo['medal']['roomid'] = 0;
}
$metal_list[] = $vo['medal'];
}
}
}
if ($de_raw['data']['pageinfo']['totalpages'] == $de_raw['data']['pageinfo']['curPage']) {
return $metal_list;
// total_number || count == 0
if (count($metal_list) >= $de_raw['data']['total_number'] || empty($metal_list)) {
break;
}
}
Log::info('勋章列表获取成功!');
// count == 0
if (!empty($metal_list)) {
$num = count($metal_list);
Log::info("勋章列表获取成功, 共获取到 $num 个!");
}
return $metal_list;
}

View File

@ -46,7 +46,7 @@ class PolishTheMedal
self::$metal_lock = time() + 10 * 60 * 60;
}
} else {
self::$metal_lock = time() + 1 * 60 * 60;
self::$metal_lock = time() + 60 * 60;
}
}
// 点亮灰色勋章
@ -88,7 +88,7 @@ class PolishTheMedal
$data = Live::fetchMedalList();
foreach ($data as $vo) {
// 过滤主站勋章
if (!isset($vo['roomid'])) continue;
if (!isset($vo['roomid']) || $vo['roomid'] == 0) continue;
// 过滤自己勋章
if ($vo['target_id'] == getUid()) continue;
// 所有

View File

@ -74,7 +74,7 @@ class SmallHeart
$data = Live::fetchMedalList();
foreach ($data as $vo) {
// 过滤主站勋章
if (!isset($vo['roomid'])) continue;
if (!isset($vo['roomid']) || $vo['roomid'] == 0) continue;
// 过滤自己勋章
if ($vo['target_id'] == getUid()) continue;
// 所有