[update] VipPrivilege type=9 vipExtraExp

This commit is contained in:
Lkeme 2023-10-29 23:15:24 +08:00
parent eafad42d3f
commit 901dd4e090
2 changed files with 75 additions and 4 deletions

View File

@ -15,6 +15,7 @@
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
use Bhp\Api\Vip\ApiExperience;
use Bhp\Api\Vip\ApiPrivilege;
use Bhp\Log\Log;
use Bhp\Plugin\BasePlugin;
@ -49,6 +50,7 @@ class VipPrivilege extends BasePlugin
3 => '年度专享漫画礼包',
4 => '大会员专享会员购包邮券',
5 => '年度专享漫画礼包',
9 => '会员观看任意1个视频即可领取日限1次',
];
/**
@ -73,8 +75,8 @@ class VipPrivilege extends BasePlugin
//
$this->receiveTask();
//
// 定时11点 + 随机120分钟
TimeLock::setTimes(TimeLock::timing(11) + mt_rand(1, 120) * 60);
// 定时23点 + 随机10-30分钟
TimeLock::setTimes(TimeLock::timing(23) + mt_rand(10, 30) * 60);
}
/**
@ -94,10 +96,32 @@ class VipPrivilege extends BasePlugin
if ($privilege['state'] != 0) {
continue;
}
// 特殊类型
if ($privilege['type'] != 9) {
// 领取奖励
$this->myVipPrivilegeReceive($privilege['type']);
} else {
// 领取额外经验
$this->myVipExtraExp();
}
}
}
/**
* 大会员额外经验
* @return void
*/
protected function myVipExtraExp(): void
{
$response = ApiExperience::add();
//
if (!$response['code']) {
Log::info("大会员额外经验: 领取额外经验成功");
} else {
Log::warning("大会员额外经验: 领取额外经验失败 {$response['code']} -> {$response['message']}");
}
}
/**
* 获取我的大会员权益列表

View File

@ -0,0 +1,47 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2023 ~ 2024
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\Vip;
use Bhp\Request\Request;
use Bhp\User\User;
class ApiExperience
{
/**
* 领取大会员额外经验
* @return array
*/
public static function add(): array
{
$user = User::parseCookie();
//
$url = 'https://api.bilibili.com/x/vip/experience/add';
$payload = [
'mid' => $user['uid'],
'csrf' => $user['csrf'],
// 'buvid'=>'B8B511D7-AE19-2586-6A5F-xxxxxx',
];
$headers = [
'origin' => 'https://account.bilibili.com',
'referer' => 'https://account.bilibili.com/',
];
// {"code":0,"message":"0","ttl":1,"data":{"type":0,"is_grant":true}}
return Request::postJson(true, 'pc', $url, $payload, $headers);
}
}