From 7695c88817d90e7d0eeec0565f56a4a314286dcf Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Wed, 23 Jun 2021 16:44:26 +0800 Subject: [PATCH] [fix] MainSite & Silver2Coin fixed #90 --- CHANGELOG.md | 22 ++++++++++++ README.md | 70 +++++++++++++++++++------------------- data/activity_infos.json | 56 ------------------------------ data/capsule_infos.json | 17 +++++---- data/latest_version.json | 4 +-- src/core/App.php | 2 +- src/plugin/Live.php | 4 +-- src/plugin/MainSite.php | 38 ++++++++++++++++++--- src/plugin/Silver2Coin.php | 39 ++++++++++++++++++--- 9 files changed, 140 insertions(+), 112 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fc3c1d..44e2b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ # 本项目Log +## v0.9.4.210623 alpha (2021-06-23) + +### Added + +- + +### Changed + +- 更新部分仓库文件 +- + +### Fixed + +- 修复PC端银瓜子兑换硬币 +- 修复主站投币任务 +- 修复点亮勋章特殊情况 +- + +### Remarks + +- + ## v0.9.3.210616 alpha (2021-06-16) ### Added diff --git a/README.md b/README.md index 78edf41..43d2053 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@

- + @@ -37,40 +37,40 @@ | plugin | status | version | description | |-----------------|--------|----------|---------------------------------------------| -| CheckUpdate | true | 21.06.16 | 程序检查更新 | -| Login | true | 21.06.16 | 账号登录、刷新、维持 | -| Schedule | true | 21.06.16 | 控制插件运行周期 | -| MainSite | true | 21.06.16 | 投币、观看、分享视频 (速升6级不是梦) | -| DailyBag | true | 21.06.16 | 双端领取日常/周常礼包 | -| ManGa | true | 21.06.16 | 漫画签到、分享 | -| ActivityLottery | true | 21.06.16 | 主站活动九宫格抽奖 | -| Competition | true | 21.06.16 | 游戏赛事竞猜 | -| DoubleHeart | true | 21.06.16 | 双端心跳 (姥爷直播经验) | -| DailyTask | true | 21.06.16 | 直播每日任务(签到、观看) | -| Barrage | true | 21.06.16 | 保持活跃弹幕 | -| Silver2Coin | true | 21.06.16 | 银瓜子兑换硬币 | -| Judge | true | 21.06.16 | 风纪委员投票 | -| GiftSend | true | 21.06.16 | 礼物赠送、维持每日勋章亲密度 | -| GroupSignIn | true | 21.06.16 | 友爱社签到 | -| GiftHeart | true | 21.06.16 | 日常心跳每日礼包礼物 | -| SmallHeart | true | 21.06.16 | 直播挂机,每日24个小心心 | -| MaterialObject | true | 21.06.16 | 直播金色宝箱实物抽奖 | -| AloneTcpClient | true | 21.06.16 | 作者的独立直播监控(可支持本项目哦) | -| ZoneTcpClient | true | 21.06.16 | 官方的分区直播监控 | -| StormRaffle | true | 21.06.16 | 直播节奏风暴抽奖、亿元 | -| GiftRaffle | true | 21.06.16 | 直播礼物抽奖 | -| PkRaffle | true | 21.06.16 | 直播大乱斗抽奖 | -| GuardRaffle | true | 21.06.16 | 直播大航海抽奖 | -| AnchorRaffle | true | 21.06.16 | 直播天选时刻抽奖 | -| GiftRaffle | true | 21.06.16 | 直播礼物抽奖 | -| AwardRecord | true | 21.06.16 | 最新的中奖纪录通知 | -| Forward | true | 21.06.16 | 主站动态抽奖转发 | -| CapsuleLottery | true | 21.06.16 | 直播扭蛋活动抽奖 | -| PolishTheMedal | true | 21.06.16 | 每日自动点亮灰色勋章 | -| CapsuleLottery | true | 21.06.16 | 直播扭蛋活动抽奖 | -| VipPrivilege | true | 21.06.16 | 每月领取年度大会员特权(B币券、会员购优惠券) | -| BpConsumption | true | 21.06.16 | 每月消费使用年度大会员特权的B币券 | -| Statistics | true | 21.06.16 | 全局抽奖结果统计 | +| CheckUpdate | true | 21.06.23 | 程序检查更新 | +| Login | true | 21.06.23 | 账号登录、刷新、维持 | +| Schedule | true | 21.06.23 | 控制插件运行周期 | +| MainSite | true | 21.06.23 | 投币、观看、分享视频 (速升6级不是梦) | +| DailyBag | true | 21.06.23 | 双端领取日常/周常礼包 | +| ManGa | true | 21.06.23 | 漫画签到、分享 | +| ActivityLottery | true | 21.06.23 | 主站活动九宫格抽奖 | +| Competition | true | 21.06.23 | 游戏赛事竞猜 | +| DoubleHeart | true | 21.06.23 | 双端心跳 (姥爷直播经验) | +| DailyTask | true | 21.06.23 | 直播每日任务(签到、观看) | +| Barrage | true | 21.06.23 | 保持活跃弹幕 | +| Silver2Coin | true | 21.06.23 | 银瓜子兑换硬币 | +| Judge | true | 21.06.23 | 风纪委员投票 | +| GiftSend | true | 21.06.23 | 礼物赠送、维持每日勋章亲密度 | +| GroupSignIn | true | 21.06.23 | 友爱社签到 | +| GiftHeart | true | 21.06.23 | 日常心跳每日礼包礼物 | +| SmallHeart | true | 21.06.23 | 直播挂机,每日24个小心心 | +| MaterialObject | true | 21.06.23 | 直播金色宝箱实物抽奖 | +| AloneTcpClient | true | 21.06.23 | 作者的独立直播监控(可支持本项目哦) | +| ZoneTcpClient | true | 21.06.23 | 官方的分区直播监控 | +| StormRaffle | true | 21.06.23 | 直播节奏风暴抽奖、亿元 | +| GiftRaffle | true | 21.06.23 | 直播礼物抽奖 | +| PkRaffle | true | 21.06.23 | 直播大乱斗抽奖 | +| GuardRaffle | true | 21.06.23 | 直播大航海抽奖 | +| AnchorRaffle | true | 21.06.23 | 直播天选时刻抽奖 | +| GiftRaffle | true | 21.06.23 | 直播礼物抽奖 | +| AwardRecord | true | 21.06.23 | 最新的中奖纪录通知 | +| Forward | true | 21.06.23 | 主站动态抽奖转发 | +| CapsuleLottery | true | 21.06.23 | 直播扭蛋活动抽奖 | +| PolishTheMedal | true | 21.06.23 | 每日自动点亮灰色勋章 | +| CapsuleLottery | true | 21.06.23 | 直播扭蛋活动抽奖 | +| VipPrivilege | true | 21.06.23 | 每月领取年度大会员特权(B币券、会员购优惠券) | +| BpConsumption | true | 21.06.23 | 每月消费使用年度大会员特权的B币券 | +| Statistics | true | 21.06.23 | 全局抽奖结果统计 | | Silver | false | 21.03.27 | 直播银瓜子自动开启宝箱 | ## 交流反馈 diff --git a/data/activity_infos.json b/data/activity_infos.json index 832be33..9b50c37 100644 --- a/data/activity_infos.json +++ b/data/activity_infos.json @@ -31,62 +31,6 @@ "share": "true", "draw_times": 1, "expire_at": "2021-07-15 11:59:59" - }, - { - "url": "https://www.bilibili.com/blackboard/activity-aT7zphkwF1.html", - "title": "初夏逛吃大会", - "description": "活动期间每天分享页面,新增一次机会。", - "sid": "01aff78a-9e1a-11eb-8597-246e966235d8", - "login": "true", - "follow": "false", - "share": "true", - "draw_times": 1, - "expire_at": "2021-06-10 23:59:59" - }, - { - "url": "https://www.bilibili.com/blackboard/activity-Tpo81ydpiW.html", - "title": "和平精英周年庆嘉年华1次", - "description": "活动期间每天分享页面,新增一次机会。", - "sid": "e2d93baa-96b9-11eb-8597-246e966235d8", - "login": "true", - "follow": "false", - "share": "true", - "draw_times": 1, - "expire_at": "2021-06-15 23:59:59" - }, - { - "url": "https://www.bilibili.com/blackboard/activity-Tpo81ydpiW.html", - "title": "和平精英周年庆嘉年华2次", - "description": "活动期间每天分享页面,新增一次机会。", - "sid": "e2d93baa-96b9-11eb-8597-246e966235d8", - "login": "true", - "follow": "false", - "share": "true", - "draw_times": 1, - "expire_at": "2021-06-15 23:59:59" - }, - { - "url": "https://www.bilibili.com/blackboard/activity-Tpo81ydpiW.html", - "title": "和平精英周年庆嘉年华3次", - "description": "活动期间每天分享页面,新增一次机会。", - "sid": "e2d93baa-96b9-11eb-8597-246e966235d8", - "login": "true", - "follow": "false", - "share": "true", - "draw_times": 1, - "expire_at": "2021-06-15 23:59:59" - } - , - { - "url": "https://www.bilibili.com/blackboard/topic/activity-natsume.html", - "title": "夏目友人帐新作动画有奖预约页", - "description": "活动期间每天分享页面,新增一次机会。", - "sid": "a213c0b5-b6d4-11eb-8597-246e966235d8", - "login": "true", - "follow": "false", - "share": "true", - "draw_times": 1, - "expire_at": "2021-06-15 23:59:59" } ] } \ No newline at end of file diff --git a/data/capsule_infos.json b/data/capsule_infos.json index d7e518f..1554e38 100644 --- a/data/capsule_infos.json +++ b/data/capsule_infos.json @@ -5,9 +5,9 @@ "data": [ { "_url": "注释: 活动地址", - "url": "https://www.bilibili.com/blackboard/activity-raop07Ymhm.html", + "url": "https://www.bilibili.com/blackboard/activity-kiOl0D1nF8.html", "_title": "注释: 活动标题", - "title": "原神1.5版本UP主激励计划", + "title": "原神1.6版本UP主激励计划", "_description": "注释: 活动描述", "description": "每日在原神分区任意直播间观看,20分钟1张、1小时2张、2小时3张,每日最高6张。", "_room_id": "注释: 活动直播间,如果为0,则取分区随机一个", @@ -17,13 +17,15 @@ "_parent_area_id": "注释: 主分区id", "parent_area_id": 3, "_coin_id": "注释: 抽奖id", - "coin_id": 135, + "coin_id": 165, + "_pool_id": "注释: 抽奖id", + "pool_id": 179, "_watch_time": "注释: 观看时长 单位秒", "watch_time": 7320, "_draw_times": "注释: 抽奖次数", - "draw_times": 1, + "draw_times": 6, "_expire_at": "注释: 活动有效时间", - "expire_at": "2021-06-08 23:59:59" + "expire_at": "2021-07-20 23:59:59" }, { "url": "https://live.bilibili.com/11218604", @@ -32,10 +34,11 @@ "room_id": 11218604, "area_id": 0, "parent_area_id": 2, - "coin_id": 129, + "coin_id": 170, + "pool_id": 183, "watch_time": 3720, "draw_times": 3, - "expire_at": "2021-05-30 23:59:59" + "expire_at": "2021-06-27 23:59:59" }, { "url": "https://live.bilibili.com/6", diff --git a/data/latest_version.json b/data/latest_version.json index 6c97590..436c604 100644 --- a/data/latest_version.json +++ b/data/latest_version.json @@ -5,7 +5,7 @@ "source": "https://github.com/lkeme/BiliHelper-personal", "raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", "purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", - "version": "0.9.2.210602", + "version": "0.9.4.210623", "des": "程序有更新,请及时线上查看更新哦~", - "time": "2021年6月2日21:40:35" + "time": "2021年6月23日21:40:35" } \ No newline at end of file diff --git a/src/core/App.php b/src/core/App.php index 25ccbae..ecdce88 100644 --- a/src/core/App.php +++ b/src/core/App.php @@ -42,7 +42,7 @@ class App * @param string $load_file * @return $this */ - public function load($load_file = 'user.ini'): App + public function load(string $load_file = 'user.ini'): App { Config::load($load_file); return $this; diff --git a/src/plugin/Live.php b/src/plugin/Live.php index b9914ec..834eb44 100644 --- a/src/plugin/Live.php +++ b/src/plugin/Live.php @@ -246,7 +246,7 @@ class Live { $room_id = self::getRealRoomID($room_id); if (!$room_id) { - return ['code' => 404, 'msg' => '直播间数据异常']; + return ['code' => 404, 'message' => '直播间数据异常']; } $url = 'https://api.live.bilibili.com/msg/send'; $payload = [ @@ -279,7 +279,7 @@ class Live { $room_id = self::getRealRoomID($room_id); if (!$room_id) { - return ['code' => 404, 'msg' => '直播间数据异常']; + return ['code' => 404, 'message' => '直播间数据异常']; } $url = 'https://api.live.bilibili.com/msg/send'; $payload = [ diff --git a/src/plugin/MainSite.php b/src/plugin/MainSite.php index 4c438d5..dac6dd6 100644 --- a/src/plugin/MainSite.php +++ b/src/plugin/MainSite.php @@ -50,13 +50,15 @@ class MainSite 'Referer' => "https://www.bilibili.com/video/av{$aid}", 'User-Agent' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36", ]; + // {"code":34005,"message":"超过投币上限啦~","ttl":1,"data":{"like":false}} + // {"code":0,"message":"0","ttl":1,"data":{"like":false}} $raw = Curl::post('app', $url, Sign::common($payload), $headers); $de_raw = json_decode($raw, true); if ($de_raw['code'] == 0) { - Log::notice("主站任务: av{$aid} 投币成功"); + Log::notice("主站任务: av{$aid} 投币成功 {$de_raw['code']} MSG -> {$de_raw['message']}"); return true; } else { - Log::warning("主站任务: av{$aid} 投币失败"); + Log::warning("主站任务: av{$aid} 投币失败 CODE -> {$de_raw['code']} MSG -> {$de_raw['message']}"); return false; } } @@ -120,7 +122,7 @@ class MainSite // 稿件列表 if (getConf('add_coin_mode', 'main_site') == 'random') { // 随机热门稿件榜单 - $aids = self::getDayRankingAids($actual_num); + $aids = self::getTopRCmdAids($actual_num); } else { // 固定获取关注UP稿件榜单, 不足会随机补全 $aids = self::getFollowUpAids($actual_num); @@ -181,7 +183,7 @@ class MainSite } // 此处补全缺失 if (count($aids) < $num) { - $aids = array_merge($aids, self::getDayRankingAids($num - count($aids))); + $aids = array_merge($aids, self::getTopRCmdAids($num - count($aids))); } return $aids; } @@ -222,6 +224,34 @@ class MainSite return $aids; } + /** + * @use 首页推荐 + * @param int $num + * @param int $ps + * @return array + */ + private static function getTopRCmdAids(int $num, int $ps = 30): array + { + // 动画1 国创168 音乐3 舞蹈129 游戏4 知识36 科技188 汽车223 生活160 美食211 动物圈127 鬼畜119 时尚155 资讯202 娱乐5 影视181 + $rids = [1, 168, 3, 129, 4, 36, 188, 223, 160, 211, 127, 119, 155, 202, 5, 181]; + $aids = []; + $url = 'https://api.bilibili.com/x/web-interface/dynamic/region'; + $payload = [ + 'ps' => $ps, + 'rid' => $rids[array_rand($rids)], + ]; + $raw = Curl::get('other', $url, $payload); + $de_raw = json_decode($raw, true); + if ($de_raw['code'] == 0) { + $temps = array_rand($de_raw['data']['archives'], $num); + foreach ($temps as $temp) { + array_push($aids, $de_raw['data']['archives'][$temp]['aid']); + } + return $aids; + } + return self::getDayRankingAids($num); + } + /** * @use 分享视频 * @return bool diff --git a/src/plugin/Silver2Coin.php b/src/plugin/Silver2Coin.php index f7a81f8..ed0ed4f 100644 --- a/src/plugin/Silver2Coin.php +++ b/src/plugin/Silver2Coin.php @@ -43,7 +43,7 @@ class Silver2Coin $raw = Curl::get('app', $url, Sign::common($payload)); $de_raw = json_decode($raw, true); - return self::handle('APP', $de_raw); + return self::appHandle('APP', $de_raw); } @@ -54,13 +54,18 @@ class Silver2Coin protected static function pcSilver2coin(): bool { sleep(0.5); - $payload = []; + $payload = [ + 'csrf_token' => getCsrf(), + 'csrf' => getCsrf(), + 'visit_id' => '' + ]; $url = "https://api.live.bilibili.com/exchange/silver2coin"; $url = "https://api.live.bilibili.com/pay/v1/Exchange/silver2coin"; - $raw = Curl::get('pc', $url, $payload); + $url = "https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin"; + $raw = Curl::post('pc', $url, $payload); $de_raw = json_decode($raw, true); - return self::handle('PC', $de_raw); + return self::pcHandle('PC', $de_raw); } /** @@ -69,7 +74,7 @@ class Silver2Coin * @param array $data * @return bool */ - private static function handle(string $type, array $data): bool + private static function appHandle(string $type, array $data): bool { // {"code":403,"msg":"每天最多能兑换 1 个","message":"每天最多能兑换 1 个","data":[]} // {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]} @@ -86,4 +91,28 @@ class Silver2Coin return false; } } + + /** + * @use 处理结果 + * @param string $type + * @param array $data + * @return bool + */ + private static function pcHandle(string $type, array $data): bool + { + // {"code":403,"msg":"每天最多能兑换 1 个","message":"每天最多能兑换 1 个","data":[]} + // {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]} + // {"code":0,"msg":"兑换成功","message":"兑换成功","data":{"gold":"5074","silver":"36734","tid":"727ab65376a15a6b117cf560a20a21122334","coin":1}} + switch ($data['code']) { + case 0: + Log::notice("[{$type}] 银瓜子兑换硬币: {$data['message']}"); + return true; + case 403: + Log::warning("[{$type}] 银瓜子兑换硬币: {$data['message']}"); + return true; + default: + Log::warning("[{$type}] 银瓜子兑换硬币: CODE -> {$data['code']} MSG -> {$data['message']} "); + return false; + } + } } \ No newline at end of file