From 96db883319cf9f2bed5f9f6afb22eb2b97722b24 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Sun, 30 Apr 2023 16:51:30 +0800 Subject: [PATCH] [update] Version v2.1.0.230430 --- README.md | 2 +- docs/CHANGELOG.md | 21 +++++++++++++++ plugin/LiveGoldBox/LiveGoldBox.php | 2 +- plugin/Login/Login.php | 34 +++++++++++++++++++++++++ profile/example/device/device.yaml | 6 ++--- resources/version.json | 6 ++--- src/Api/Passport/ApiOauth2.php | 10 ++++---- src/Api/PassportTv/ApiQrcode.php | 41 ++++++++++++++++++++++++++++++ 8 files changed, 109 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9294ef0..b131e7a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@

- + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0da0037..98090ff 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,27 @@ [comment]: <> () + +## v2.1.0.230430 alpha (2023-04-30) + +### Added + +- + +### Changed + +- 更新宝箱穷举范围 + +### Fixed + +- 修复短信登录行为验证码手动识别错误 +- 尝试修复(-663|鉴权失败|联系账号组)导致的各类`array offset`错误 +- 修复一些日志错误 + +### Remarks + +- 请注意配置文件有所变动,注意更新。 + ## v2.0.7.230324 alpha (2023-03-24) ### Added diff --git a/plugin/LiveGoldBox/LiveGoldBox.php b/plugin/LiveGoldBox/LiveGoldBox.php index 203260a..6e3f256 100644 --- a/plugin/LiveGoldBox/LiveGoldBox.php +++ b/plugin/LiveGoldBox/LiveGoldBox.php @@ -77,7 +77,7 @@ class LiveGoldBox extends BasePlugin { if (TimeLock::getTimes() > time() || !getEnable('live_gold_box')) return; // 2022-06-07 - $this->calcAidRange(945, 1200); + $this->calcAidRange(1000, 1200); // $lottery_list = $this->fetchLotteryList(); // diff --git a/plugin/Login/Login.php b/plugin/Login/Login.php index 3e72175..3645bdb 100644 --- a/plugin/Login/Login.php +++ b/plugin/Login/Login.php @@ -265,6 +265,9 @@ class Login extends BasePlugin // // $this->updateInfo('username',$this->username); // $this->updateInfo('password',$this->password); + // 转换 + $access_token = $this->tvConvert(); + $this->updateInfo('access_token', $access_token); } /** @@ -744,4 +747,35 @@ class Login extends BasePlugin return implode("", array_reverse($cookies)); } + + /** + * @return string + */ + protected function tvConvert(): string + { + # Android 旧 + $app_key = base64_decode(getDevice('app.bili_a.app_key')); + $app_secret = base64_decode(getDevice('app.bili_a.secret_key')); + + $response = ApiQrcode::getConfrimUrl($app_key, $app_secret); + if ($response['code'] == 0 && isset($response['data']['has_login']) && $response['data']['has_login'] == 1) { + Log::info('获取tv转换确认链接成功'); + } else { + failExit('获取转换确认链接失败'); + } + // + $next_url = $response['data']['confirm_uri']; + $response = ApiQrcode::goConfrimUrl($next_url); + $location = $response['Location'][0]; +// var_dump($location); + preg_match('/access_key=([a-f0-9]+)/', $location, $matches); + $access_key = $matches[1]; +// var_dump($matches); + if (empty($access_key)) { + failExit('获取转换access_key失败'); + } + Log::info('获取tv转换access_key成功'); + return $access_key; + } + } diff --git a/profile/example/device/device.yaml b/profile/example/device/device.yaml index 0d6734c..80c760f 100644 --- a/profile/example/device/device.yaml +++ b/profile/example/device/device.yaml @@ -3,8 +3,8 @@ device_version: 0.0.1 app: bili_a: # Android package: "tv.danmaku.bili" - version: "7.22.0" - build: "7220300" + version: "7.27.0" + build: "7270300" channel: "bili" device: "phone" mobi_app: "android" @@ -15,7 +15,7 @@ app: secret_key: "NTYwYzUyY2NkMjg4ZmVkMDQ1ODU5ZWQxOGJmZmQ5NzM" app_key_n: "NzgzYmJiNzI2NDQ1MWQ4Mg==" secret_key_n: "MjY1MzU4M2M4ODczZGVhMjY4YWI5Mzg2OTE4YjFkNjU=" - statistics: '{"appId":1,"platform":3,"version":"7.22.0","abtest":""}' + statistics: '{"appId":1,"platform":3,"version":"7.27.0","abtest":""}' bili_i: # IOS app_key: "MjdlYjUzZmM5MDU4ZjhjMw==" secret_key: "YzJlZDUzYTc0ZWVlZmUzY2Y5OWZiZDAxZDhjOWMzNzU=" diff --git a/resources/version.json b/resources/version.json index 4df6cde..31d138d 100644 --- a/resources/version.json +++ b/resources/version.json @@ -7,10 +7,10 @@ "dev_raw_url": "https://gh.notifyplus.cf/https://github.com/lkeme/BiliHelper-personal/blob/dev/resources/version.json", "master_purge_url": "https://cdn.staticaly.com/gh/lkeme/BiliHelper-personal/master/resources/version.json", "dev_purge_url": "https://cdn.staticaly.com/gh/lkeme/BiliHelper-personal/dev/resources/version.json", - "version": "2.0.7.230324", + "version": "2.1.0.230430", "des": "程序有更新,请及时线上查看更新哦~", - "time": "2023年03月24日", + "time": "2023年04月30日", "ini_version": "0.0.1", "ini_des": "配置有更新,请及时线上查看更新哦~", - "ini_time": "2023年03月24日" + "ini_time": "2023年04月30日" } diff --git a/src/Api/Passport/ApiOauth2.php b/src/Api/Passport/ApiOauth2.php index 4600ccc..5db2716 100644 --- a/src/Api/Passport/ApiOauth2.php +++ b/src/Api/Passport/ApiOauth2.php @@ -34,7 +34,7 @@ class ApiOauth2 'access_token' => $token, ]; // {"ts":1234,"code":0,"data":{"mid":1234,"access_token":"1234","expires_in":7759292}} - return Request::getJson(true, 'app', $url, Sign::login($payload)); + return Request::getJson(true, 'app', $url, Sign::common($payload)); } /** @@ -49,7 +49,7 @@ class ApiOauth2 'access_key' => $token, ]; // {"code":0,"message":"0","ttl":1,"data":{"mid":"","access_token":"","expires_in":9787360,"refresh":true}} - return Request::getJson(true, 'app', $url, Sign::login($payload)); + return Request::getJson(true, 'app', $url, Sign::common($payload)); } /** @@ -83,7 +83,7 @@ class ApiOauth2 'refresh_token' => $r_token, ]; // {"message":"user not login","ts":1593111694,"code":-101} - return Request::postJson(true, 'app', $url, Sign::login($payload)); + return Request::postJson(true, 'app', $url, Sign::common($payload)); } /** @@ -97,7 +97,7 @@ class ApiOauth2 $payload = [ 'access_key' => $token, ]; - return Request::getJson(true, 'app', $url, Sign::login($payload)); + return Request::getJson(true, 'app', $url, Sign::common($payload)); } /** @@ -124,7 +124,7 @@ class ApiOauth2 'access_key' => $token, 'gourl' => 'https%3A%2F%2Faccount.bilibili.com%2Faccount%2Fhome' ]; - return Request::headers('app', $url, Sign::login($payload)); + return Request::headers('app', $url, Sign::common($payload)); } } diff --git a/src/Api/PassportTv/ApiQrcode.php b/src/Api/PassportTv/ApiQrcode.php index 942fa43..59036a7 100644 --- a/src/Api/PassportTv/ApiQrcode.php +++ b/src/Api/PassportTv/ApiQrcode.php @@ -57,4 +57,45 @@ class ApiQrcode } + /** + * 获取确认Url + * @param string $app_key + * @param string $app_secret + * @return array + */ + public static function getConfrimUrl(string $app_key, string $app_secret): array + { + $sign = md5('api=http://link.acg.tv/forum.php' . $app_secret); + // + $url = 'https://passport.bilibili.com/login/app/third'; + $payload = [ + 'appkey' => $app_key, + 'api' => 'http://link.acg.tv/forum.php', + 'sign' => $sign + ]; + $headers = [ + "origin" => 'https://passport.bilibili.com', + "referer" => 'https://passport.bilibili.com', + ]; + return Request::getJson(true, 'pc', $url, $payload, $headers); + } + + /** + * 跳转确认Url + * @param string $url + * @return array + */ + public static function goConfrimUrl(string $url): array + { + // 取出url的主体部分 + $query = parse_url($url)['query']; + // 取出url参数部分转为数组 + parse_str($query, $payload); + $headers = [ + "origin" => 'https://passport.bilibili.com', + "referer" => 'https://passport.bilibili.com', + ]; + return Request::headers('pc', $url, $payload, $headers); + } + }