[update] Version v2.0.6.230127

This commit is contained in:
Lkeme 2023-01-27 00:12:30 +08:00
parent 84799aa574
commit b3204358a5
7 changed files with 113 additions and 35 deletions

View File

@ -29,7 +29,7 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Version-2.0.4.221222-orange.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Version-2.0.6.230127-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/PHP-8.1+-green.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/PHP-8.1+-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">

View File

@ -47,6 +47,7 @@ RUN set -x; \
#ENV PATH=/root/.composer/vendor/bin:$PATH #ENV PATH=/root/.composer/vendor/bin:$PATH
RUN apk add --no-cache git && \ RUN apk add --no-cache git && \
# https://github.com/php/php-src/issues/8681
apk add --no-cache linux-headers && \ apk add --no-cache linux-headers && \
git clone ${REPO_URL}/lkeme/BiliHelper-personal.git --depth=1 /app && \ git clone ${REPO_URL}/lkeme/BiliHelper-personal.git --depth=1 /app && \
cp -f /app/docker/entrypoint.sh /usr/local/bin/entrypoint.sh && \ cp -f /app/docker/entrypoint.sh /usr/local/bin/entrypoint.sh && \

View File

@ -8,6 +8,26 @@
[comment]: <> (</details>) [comment]: <> (</details>)
## 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) ## v2.0.4.221222 alpha (2022-12-22)
### Added ### Added

View File

@ -15,6 +15,7 @@
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\ * |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/ */
use Bhp\Api\Api\X\Player\ApiPlayer;
use Bhp\Api\DynamicSvr\ApiDynamicSvr; use Bhp\Api\DynamicSvr\ApiDynamicSvr;
use Bhp\Api\Video\ApiCoin; use Bhp\Api\Video\ApiCoin;
use Bhp\Api\Video\ApiShare; 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 * @return bool
@ -92,13 +110,7 @@ class MainSite extends BasePlugin
return true; return true;
} }
// 稿件列表 // 稿件列表
if (getConf('main_site.add_coin_mode') == 'random') { $aids = $this->fetchCustomAids($actual_num);
// 随机热门稿件榜单
$aids = self::getTopAids($actual_num);
} else {
// 固定获取关注UP稿件榜单, 不足会随机补全
$aids = self::getFollowUpAids($actual_num);
}
// //
Log::info("主站任务: 预投币稿件 " . implode(" ", $aids)); Log::info("主站任务: 预投币稿件 " . implode(" ", $aids));
// 投币 // 投币
@ -137,25 +149,20 @@ class MainSite extends BasePlugin
* @param int $ps * @param int $ps
* @return array * @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); $response = ApiVideo::dynamicRegion($ps);
// //
if ($response['code']) { if ($response['code']) {
Log::warning("主站任务: 获取首页推荐失败 {$response['code']} -> {$response['message']}"); Log::warning("主站任务: 获取首页推荐失败 {$response['code']} -> {$response['message']}");
return self::getDayRankingAids($num); return $this->getDayRankingArchives($num);
} }
// //
if ($num == 1) { if ($num == 1) {
$temps = [array_rand($response['data']['archives'], $num)]; return [array_rand($response['data']['archives'], $num)];
} else { } 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 * @param int $num
* @return array * @return array
*/ */
protected function getDayRankingAids(int $num): array protected function getDayRankingArchives(int $num): array
{ {
$aids = []; $archives = [];
$rand_nums = []; $rand_nums = [];
// //
$response = ApiVideo::ranking(); $response = ApiVideo::ranking();
@ -180,11 +187,10 @@ class MainSite extends BasePlugin
break; break;
} }
} }
$aid = $response['data']['list'][$rand_nums[$i]]['aid']; $archives[] = $response['data']['list'][$rand_nums[$i]];
$aids[] = $aid;
} }
// //
return $aids; return $archives;
} }
/** /**
@ -211,7 +217,7 @@ class MainSite extends BasePlugin
} }
// 此处补全缺失 // 此处补全缺失
if (count($aids) < $num) { if (count($aids) < $num) {
$aids = array_merge($aids, $this->getTopAids($num - count($aids))); $aids = array_merge($aids, $this->getTopArchives($num - count($aids)));
} }
return $aids; return $aids;
} }
@ -281,10 +287,11 @@ class MainSite extends BasePlugin
protected function shareTask(): bool protected function shareTask(): bool
{ {
if (!getConf('main_site.share', false, 'bool')) return true; if (!getConf('main_site.share', false, 'bool')) return true;
// video*10
$infos = $this->fetchRandomAvInfos(); $archives = $this->fetchCustomAids(10);
$info = array_pop($infos); $archive = array_pop($archives);
$aid = (string)$info['aid']; $aid = (string)$archive['aid'];
// //
$response = ApiShare::share($aid); $response = ApiShare::share($aid);
switch ($response['code']) { switch ($response['code']) {
@ -306,9 +313,11 @@ class MainSite extends BasePlugin
protected function watchTask(): bool protected function watchTask(): bool
{ {
if (!getConf('main_site.watch', false, 'bool')) return true; if (!getConf('main_site.watch', false, 'bool')) return true;
// video*10
$infos = $this->fetchRandomAvInfos(); $archives = $this->fetchCustomAids(10);
$info = array_pop($infos); $archive = array_pop($archives);
// 额外处理信息
$info = $this->getArchiveInfo((string)$archive['aid']);
$aid = (string)$info['aid']; $aid = (string)$info['aid'];
$cid = (string)$info['cid']; $cid = (string)$info['cid'];
$duration = (int)$info['duration']; $duration = (int)$info['duration'];
@ -341,6 +350,19 @@ class MainSite extends BasePlugin
return true; return true;
} }
/**
* 获取稿件详情/暂时不额外处理错误
* @param string $aid
* @return array
*/
protected function getArchiveInfo(string $aid): array
{
$response = ApiPlayer::pageList($aid);
return $response['data'];
}
/** /**
* 获取随机 * 获取随机
* @return array * @return array

View File

@ -36,13 +36,14 @@ phone = true
; 主站每日任务(每日登录、观看、投币、分享) ; 主站每日任务(每日登录、观看、投币、分享)
[main_site] [main_site]
enable = true enable = true
; 获取AIDS模式/random(随机热门)/fixed(关注列表)
fetch_aids_mode = random
; 每日观看 ; 每日观看
watch = true watch = true
; 每日分享 ; 每日分享
share = true share = true
; 每日视频投币/random(随机热门)/fixed(关注列表)/投币稿件数(每日任务最大5) ; 每日视频投币/投币稿件数(每日任务最大5)
add_coin = true add_coin = true
add_coin_mode = random
add_coin_num = 5 add_coin_num = 5
; 漫画助手(每日签到、分享) ; 漫画助手(每日签到、分享)

View File

@ -7,10 +7,10 @@
"dev_raw_url": "https://gh.notifyplus.cf/https://github.com/lkeme/BiliHelper-personal/blob/dev/resources/version.json", "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", "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", "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": "程序有更新,请及时线上查看更新哦~", "des": "程序有更新,请及时线上查看更新哦~",
"time": "2022年12月22日", "time": "2023年01月27日",
"ini_version": "0.0.1", "ini_version": "0.0.1",
"ini_des": "配置有更新,请及时线上查看更新哦~", "ini_des": "配置有更新,请及时线上查看更新哦~",
"ini_time": "2022年12月22日" "ini_time": "2023年01月27日"
} }

View File

@ -0,0 +1,34 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\Api\X\Player;
use Bhp\Request\Request;
class ApiPlayer
{
public static function pageList(string $aid): array
{
// day: 日榜1 三榜3 周榜7 月榜30
$url = 'https://api.bilibili.com/x/player/pagelist';
$payload = [
'aid' => $aid,
];
return Request::getJson(true, 'other', $url, $payload);
}
}