From b3204358a5c28e6090bc9e2d0f0ab8f8277ba787 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Fri, 27 Jan 2023 00:12:30 +0800 Subject: [PATCH] [update] Version v2.0.6.230127 --- README.md | 2 +- docker/Dockerfile | 1 + docs/CHANGELOG.md | 20 ++++++++ plugin/MainSite/MainSite.php | 80 +++++++++++++++++++----------- profile/example/config/user.ini | 5 +- resources/version.json | 6 +-- src/Api/Api/X/Player/ApiPlayer.php | 34 +++++++++++++ 7 files changed, 113 insertions(+), 35 deletions(-) create mode 100644 src/Api/Api/X/Player/ApiPlayer.php diff --git a/README.md b/README.md index 06e284e..5ffa1b0 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@

- + diff --git a/docker/Dockerfile b/docker/Dockerfile index f9aa3d6..a65400b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,6 +47,7 @@ RUN set -x; \ #ENV PATH=/root/.composer/vendor/bin:$PATH RUN apk add --no-cache git && \ + # https://github.com/php/php-src/issues/8681 apk add --no-cache linux-headers && \ git clone ${REPO_URL}/lkeme/BiliHelper-personal.git --depth=1 /app && \ cp -f /app/docker/entrypoint.sh /usr/local/bin/entrypoint.sh && \ diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 282e013..60f6d62 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,26 @@ [comment]: <> () +## v2.0.6.230127 alpha (2023-01-27) + +### Added + +- pushDeer推送 +- + +### Changed + +- 更新主站任务逻辑(alpha) +- + +### Fixed + +- Docker Build Eroor + +### Remarks + +- 请注意配置文件有所变动,注意更新。 + ## v2.0.4.221222 alpha (2022-12-22) ### Added diff --git a/plugin/MainSite/MainSite.php b/plugin/MainSite/MainSite.php index 4a25bca..f440b64 100644 --- a/plugin/MainSite/MainSite.php +++ b/plugin/MainSite/MainSite.php @@ -15,6 +15,7 @@ * |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\ */ +use Bhp\Api\Api\X\Player\ApiPlayer; use Bhp\Api\DynamicSvr\ApiDynamicSvr; use Bhp\Api\Video\ApiCoin; use Bhp\Api\Video\ApiShare; @@ -69,6 +70,23 @@ class MainSite extends BasePlugin } } + /** + * 获取稿件列表 + * @param int $num + * @return array + */ + protected function fetchCustomAids(int $num = 30): array + { + if (getConf('main_site.fetch_aids_mode') == 'random') { + // 随机热门稿件榜单 + return $this->getTopArchives($num); + } else { + // 固定获取关注UP稿件榜单, 不足会随机补全 + return $this->getFollowUpAids($num); + } + } + + /** * 投币任务 * @return bool @@ -92,13 +110,7 @@ class MainSite extends BasePlugin return true; } // 稿件列表 - if (getConf('main_site.add_coin_mode') == 'random') { - // 随机热门稿件榜单 - $aids = self::getTopAids($actual_num); - } else { - // 固定获取关注UP稿件榜单, 不足会随机补全 - $aids = self::getFollowUpAids($actual_num); - } + $aids = $this->fetchCustomAids($actual_num); // Log::info("主站任务: 预投币稿件 " . implode(" ", $aids)); // 投币 @@ -137,25 +149,20 @@ class MainSite extends BasePlugin * @param int $ps * @return array */ - protected function getTopAids(int $num, int $ps = 30): array + protected function getTopArchives(int $num, int $ps = 30): array { - $aids = []; $response = ApiVideo::dynamicRegion($ps); // if ($response['code']) { Log::warning("主站任务: 获取首页推荐失败 {$response['code']} -> {$response['message']}"); - return self::getDayRankingAids($num); + return $this->getDayRankingArchives($num); } // if ($num == 1) { - $temps = [array_rand($response['data']['archives'], $num)]; + return [array_rand($response['data']['archives'], $num)]; } else { - $temps = array_rand($response['data']['archives'], $num); + return array_rand($response['data']['archives'], $num); } - foreach ($temps as $temp) { - $aids[] = $response['data']['archives'][$temp]['aid']; - } - return $aids; } /** @@ -163,9 +170,9 @@ class MainSite extends BasePlugin * @param int $num * @return array */ - protected function getDayRankingAids(int $num): array + protected function getDayRankingArchives(int $num): array { - $aids = []; + $archives = []; $rand_nums = []; // $response = ApiVideo::ranking(); @@ -180,11 +187,10 @@ class MainSite extends BasePlugin break; } } - $aid = $response['data']['list'][$rand_nums[$i]]['aid']; - $aids[] = $aid; + $archives[] = $response['data']['list'][$rand_nums[$i]]; } // - return $aids; + return $archives; } /** @@ -211,7 +217,7 @@ class MainSite extends BasePlugin } // 此处补全缺失 if (count($aids) < $num) { - $aids = array_merge($aids, $this->getTopAids($num - count($aids))); + $aids = array_merge($aids, $this->getTopArchives($num - count($aids))); } return $aids; } @@ -281,10 +287,11 @@ class MainSite extends BasePlugin protected function shareTask(): bool { if (!getConf('main_site.share', false, 'bool')) return true; - // video*10 - $infos = $this->fetchRandomAvInfos(); - $info = array_pop($infos); - $aid = (string)$info['aid']; + + $archives = $this->fetchCustomAids(10); + $archive = array_pop($archives); + $aid = (string)$archive['aid']; + // $response = ApiShare::share($aid); switch ($response['code']) { @@ -306,9 +313,11 @@ class MainSite extends BasePlugin protected function watchTask(): bool { if (!getConf('main_site.watch', false, 'bool')) return true; - // video*10 - $infos = $this->fetchRandomAvInfos(); - $info = array_pop($infos); + + $archives = $this->fetchCustomAids(10); + $archive = array_pop($archives); + // 额外处理信息 + $info = $this->getArchiveInfo((string)$archive['aid']); $aid = (string)$info['aid']; $cid = (string)$info['cid']; $duration = (int)$info['duration']; @@ -341,6 +350,19 @@ class MainSite extends BasePlugin return true; } + /** + * 获取稿件详情/暂时不额外处理错误 + * @param string $aid + * @return array + */ + protected function getArchiveInfo(string $aid): array + { + $response = ApiPlayer::pageList($aid); + return $response['data']; + + } + + /** * 获取随机 * @return array diff --git a/profile/example/config/user.ini b/profile/example/config/user.ini index b18ec3c..a6c1ed2 100644 --- a/profile/example/config/user.ini +++ b/profile/example/config/user.ini @@ -36,13 +36,14 @@ phone = true ; 主站每日任务(每日登录、观看、投币、分享) [main_site] enable = true +; 获取AIDS模式/random(随机热门)/fixed(关注列表) +fetch_aids_mode = random ; 每日观看 watch = true ; 每日分享 share = true -; 每日视频投币/random(随机热门)/fixed(关注列表)/投币稿件数(每日任务最大5) +; 每日视频投币/投币稿件数(每日任务最大5) add_coin = true -add_coin_mode = random add_coin_num = 5 ; 漫画助手(每日签到、分享) diff --git a/resources/version.json b/resources/version.json index cc31ef5..14111c2 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.4.221222", + "version": "2.0.6.230127", "des": "程序有更新,请及时线上查看更新哦~", - "time": "2022年12月22日", + "time": "2023年01月27日", "ini_version": "0.0.1", "ini_des": "配置有更新,请及时线上查看更新哦~", - "ini_time": "2022年12月22日" + "ini_time": "2023年01月27日" } diff --git a/src/Api/Api/X/Player/ApiPlayer.php b/src/Api/Api/X/Player/ApiPlayer.php new file mode 100644 index 0000000..d2628cd --- /dev/null +++ b/src/Api/Api/X/Player/ApiPlayer.php @@ -0,0 +1,34 @@ + $aid, + ]; + return Request::getJson(true, 'other', $url, $payload); + } + +}