From d1516432ad3a12b40df0b84ae1c2a7a97b87684d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A87=E6=A5=BC?= <31154238+RayWangQvQ@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:07:55 +0800 Subject: [PATCH 1/4] Release 2.0.3 (#688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 实现浏览会员购页面与观看正片内容功能 (#641) * 实现浏览会员购页面 * 实现浏览正片内容的功能 * 观看正片任务运行两次以获取全部大积分 * 更新文档 * 修复专栏投币中导致提前结束的逻辑错误 * 修改大积分中相关api调用的错误 * 修复错误 * 修复专栏投币出现权限不足的问题 * 恢复默认配置 * 部分修复大积分功能 (#685) * 根据api进行修改,等待测试 * 待实现:观看剧集内容 * update UserAgent and ranking api --------- Co-authored-by: Polaris_cn --- CHANGELOG.md | 233 ++--- common.props | 2 +- docs/configuration.md | 31 + .../Article/SearchArticlesByUpIdFullFto.cs | 12 +- .../Dtos/UploadVideoHeartbeatRequest.cs | 9 + .../Dtos/Video/GetBangumiBySsidResponse.cs | 45 + .../Dtos/ViewMall/ViewvipMallRequest.cs | 7 + .../BiliBiliAgent/Interfaces/IVideoApi.cs | 12 +- .../Interfaces/IVipBigPointApi.cs | 28 +- .../BiliBiliAgent/Interfaces/IVipMallApi.cs | 13 + .../Extensions/ServiceCollectionExtension.cs | 14 +- .../IVipBigPointAppService.cs | 4 + ....BiliBiliTool.Application.Contracts.csproj | 4 + .../DailyTaskAppService.cs | 3 - .../VipBigPointAppService.cs | 923 ++++++++++-------- .../Extensions/ServiceCollectionExtension.cs | 1 + .../Options/VipBigPointOptions.cs | 28 + src/Ray.BiliBiliTool.Console/appsettings.json | 7 +- .../ArticleDomainService.cs | 44 +- test/AppServiceTest/VipServiceTest.cs | 31 + test/BiliAgentTest/BiliAgentTest.csproj | 2 + test/BiliAgentTest/VideoApiTest.cs | 27 +- test/BiliAgentTest/VipApiTest.cs | 48 + 23 files changed, 972 insertions(+), 556 deletions(-) create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Video/GetBangumiBySsidResponse.cs create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/ViewMall/ViewvipMallRequest.cs create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipMallApi.cs create mode 100644 src/Ray.BiliBiliTool.Config/Options/VipBigPointOptions.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8d0f943..7bc0f5448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,60 +1,66 @@ -## 0.0.1 -- 重启项目 -- 支持[青龙面板](https://github.com/whyour/qinglong)部署 -## 0.0.2 -- 更新文档 -- 天选抽奖新增黑名单功能 -- 批量取关新增白名单功能 -## 0.0.3 -- 【#16】修复银瓜子兑换硬币bug -- 【#18】修改[青龙面板](https://github.com/whyour/qinglong)以`Production`环境运行 -- [青龙面板](https://github.com/whyour/qinglong)新增拉取dev先行版功能 -## 0.0.4 -- 【#15】修复`Actions`部署到腾讯云函数时的偶发异常 -## 0.0.5 -- 优化推送日志,在标题中显示运行的任务名称 -- 新增`CodeQL`workflows,用于检测代码 -- 新增`Publish image`workflows,用于发布镜像 -- 新增`no-toxic-comments.yml`,用于检测评论 -- 更新`auto-close-pr.yml`,用于修正PR的目标到`develop` -## 0.0.6 -- 更新docker镜像的构建 -- 【#12】新增配置`Notification:IsSingleAccountSingleNotify`,支持开启每个账号单独推送消息 -- publish-release.yml新增手动输入tag功能 -## 0.0.7 -- 【#44】兼容青龙最新版本(v2.12.0),修复因青龙调整目录结构导致的bug -- 更新`publish-image.yml`,只有`release`时才打`latest tag`,手动运行时不打`latest tag` -## 0.0.8 -- 【#55】新增日志推送端:`Microsoft Teams` -- 【#27】更新README -## 0.0.9 -- 【#47】青龙安装`dotnet`环境,支持arm架构服务器 -## 0.1.0 -- 【#62】`codeql-analysis.yml`可以指定检查的文件类型 -- 【#61】`publish-image.yml`手动打镜像时支持指定是否打latest的tag -- 【#32】新增企业微信的应用推送,实现微信接受推送消息 -- 优化日志格式 -## 0.1.1 -- 【#54】优化青龙shell脚本读取仓库目录方式,解决青龙新老版本切换导致出现多个repo目录的bug -- 【#82】【#85】合并外部PR,更新了文档 -- 感谢`JetBrain`提供免费的证书支持 -## 0.1.2 -- 修复`auto-close-pr.yml`分支错误的bug -- 【#107】新增自动检测并关闭长时无状态issues的actions:no-response.yml -- 【#73】【#105】【#108】更新、纠正文档内容 -- HostConfiguration,删除了CommandLine配置源,推荐只使用环境变量,同时更新青龙shell脚本内配置 -- 【#169】领取大会员福利任务更改为每日都尝试执行 -- 青龙拉库兼容大小写问题 -- 【#197】合并PR,新增了阅读漫画功能到每日任务中(@ChanceLuo) -## 0.2.0 -- 新增大会员大积分任务 -## 0.2.1 -- 合并PR(#253、#257),更新文档(@layui0320) -- 合并PR(#256),重构docker运行是cron构建方式,并优化读取环境变量的方式(@syrinka) -- Feature(#65):新增TG推送配置并使用代理功能 -- Feature(#240):新增gotify推送 -- Feature(#259):大会员状态改为枚举类型,当非会员时自动跳过大积分任务 -- Feature:更新、优化docker部署文档 +## 2.0.3 +- PR[#641]:实现浏览会员购页面与观看正片内容功能 +- PR[#685]:部分修复大积分功能 +- Fix:更新过于老旧的UserAgent +- Fix:更新排行榜api +## 2.0.2 +- PR[#617]:增加专栏投币功能与领取大会员经验的功能 +## 2.0.1 +- PR[#539]:更新文档 +- PR[#557]:修复直播接口权限不足问题 +## 2.0.0 +- Feature[#513]:将基础组件和抽象迁移到nuget包中 +- Fix[#543]:修复部分Api调用报“访问权限不足” +## 1.0.3 +- Fix #486 : fix release zip error +## 1.0.2 +- Fix #484 : fix read dic config error +- Merge PR #472 : add reverse proxy host for telegram notification +- Merge PR #483 : update login field for entrypoint +## 1.0.1 +- Fix #463 : do not trust user's ck config +- Feature #460 : publish single file when release +- Feature: use new scripts for gh actions's release +- Feature #473 : let user input when there is no target task in configs +## 1.0.0 +- Feature: Enable asynchronous +- Fix #344 : Support `Ctrl + C` to trigger exit event +- Fix #451 : Rebuild cookie factory pattern and fix bug of donating coin +- Featur: Replace AOP from MethodBoundaryAspect.Fody to Rougamo.Fody, to fix async exception +- Merge PR #448 : Fix typo +- Fix #446 : Change id type from int to long +## 0.4.6 +- Fix: ck list init empty error +- Feature #440 : use 'apk add' to install dotnet in qinglong +## 0.4.5 +- Fix #423 : Change int to string to avoid overflow exception +## 0.4.4 +- Fix #228 : Try to fix sharing video error +- Feature: Change default docker image from dockerhub to github +## 0.4.3 +- Feature #419 : Add a auto shell script for installing with docker +- Feature #396 : Publish docker image to GitHub pkg +## 0.4.2 +- Merfe PRs #425 #426 #427 : Enhancement docker things, thx @zclkkk +## 0.4.1 +- Merge PR #418 : Fix search video api's error, thx @catlair +## 0.4.0 +- 合并PR( #381 #383 ),新增直播间挂机功能,感谢@bakapiano +## 0.3.2 +- Fix( #358 ),获取auth时兼容老版青龙文件路径 +- Fix( #364 ),兼容青龙异形response数据类型 +- Fix( #366 #361 ),修复一些低级bug +- Feature( #359 ),兼容读取不到`$QL_DIR`的情况 +## 0.3.1 +- Fix( #260 ),在需要的时候encode cookie +- 更新文档 +## 0.3.0 +- hotfix docker build error +- 合并PR(#341),新增krew部署,感谢@chenliu1993 +- 合并PR(##348),更新文档,感谢@jexjws +- 合并PR(#350),修改请求header错误的bug,感谢@catlair +- 合并PR(#353),新增python扫码登录的feature(仅针对青龙),感谢@AFUL1991 +- Feature(#351):重构并新增了扫码登录功能,使之适用于各种部署平台 ## 0.2.2 - 新增`podman`部署教程 - 合并PR(#264),腾讯云定时任务补充新增的大会员大积分任务,感谢@layui0320 @@ -63,61 +69,60 @@ - 合并PR(#309)新增lv6后开启白嫖模式的配置(多账号时可以实现不足lv6的继续投币,达到lv6的开始白嫖),感谢@cluom - 优化青龙安装dotnet的脚本,改为使用官方`dotnet-install.sh`脚本安装(之前测试网络不通,后发现--no-cdn可以) - 优化青龙的执行脚本,提取公共部分,并且在执行前会尝试安装一次dotnet,会清理一次缓存 -## 0.3.0 -- hotfix docker build error -- 合并PR(#341),新增krew部署,感谢@chenliu1993 -- 合并PR(##348),更新文档,感谢@jexjws -- 合并PR(#350),修改请求header错误的bug,感谢@catlair -- 合并PR(#353),新增python扫码登录的feature(仅针对青龙),感谢@AFUL1991 -- Feature(#351):重构并新增了扫码登录功能,使之适用于各种部署平台 -## 0.3.1 -- Fix( #260 ),在需要的时候encode cookie +## 0.2.1 +- 合并PR(#253、#257),更新文档(@layui0320) +- 合并PR(#256),重构docker运行是cron构建方式,并优化读取环境变量的方式(@syrinka) +- Feature(#65):新增TG推送配置并使用代理功能 +- Feature(#240):新增gotify推送 +- Feature(#259):大会员状态改为枚举类型,当非会员时自动跳过大积分任务 +- Feature:更新、优化docker部署文档 +## 0.2.0 +- 新增大会员大积分任务 +## 0.1.2 +- 修复`auto-close-pr.yml`分支错误的bug +- 【#107】新增自动检测并关闭长时无状态issues的actions:no-response.yml +- 【#73】【#105】【#108】更新、纠正文档内容 +- HostConfiguration,删除了CommandLine配置源,推荐只使用环境变量,同时更新青龙shell脚本内配置 +- 【#169】领取大会员福利任务更改为每日都尝试执行 +- 青龙拉库兼容大小写问题 +- 【#197】合并PR,新增了阅读漫画功能到每日任务中(@ChanceLuo) +## 0.1.1 +- 【#54】优化青龙shell脚本读取仓库目录方式,解决青龙新老版本切换导致出现多个repo目录的bug +- 【#82】【#85】合并外部PR,更新了文档 +- 感谢`JetBrain`提供免费的证书支持 +## 0.1.0 +- 【#62】`codeql-analysis.yml`可以指定检查的文件类型 +- 【#61】`publish-image.yml`手动打镜像时支持指定是否打latest的tag +- 【#32】新增企业微信的应用推送,实现微信接受推送消息 +- 优化日志格式 +## 0.0.9 +- 【#47】青龙安装`dotnet`环境,支持arm架构服务器 +## 0.0.8 +- 【#55】新增日志推送端:`Microsoft Teams` +- 【#27】更新README +## 0.0.7 +- 【#44】兼容青龙最新版本(v2.12.0),修复因青龙调整目录结构导致的bug +- 更新`publish-image.yml`,只有`release`时才打`latest tag`,手动运行时不打`latest tag` +## 0.0.6 +- 更新docker镜像的构建 +- 【#12】新增配置`Notification:IsSingleAccountSingleNotify`,支持开启每个账号单独推送消息 +- publish-release.yml新增手动输入tag功能 +## 0.0.5 +- 优化推送日志,在标题中显示运行的任务名称 +- 新增`CodeQL`workflows,用于检测代码 +- 新增`Publish image`workflows,用于发布镜像 +- 新增`no-toxic-comments.yml`,用于检测评论 +- 更新`auto-close-pr.yml`,用于修正PR的目标到`develop` +## 0.0.4 +- 【#15】修复`Actions`部署到腾讯云函数时的偶发异常 +## 0.0.3 +- 【#16】修复银瓜子兑换硬币bug +- 【#18】修改[青龙面板](https://github.com/whyour/qinglong)以`Production`环境运行 +- [青龙面板](https://github.com/whyour/qinglong)新增拉取dev先行版功能 +## 0.0.2 - 更新文档 -## 0.3.2 -- Fix( #358 ),获取auth时兼容老版青龙文件路径 -- Fix( #364 ),兼容青龙异形response数据类型 -- Fix( #366 #361 ),修复一些低级bug -- Feature( #359 ),兼容读取不到`$QL_DIR`的情况 -## 0.4.0 -- 合并PR( #381 #383 ),新增直播间挂机功能,感谢@bakapiano -## 0.4.1 -- Merge PR #418 : Fix search video api's error, thx @catlair -## 0.4.2 -- Merfe PRs #425 #426 #427 : Enhancement docker things, thx @zclkkk -## 0.4.3 -- Feature #419 : Add a auto shell script for installing with docker -- Feature #396 : Publish docker image to GitHub pkg -## 0.4.4 -- Fix #228 : Try to fix sharing video error -- Feature: Change default docker image from dockerhub to github -## 0.4.5 -- Fix #423 : Change int to string to avoid overflow exception -## 0.4.6 -- Fix: ck list init empty error -- Feature #440 : use 'apk add' to install dotnet in qinglong -## 1.0.0 -- Feature: Enable asynchronous -- Fix #344 : Support `Ctrl + C` to trigger exit event -- Fix #451 : Rebuild cookie factory pattern and fix bug of donating coin -- Featur: Replace AOP from MethodBoundaryAspect.Fody to Rougamo.Fody, to fix async exception -- Merge PR #448 : Fix typo -- Fix #446 : Change id type from int to long -## 1.0.1 -- Fix #463 : do not trust user's ck config -- Feature #460 : publish single file when release -- Feature: use new scripts for gh actions's release -- Feature #473 : let user input when there is no target task in configs -## 1.0.2 -- Fix #484 : fix read dic config error -- Merge PR #472 : add reverse proxy host for telegram notification -- Merge PR #483 : update login field for entrypoint -## 1.0.3 -- Fix #486 : fix release zip error -## 2.0.0 -- Feature[#513]:将基础组件和抽象迁移到nuget包中 -- Fix[#543]:修复部分Api调用报“访问权限不足” -## 2.0.1 -- PR[#539]:更新文档 -- PR[#557]:修复直播接口权限不足问题 -## 2.0.2 -- PR[#617]:增加专栏投币功能与领取大会员经验的功能 +- 天选抽奖新增黑名单功能 +- 批量取关新增白名单功能 +## 0.0.1 +- 重启项目 +- 支持[青龙面板](https://github.com/whyour/qinglong)部署 diff --git a/common.props b/common.props index 74347ebbe..4add63019 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ Ray - 2.0.2 + 2.0.3 $(NoWarn);CS1591;CS0436 diff --git a/docs/configuration.md b/docs/configuration.md index 31b9f0116..1c72fe6fe 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -31,6 +31,7 @@ - [3.3.8. 每月几号自动领取会员权益](#338-每月几号自动领取会员权益) - [3.3.9. 每月几号进行直播中心银瓜子兑换硬币](#339-每月几号进行直播中心银瓜子兑换硬币) - [3.3.10. Lv6后开启硬币白嫖模式](#3310-lv6后开启硬币白嫖模式) + - [3.3.11. 是否开启专栏投币](#3311-是否开启专栏投币) - [3.4. 天选时刻抽奖相关](#34-天选时刻抽奖相关) - [3.4.1. 根据关键字排除奖品](#341-根据关键字排除奖品) - [3.4.2. 根据关键字指定奖品](#342-根据关键字指定奖品) @@ -75,6 +76,8 @@ - [3.7.3. 定时任务相关](#373-定时任务相关) - [3.7.4. 定时任务](#374-定时任务) - [3.7.5. Crontab](#375-crontab) + - [3.8. 大积分相关](#38-大积分相关) + - [3.8.1. 自定义观看番剧](#381-自定义观看番剧) @@ -314,6 +317,8 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde" #### 3.3.1. 是否开启观看视频任务 +当该配置被设置为`false`时会导致大积分任务中的签到领额外10点经验的任务不能自动完成。 + | TITLE | CONTENT | | ---------- | -------------- | | 配置Key | `DailyTaskConfig:IsWatchVideo` | @@ -437,6 +442,18 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde" | 环境变量 | `Ray_DailyTaskConfig__SaveCoinsWhenLv6` | | GitHub Secrets | | + +#### 3.3.11. 是否开启专栏投币 + +| TITLE | CONTENT | +| ---------- | -------------- | +| 配置Key | `DailyTaskConfig:IsDonateCoinForArticle` | +| 值域 | [true,false]| +| 默认值 | false | +| 环境变量 | `Ray_DailyTaskConfig__IsDonateCoinForArticle` | +| GitHub Secrets | | + + ### 3.4. 天选时刻抽奖相关 @@ -896,3 +913,17 @@ environment: 0 15 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=Daily >> /var/log/cron.log 0 22 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=LiveLottery >> /var/log/cron.log ``` + + +### 3.8. 大积分相关 + + +#### 3.8.1. 自定义观看番剧 + +| TITLE | CONTENT | +| ---------- | -------------- | +| 配置Key | `VipBigPointConfig:ViewBangumis` | +| 值域 | 番剧的ssid(season_id) | +| 默认值 | `33378`(名侦探柯南) | +| 环境变量 | `Ray_VipBigPointConfig__ViewBangumis` | +| GitHub Secrets | | diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Article/SearchArticlesByUpIdFullFto.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Article/SearchArticlesByUpIdFullFto.cs index e4cae3b9b..8d646ffbd 100644 --- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Article/SearchArticlesByUpIdFullFto.cs +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Article/SearchArticlesByUpIdFullFto.cs @@ -2,13 +2,17 @@ public class SearchArticlesByUpIdDto { - public long Mid { get; set; } + public long mid { get; set; } - public int Pn { get; set; } = 1; + public int pn { get; set; } = 1; - public int Ps { get; set; } = 30; + public int ps { get; set; } = 12; - public string Sort { get; set; } = "publish_time"; + public string sort { get; set; } = "publish_time"; + + public long web_location { get; set; } = 1550101; + + public string platform { get; set; } = "web"; } public class SearchArticlesByUpIdFullDto : SearchArticlesByUpIdDto diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/UploadVideoHeartbeatRequest.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/UploadVideoHeartbeatRequest.cs index a8b50b652..0612801c1 100644 --- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/UploadVideoHeartbeatRequest.cs +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/UploadVideoHeartbeatRequest.cs @@ -17,6 +17,10 @@ public class UploadVideoHeartbeatRequest public string Bvid { get; set; } + public long? Epid { get; set; } + + public long? Sid { get; set; } + /// /// 当前用户UID /// @@ -49,6 +53,11 @@ public class UploadVideoHeartbeatRequest /// public int Type { get; set; } = 3; + /// + /// 剧集副类型 + /// + public int? Sub_type { get; set; } + /// /// 2 /// diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Video/GetBangumiBySsidResponse.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Video/GetBangumiBySsidResponse.cs new file mode 100644 index 000000000..b59c58c7a --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Video/GetBangumiBySsidResponse.cs @@ -0,0 +1,45 @@ +using static System.Collections.Specialized.BitVector32; +using System.Collections.Generic; +using System.Diagnostics; +using System.Xml.Linq; + +namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Video; + +public class GetBangumiBySsidResponse +{ + public int Code { get; set; } = int.MinValue; + + public string Message { get; set; } + + public Result Result { get; set; } +} + +public class Result +{ + public List episodes { get; set; } +} + + +public class Episode +{ + public int aid { get; set; } + + public string bvid { get; set; } + + public int cid { get; set; } + + public int duration { get; set; } + + public int ep_id { get; set; } + + public int id { get; set; } + + public string long_title { get; set; } + + public string share_copy { get; set; } + + public int status { get; set; } + + + +} diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/ViewMall/ViewvipMallRequest.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/ViewMall/ViewvipMallRequest.cs new file mode 100644 index 000000000..186351056 --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/ViewMall/ViewvipMallRequest.cs @@ -0,0 +1,7 @@ +namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.ViewMall; + +public class ViewVipMallRequest +{ + public string Csrf { get; set; } + public string EventId { get; set; } = "hevent_oy4b7h3epeb"; +} diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVideoApi.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVideoApi.cs index 3c19f92f3..5c9ab9053 100644 --- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVideoApi.cs +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVideoApi.cs @@ -73,7 +73,16 @@ public interface IVideoApi : IBiliBiliApi //[HttpGet("/x/space/wbi/arc/search?mid={upId}&ps={pageSize}&tid=0&pn={pageNumber}&keyword={keyword}&order=pubdate&platform=web&web_location=1550101&order_avoided=true&w_rid=5df06b1c48e2be86a96e9d0f99bf06f4&wts=1684854929")] [HttpGet("/x/space/wbi/arc/search")] Task> SearchVideosByUpId([PathQuery] SearchVideosByUpIdFullDto request); - + + /// + /// 通过ssid获取番剧的具体信息 + /// + /// + /// + [HttpGet("/pgc/view/web/season?season_id={ssid}")] + Task GetBangumiBySsid(long ssid); + + } /// @@ -107,6 +116,7 @@ public interface IVideoWithoutCookieApi : IVideoApi /// [Header("Referer", "https://www.bilibili.com/")] [Header("Origin", "https://www.bilibili.com")] + [Header("dnt", "1")] [HttpGet("/x/web-interface/ranking/v2?rid=0&type=all")] Task> GetRegionRankingVideosV2(); diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipBigPointApi.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipBigPointApi.cs index f83122d74..3e762e179 100644 --- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipBigPointApi.cs +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipBigPointApi.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Threading.Tasks; using Ray.BiliBiliTool.Agent.Attributes; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask; @@ -12,30 +10,48 @@ namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces /// 大会员大积分 /// [Header("Host", "api.bilibili.com")] - [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] - [Header("User-Agent", "Mozilla/5.0 (Linux; Android 6.0.1; MuMu Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.158 Mobile Safari/537.36 os/android model/MuMu build/6720300 osVer/6.0.1 sdkInt/23 network/2 BiliApp/6720300 mobi_app/android channel/html5_search_baidu Buvid/XZFC135F5263B6897C8A4BE7AEB125BBF10F8 sessionID/72d3f4c9 innerVer/6720310 c_locale/zh_CN s_locale/zh_CN disable_rcmd/0 6.72.0 os/android model/MuMu mobi_app/android build/6720300 channel/html5_search_baidu innerVer/6720310 osVer/6.0.1 network/2")] + [Header("User-Agent", + "Mozilla/5.0 (Linux; Android 9; SM-N9700 Build/PQ3A.190605.04081832; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Safari/537.36 Mobile os/android model/SM-N9700 build/7300400 osVer/9 sdkInt/28 network/2 BiliApp/7300400 mobi_app/android channel/alifenfa Buvid/XY77D6C72ECDC63147110C5C8D1DA34D38CD1 sessionID/9795ed5c innerVer/7300400 c_locale/zh_CN s_locale/zh_CN disable_rcmd/0 7.30.0 os/android model/SM-N9700 mobi_app/android build/7300400 channel/alifenfa innerVer/7300400 osVer/9 network/2")] [LogFilter] public interface IVipBigPointApi { + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] [HttpGet("/x/vip_point/task/combine")] Task> GetTaskList(); + + [Header("Referer", "https://www.bilibili.com")] [HttpPost("/pgc/activity/score/task/sign")] Task Sign([FormContent] SignRequest request); + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] [HttpPost("/pgc/activity/score/task/receive")] Task Receive([JsonContent] ReceiveOrCompleteTaskRequest request); + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] + [HttpPost("/pgc/activity/score/task/receive/v2")] + Task ReceiveV2([FormContent] ReceiveOrCompleteTaskRequest request); + + + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] [HttpPost("/pgc/activity/score/task/complete")] Task Complete([JsonContent] ReceiveOrCompleteTaskRequest request); + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] + [HttpPost("/pgc/activity/score/task/complete/v2")] + Task CompleteV2([FormContent] ReceiveOrCompleteTaskRequest request); + + + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] [HttpPost("/pgc/activity/deliver/task/complete")] Task ViewComplete([FormContent] ViewRequest request); + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] [HttpGet("/x/vip/privilege/my")] Task> GetVouchersInfo(); - [Header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")] + [Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")] + // [Header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")] [HttpPost("/x/vip/experience/add")] Task GetVipExperience([FormContent] VipExperienceRequest request); } diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipMallApi.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipMallApi.cs new file mode 100644 index 000000000..f5f2d5933 --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IVipMallApi.cs @@ -0,0 +1,13 @@ +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos; +using System.Threading.Tasks; +using WebApiClientCore.Attributes; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.ViewMall; + +namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces; + +[Header("Host", "show.bilibili.com")] +public interface IVipMallApi +{ + [HttpPost("/api/activity/fire/common/event/dispatch")] + Task ViewVipMall([JsonContent] ViewVipMallRequest request); +} diff --git a/src/Ray.BiliBiliTool.Agent/Extensions/ServiceCollectionExtension.cs b/src/Ray.BiliBiliTool.Agent/Extensions/ServiceCollectionExtension.cs index 92b8831c4..8f5a2c12d 100644 --- a/src/Ray.BiliBiliTool.Agent/Extensions/ServiceCollectionExtension.cs +++ b/src/Ray.BiliBiliTool.Agent/Extensions/ServiceCollectionExtension.cs @@ -75,6 +75,7 @@ public static IServiceCollection AddBiliBiliClientApi(this IServiceCollection se // 添加注入 services.AddBiliBiliClientApi("https://api.bilibili.com"); + services.AddBiliBiliClientApi("https://show.bilibili.com"); //qinglong var qinglongHost = configuration["QL_URL"] ?? "http://localhost:5600"; @@ -145,10 +146,15 @@ private static IServiceCollection SetGlobalProxy(this IServiceCollection service if (proxyAddress.Contains("@")) { string userPass = proxyAddress.Split("@")[0]; - string address = proxyAddress.Split("@")[1]; - - string proxyUser = userPass.Split(":")[0]; - string proxyPass = userPass.Split(":")[1]; + string address = proxyAddress.Split("@")[1]; + + string proxyUser = ""; + string proxyPass = ""; + if (userPass.Contains(":")) + { + proxyUser = userPass?.Split(":")[0]; + proxyPass = userPass?.Split(":")[1]; + } webProxy.Address = new Uri("http://" + address); webProxy.Credentials = new NetworkCredential(proxyUser, proxyPass); diff --git a/src/Ray.BiliBiliTool.Application.Contracts/IVipBigPointAppService.cs b/src/Ray.BiliBiliTool.Application.Contracts/IVipBigPointAppService.cs index f78097ef3..db57c0539 100644 --- a/src/Ray.BiliBiliTool.Application.Contracts/IVipBigPointAppService.cs +++ b/src/Ray.BiliBiliTool.Application.Contracts/IVipBigPointAppService.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Text; using System.Threading.Tasks; +using Ray.BiliBiliTool.DomainService.Dtos; namespace Ray.BiliBiliTool.Application.Contracts { @@ -14,5 +15,8 @@ namespace Ray.BiliBiliTool.Application.Contracts public interface IVipBigPointAppService : IAppService { Task VipExpress(); + Task WatchBangumi(); } + + } diff --git a/src/Ray.BiliBiliTool.Application.Contracts/Ray.BiliBiliTool.Application.Contracts.csproj b/src/Ray.BiliBiliTool.Application.Contracts/Ray.BiliBiliTool.Application.Contracts.csproj index 3f9985f28..90b5e4c9b 100644 --- a/src/Ray.BiliBiliTool.Application.Contracts/Ray.BiliBiliTool.Application.Contracts.csproj +++ b/src/Ray.BiliBiliTool.Application.Contracts/Ray.BiliBiliTool.Application.Contracts.csproj @@ -8,4 +8,8 @@ + + + + diff --git a/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs b/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs index db2ee02f9..f7e6ccc84 100644 --- a/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs +++ b/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs @@ -95,9 +95,6 @@ public override async Task DoTaskAsync(CancellationToken cancellationToken) await ReceiveVipPrivilege(userInfo); await ReceiveMangaVipReward(userInfo); - //TODO 大会员领经验 - - await Charge(userInfo); } diff --git a/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs b/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs index 7d3d038ee..6d4f63c81 100644 --- a/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs +++ b/src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs @@ -4,540 +4,665 @@ using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Ray.BiliBiliTool.Agent; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Video; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.ViewMall; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces; using Ray.BiliBiliTool.Application.Attributes; using Ray.BiliBiliTool.Application.Contracts; +using Ray.BiliBiliTool.Config.Options; +using Ray.BiliBiliTool.DomainService.Dtos; using Ray.BiliBiliTool.DomainService.Interfaces; -namespace Ray.BiliBiliTool.Application +namespace Ray.BiliBiliTool.Application; + +public class VipBigPointAppService : AppService, IVipBigPointAppService { - public class VipBigPointAppService : AppService, IVipBigPointAppService + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + private readonly IVipBigPointApi _vipApi; + private readonly IAccountDomainService _loginDomainService; + private readonly IVideoDomainService _videoDomainService; + private readonly IAccountDomainService _accountDomainService; + private readonly BiliCookie _biliCookie; + private readonly IVipMallApi _vipMallApi; + private readonly IVideoApi _videoApi; + private readonly VipBigPointOptions _vipBigPointOptions; + + public VipBigPointAppService( + IConfiguration configuration, + ILogger logger, + IVipBigPointApi vipApi, + IAccountDomainService loginDomainService, + IVideoDomainService videoDomainService, + BiliCookie biliCookie, + IAccountDomainService accountDomainService, + IVipMallApi vipMallApi, + IVideoApi videoApi, + IOptionsMonitor vipBigPointOptions) { - private readonly ILogger _logger; - private readonly IConfiguration _configuration; - private readonly IVipBigPointApi _vipApi; - private readonly IAccountDomainService _loginDomainService; - private readonly IVideoDomainService _videoDomainService; - private readonly IAccountDomainService _accountDomainService; - private readonly BiliCookie _biliCookie; - - public VipBigPointAppService( - IConfiguration configuration, - ILogger logger, - IVipBigPointApi vipApi, - IAccountDomainService loginDomainService, - IVideoDomainService videoDomainService, - BiliCookie biliCookie, IAccountDomainService accountDomainService) - { - _configuration = configuration; - _logger = logger; - _vipApi = vipApi; - _loginDomainService = loginDomainService; - _videoDomainService = videoDomainService; - _biliCookie = biliCookie; - _accountDomainService = accountDomainService; - } - - public async Task VipExpress() - { - _logger.LogInformation("大会员经验领取任务开始"); - var re = await _vipApi.GetVouchersInfo(); - if (re.Code == 0) - { - var state = re.Data.List.Find(x => x.Type == 9).State; - - switch (state) - { - case 2: - _logger.LogInformation("大会员经验观看任务未完成"); - _logger.LogInformation("开始观看视频"); - // 观看视频,暂时没有好办法解决,先这样使着 - DailyTaskInfo dailyTaskInfo = await _accountDomainService.GetDailyTaskStatus(); - await _videoDomainService.WatchAndShareVideo(dailyTaskInfo); - // 跳转到未兑换,执行兑换任务 - goto case 0; - - case 1: - _logger.LogInformation("大会员经验已兑换"); - break; + _configuration = configuration; + _logger = logger; + _vipApi = vipApi; + _loginDomainService = loginDomainService; + _videoDomainService = videoDomainService; + _biliCookie = biliCookie; + _accountDomainService = accountDomainService; + _vipMallApi = vipMallApi; + _videoApi = videoApi; + _vipBigPointOptions = vipBigPointOptions.CurrentValue; + } - case 0: - _logger.LogInformation("大会员经验未兑换"); - //兑换api - var response = await _vipApi.GetVipExperience(new VipExperienceRequest() - { - csrf = _biliCookie.BiliJct - }); - if (response.Code != 0) - { - _logger.LogInformation("大会员经验领取失败,错误信息:{message}", response.Message); - break; - } - _logger.LogInformation("领取成功,经验+10 √"); + /// + /// 领取大会员专属经验包 + /// + public async Task VipExpress() + { + _logger.LogInformation("大会员经验领取任务开始"); + var re = await _vipApi.GetVouchersInfo(); + if (re.Code == 0) + { + var state = re.Data.List.Find(x => x.Type == 9).State; + + switch (state) + { + case 2: + _logger.LogInformation("大会员经验观看任务未完成"); + _logger.LogInformation("开始观看视频"); + // 观看视频,暂时没有好办法解决,先这样使着 + DailyTaskInfo dailyTaskInfo = await _accountDomainService.GetDailyTaskStatus(); + await _videoDomainService.WatchAndShareVideo(dailyTaskInfo); + // 跳转到未兑换,执行兑换任务 + goto case 0; + + case 1: + _logger.LogInformation("大会员经验已兑换"); + break; + + case 0: + _logger.LogInformation("大会员经验未兑换"); + //兑换api + var response = await _vipApi.GetVipExperience(new VipExperienceRequest() + { + csrf = _biliCookie.BiliJct + }); + if (response.Code != 0) + { + _logger.LogInformation("大会员经验领取失败,错误信息:{message}", response.Message); break; + } - default: - _logger.LogDebug("大会员经验领取失败,未知错误"); - break; - } + _logger.LogInformation("领取成功,经验+10 √"); + break; + default: + _logger.LogDebug("大会员经验领取失败,未知错误"); + break; } - } + } + + [TaskInterceptor("大会员大积分", TaskLevel.One)] + public override async Task DoTaskAsync(CancellationToken cancellationToken) + { + // TODO 解决taskInfo在一个任务出错后,后续的任务均会报空引用错误 + var ui = await GetUserInfo(); - [TaskInterceptor("大会员大积分", TaskLevel.One)] - public override async Task DoTaskAsync(CancellationToken cancellationToken) + if (ui.GetVipType() == VipType.None) { - await VipExpress(); + _logger.LogInformation("当前不是大会员或已过期,跳过任务"); + return; + } - // TODO 解决taskInfo在一个任务出错后,后续的任务均会报空引用错误 - var ui = await GetUserInfo(); + var re = await _vipApi.GetTaskList(); - if (ui.GetVipType() == VipType.None) - { - _logger.LogInformation("当前不是大会员或已过期,跳过任务"); - return; - } + if (re.Code != 0) throw new Exception(re.ToJsonStr()); - var re = await _vipApi.GetTaskList(); + VipTaskInfo taskInfo = re.Data; + taskInfo.LogInfo(_logger); - if (re.Code != 0) throw new Exception(re.ToJsonStr()); + await VipExpress(); - VipTaskInfo taskInfo = re.Data; - taskInfo.LogInfo(_logger); + //签到 + taskInfo = await Sign(taskInfo); - //签到 - taskInfo = await Sign(taskInfo); + //福利任务 + taskInfo = await Bonus(taskInfo); - //福利任务 - taskInfo = await Bonus(taskInfo); + //体验任务 + taskInfo = await Privilege(taskInfo); - //体验任务 - taskInfo = await Privilege(taskInfo); + //日常任务 - //日常任务 + //浏览追番频道页10秒 + taskInfo = await ViewAnimate(taskInfo); - //浏览追番频道页10秒 - taskInfo = await ViewAnimate(taskInfo); + //浏览会员购页面10秒 + taskInfo = await ViewVipMall(taskInfo); - //浏览影视频道页10秒 - // taskInfo = await ViewFilmChannel(taskInfo); + //浏览装扮商城 + taskInfo = await ViewDressMall(taskInfo); - //浏览会员购页面10秒 - taskInfo = ViewVipMall(taskInfo); + //观看剧集内容 + taskInfo = await ViewVideo(taskInfo); - //观看任意正片内容 - taskInfo = await ViewVideo(taskInfo); + //领取购买任务 + taskInfo = await BuyVipVideo(taskInfo); + taskInfo = await BuyVipMall(taskInfo); - //领取购买任务 - taskInfo = await BuyVipVideo(taskInfo); - // taskInfo = await BuyVipProduct(taskInfo); - taskInfo = await BuyVipMall(taskInfo); - - taskInfo.LogInfo(_logger); + taskInfo.LogInfo(_logger); + } - - } + [TaskInterceptor("测试Cookie")] + private async Task GetUserInfo() + { + UserInfo userInfo = await _loginDomainService.LoginByCookie(); + if (userInfo == null) throw new Exception("登录失败,请检查Cookie"); //终止流程 + + return userInfo; + } - [TaskInterceptor("测试Cookie")] - private async Task GetUserInfo() + [TaskInterceptor("签到", TaskLevel.Two, false)] + private async Task Sign(VipTaskInfo info) + { + if (info.Task_info.Sing_task_item.IsTodaySigned) { - UserInfo userInfo = await _loginDomainService.LoginByCookie(); - if (userInfo == null) throw new Exception("登录失败,请检查Cookie");//终止流程 + _logger.LogInformation("已完成,跳过"); + _logger.LogInformation("今日获得签到积分:{score}", info.Task_info.Sing_task_item.TodayHistory?.Score); + _logger.LogInformation("累计签到{count}天", info.Task_info.Sing_task_item.Count); + return info; + } + + var re = await _vipApi.Sign(new SignRequest()); + if (re.Code != 0) throw new Exception(re.ToJsonStr()); + + //确认 + var infoResult = await _vipApi.GetTaskList(); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); + info = infoResult.Data; + + _logger.LogInformation("今日可获得签到积分:{score}", info.Task_info.Sing_task_item.TodayHistory?.Score); + _logger.LogInformation(info.Task_info.Sing_task_item.IsTodaySigned ? "签到成功" : "签到失败"); + _logger.LogInformation("累计签到{count}天", info.Task_info.Sing_task_item.Count); - return userInfo; + return info; + } + + [TaskInterceptor("福利任务", TaskLevel.Two, false)] + private async Task Bonus(VipTaskInfo info) + { + var bonusTask = GetTarget(info); + + //如果状态不等于3,则做 + if (bonusTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); + return info; } - [TaskInterceptor("签到", TaskLevel.Two, false)] - private async Task Sign(VipTaskInfo info) + //0需要领取 + if (bonusTask.state == 0) { - if (info.Task_info.Sing_task_item.IsTodaySigned) - { - _logger.LogInformation("已完成,跳过"); - _logger.LogInformation("今日获得签到积分:{score}", info.Task_info.Sing_task_item.TodayHistory?.Score); - _logger.LogInformation("累计签到{count}天", info.Task_info.Sing_task_item.Count); - return info; - } + _logger.LogInformation("开始领取任务"); + await TryReceive(bonusTask.task_code); + } - var re = await _vipApi.Sign(new SignRequest()); - if (re.Code != 0) throw new Exception(re.ToJsonStr()); + _logger.LogInformation("开始完成任务"); + var re = await Complete(bonusTask.task_code); - //确认 + //确认 + if (re) + { var infoResult = await _vipApi.GetTaskList(); if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); info = infoResult.Data; + bonusTask = GetTarget(info); - _logger.LogInformation("今日可获得签到积分:{score}", info.Task_info.Sing_task_item.TodayHistory?.Score); - _logger.LogInformation(info.Task_info.Sing_task_item.IsTodaySigned ? "签到成功" : "签到失败"); - _logger.LogInformation("累计签到{count}天", info.Task_info.Sing_task_item.Count); + _logger.LogInformation("确认:{re}", bonusTask.state == 3 && bonusTask.complete_times >= 1); + } + + return info; + + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "福利任务") + .common_task_item + .First(x => x.task_code == "bonus"); + } + } + [TaskInterceptor("体验任务", TaskLevel.Two, false)] + private async Task Privilege(VipTaskInfo info) + { + var privilegeTask = GetTarget(info); + + //如果状态不等于3,则做 + if (privilegeTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); return info; } - [TaskInterceptor("福利任务", TaskLevel.Two, false)] - private async Task Bonus(VipTaskInfo info) + //0需要领取 + if (privilegeTask.state == 0) { - var bonusTask = GetTarget(info); + _logger.LogInformation("开始领取任务"); + await TryReceive(privilegeTask.task_code); + } - //如果状态不等于3,则做 - if (bonusTask.state == 3) - { - _logger.LogInformation("已完成,跳过"); - return info; - } + _logger.LogInformation("开始完成任务"); + var re = await Complete(privilegeTask.task_code); - //0需要领取 - if (bonusTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(bonusTask.task_code); - } + //确认 + if (re) + { + var infoResult = await _vipApi.GetTaskList(); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); + info = infoResult.Data; + privilegeTask = GetTarget(info); - _logger.LogInformation("开始完成任务"); - var re = await Complete(bonusTask.task_code); + _logger.LogInformation("确认:{re}", privilegeTask.state == 3 && privilegeTask.complete_times >= 1); + } - //确认 - if (re) - { - var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); - info = infoResult.Data; - bonusTask = GetTarget(info); + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "体验任务") + .common_task_item + .First(x => x.task_code == "privilege"); + } - _logger.LogInformation("确认:{re}", bonusTask.state == 3 && bonusTask.complete_times >= 1); - } + return info; + } - return info; + [TaskInterceptor("浏览追番频道页10秒", TaskLevel.Two, false)] + private async Task ViewAnimate(VipTaskInfo info) + { + var code = "jp_channel"; - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "福利任务") - .common_task_item - .First(x => x.task_code == "bonus"); - } + CommonTaskItem targetTask = GetTarget(info); + + //如果状态不等于3,则做 + if (targetTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); + return info; } - [TaskInterceptor("体验任务", TaskLevel.Two, false)] - private async Task Privilege(VipTaskInfo info) + //0需要领取 + if (targetTask.state == 0) { - var privilegeTask = GetTarget(info); + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - //如果状态不等于3,则做 - if (privilegeTask.state == 3) - { - _logger.LogInformation("已完成,跳过"); - return info; - } + _logger.LogInformation("开始完成任务"); + var re = await CompleteView(code); - //0需要领取 - if (privilegeTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(privilegeTask.task_code); - } + //确认 + if (re) + { + var infoResult = await _vipApi.GetTaskList(); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); + info = infoResult.Data; + targetTask = GetTarget(info); - _logger.LogInformation("开始完成任务"); - var re = await Complete(privilegeTask.task_code); + _logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1); + } - //确认 - if (re) - { - var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); - info = infoResult.Data; - privilegeTask = GetTarget(info); + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "animatetab"); + } - _logger.LogInformation("确认:{re}", privilegeTask.state == 3 && privilegeTask.complete_times >= 1); - } + return info; + } - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "体验任务") - .common_task_item - .First(x => x.task_code == "privilege"); - } + [TaskInterceptor("浏览会员购页面10秒", TaskLevel.Two, false)] + private async Task ViewVipMall(VipTaskInfo info) + { + CommonTaskItem targetTask = GetTarget(info); + //如果状态不等于3,则做 + if (targetTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); return info; } - [TaskInterceptor("浏览追番频道页10秒", TaskLevel.Two, false)] - private async Task ViewAnimate(VipTaskInfo info) + //0需要领取 + if (targetTask.state == 0) { - var code = "jp_channel"; - - CommonTaskItem targetTask = GetTarget(info); + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - //如果状态不等于3,则做 - if (targetTask.state == 3) - { - _logger.LogInformation("已完成,跳过"); - return info; - } + _logger.LogInformation("开始完成任务"); + var re = await _vipMallApi.ViewVipMall(new ViewVipMallRequest() + { + Csrf = _biliCookie.BiliJct + }); + if (re.Code != 0) throw new Exception(re.ToJsonStr()); - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } + //确认 + if (re.Code == 0) + { + var infoResult = await _vipApi.GetTaskList(); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); + info = infoResult.Data; + targetTask = GetTarget(info); - _logger.LogInformation("开始完成任务"); - var re = await CompleteView(code); + _logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1); + } - //确认 - if (re) - { - var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); - info = infoResult.Data; - targetTask = GetTarget(info); + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "vipmallview"); + } - _logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1); - } + return info; + } - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "animatetab"); - } + [TaskInterceptor("观看剧集内容", TaskLevel.Two, false)] + private async Task ViewVideo(VipTaskInfo info) + { + CommonTaskItem targetTask = GetTarget(info); + // 如果状态不等于3,则做 + if (targetTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); return info; } - [TaskInterceptor("浏览影视频道页10秒", TaskLevel.Two, false)] - private async Task ViewFilmChannel(VipTaskInfo info) + //0需要领取 + if (targetTask.state == 0) { - var code = "tv_channel"; + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - CommonTaskItem targetTask = GetTarget(info); + _logger.LogInformation("开始完成任务"); - //如果状态不等于3,则做 - if (targetTask.state == 3) - { - _logger.LogInformation("已完成,跳过"); - return info; - } + // 观看剧集内容 + _logger.LogInformation("api变更,暂未实现"); - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "ogvwatchnew"); + } - _logger.LogInformation("开始完成任务"); - var re = await CompleteView(code); + return info; + } - //确认 - if (re) - { - var infoResult = await _vipApi.GetTaskList(); - if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); - info = infoResult.Data; - targetTask = GetTarget(info); + [TaskInterceptor("购买单点付费影片(仅领取)", TaskLevel.Two, false)] + private async Task BuyVipVideo(VipTaskInfo info) + { + CommonTaskItem targetTask = GetTarget(info); - _logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1); - } + if (targetTask.state is 3 or 1) + { + var re = targetTask.state == 1 ? "已领取" : "已完成"; + _logger.LogInformation("{re},跳过", re); + return info; + } - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "filmtab"); - } + //0需要领取 + if (targetTask.state == 0) + { + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - return info; + return info; + + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "tvodbuy"); } + } + + [TaskInterceptor("购买指定会员购商品(仅领取)", TaskLevel.Two, false)] + private async Task BuyVipMall(VipTaskInfo info) + { + CommonTaskItem targetTask = GetTarget(info); - [TaskInterceptor("浏览会员购页面10秒", TaskLevel.Two, false)] - private VipTaskInfo ViewVipMall(VipTaskInfo info) + if (targetTask.state is 3 or 1) { - //todo - _logger.LogInformation("待实现..."); + var re = targetTask.state == 1 ? "已领取" : "已完成"; + _logger.LogInformation("{re},跳过", re); return info; } - [TaskInterceptor("观看任意正片内容", TaskLevel.Two, false)] - private async Task ViewVideo(VipTaskInfo info) + //0需要领取 + if (targetTask.state == 0) { - CommonTaskItem targetTask = GetTarget(info); + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - //如果状态不等于3,则做 - if (targetTask.state == 3) - { - _logger.LogInformation("已完成,跳过"); - return info; - } + return info; - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } + CommonTaskItem GetTarget(VipTaskInfo info) + { + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "vipmallbuy"); + } + } - _logger.LogInformation("开始完成任务"); - _logger.LogInformation("待开发...");//todo + [TaskInterceptor("浏览装扮商城主页", TaskLevel.Two, false)] + private async Task ViewDressMall(VipTaskInfo info) + { + //var code = "dress-view"; - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "ogvwatch"); - } + CommonTaskItem targetTask = GetTarget(info); + + //如果状态不等于3,则做 + if (targetTask.state == 3) + { + _logger.LogInformation("已完成,跳过"); return info; } - [TaskInterceptor("购买单点付费影片(仅领取)", TaskLevel.Two, false)] - private async Task BuyVipVideo(VipTaskInfo info) + //0需要领取 + if (targetTask.state == 0) { - CommonTaskItem targetTask = GetTarget(info); - - if (targetTask.state is 3 or 1) - { - var re = targetTask.state == 1 ? "已领取" : "已完成"; - _logger.LogInformation("{re},跳过", re); - return info; - } + _logger.LogInformation("开始领取任务"); + await TryReceive(targetTask.task_code); + } - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } + _logger.LogInformation("开始完成任务"); + var re = await CompleteV2(targetTask.task_code); - return info; + //确认 + if (re) + { + var infoResult = await _vipApi.GetTaskList(); + if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr()); + info = infoResult.Data; + targetTask = GetTarget(info); - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "tvodbuy"); - } + _logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1); } - [TaskInterceptor("购买指定大会员产品(仅领取)", TaskLevel.Two, false)] - private async Task BuyVipProduct(VipTaskInfo info) + CommonTaskItem GetTarget(VipTaskInfo info) { - CommonTaskItem targetTask = GetTarget(info); - - if (targetTask.state is 3 or 1) - { - var re = targetTask.state == 1 ? "已领取" : "已完成"; - _logger.LogInformation("{re},跳过", re); - return info; - } + return info.Task_info.Modules.First(x => x.module_title == "日常任务") + .common_task_item + .First(x => x.task_code == "dress-view"); + } - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } + return info; + } - return info; - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "subscribe"); - } + /// + /// 领取任务 + /// + private async Task TryReceive(string taskCode) + { + BiliApiResponse re = null; + try + { + var request = new ReceiveOrCompleteTaskRequest(taskCode); + re = await _vipApi.Receive(request); + if (re.Code == 0) + _logger.LogInformation("领取任务成功"); + else + _logger.LogInformation("领取任务失败:{msg}", re.ToJsonStr()); + } + catch (Exception e) + { + _logger.LogError("领取任务异常"); + _logger.LogError(e.Message + re?.ToJsonStr()); } + } - [TaskInterceptor("购买指定会员购商品(仅领取)", TaskLevel.Two, false)] - private async Task BuyVipMall(VipTaskInfo info) + private async Task Complete(string taskCode) + { + var request = new ReceiveOrCompleteTaskRequest(taskCode); + var re = await _vipApi.Complete(request); + if (re.Code == 0) { - CommonTaskItem targetTask = GetTarget(info); + _logger.LogInformation("已完成"); + return true; + } - if (targetTask.state is 3 or 1) - { - var re = targetTask.state == 1 ? "已领取" : "已完成"; - _logger.LogInformation("{re},跳过", re); - return info; - } + else + { + _logger.LogInformation("失败:{msg}", re.ToJsonStr()); + return false; + } + } - //0需要领取 - if (targetTask.state == 0) - { - _logger.LogInformation("开始领取任务"); - await TryReceive(targetTask.task_code); - } - return info; + private async Task CompleteV2(string taskCode) + { + var request = new ReceiveOrCompleteTaskRequest(taskCode); + var re = await _vipApi.CompleteV2(request); + if (re.Code == 0) + { + _logger.LogInformation("已完成"); + return true; + } - CommonTaskItem GetTarget(VipTaskInfo info) - { - return info.Task_info.Modules.First(x => x.module_title == "日常任务") - .common_task_item - .First(x => x.task_code == "vipmallbuy"); - } + else + { + _logger.LogInformation("失败:{msg}", re.ToJsonStr()); + return false; } + } + + private async Task CompleteView(string code) + { + _logger.LogInformation("开始浏览"); + await Task.Delay(10 * 1000); - /// - /// 领取任务 - /// - private async Task TryReceive(string taskCode) + var request = new ViewRequest(code); + var re = await _vipApi.ViewComplete(request); + if (re.Code == 0) { - BiliApiResponse re = null; - try - { - var request = new ReceiveOrCompleteTaskRequest(taskCode); - re = await _vipApi.Receive(request); - if (re.Code == 0) - _logger.LogInformation("领取任务成功"); - else - _logger.LogInformation("领取任务失败:{msg}", re.ToJsonStr()); - } - catch (Exception e) - { - _logger.LogError("领取任务异常"); - _logger.LogError(e.Message + re?.ToJsonStr()); - } + _logger.LogInformation("浏览完成"); + return true; } - private async Task Complete(string taskCode) + else { - var request = new ReceiveOrCompleteTaskRequest(taskCode); - var re = await _vipApi.Complete(request); - if (re.Code == 0) - { - _logger.LogInformation("已完成"); - return true; - } + _logger.LogInformation("浏览失败:{msg}", re.ToJsonStr()); + return false; + } + } - else - { - _logger.LogInformation("失败:{msg}", re.ToJsonStr()); - return false; - } + public async Task WatchBangumi() + { + if (_vipBigPointOptions.ViewBangumiList == null || _vipBigPointOptions.ViewBangumiList.Count == 0) + return false; + + long randomSsid = + _vipBigPointOptions.ViewBangumiList[new Random().Next(0, _vipBigPointOptions.ViewBangumiList.Count)]; + + var res = await GetBangumi(randomSsid); + if (res is null) + { + return false; } - private async Task CompleteView(string code) + var videoInfo = res.Value.Item1; + + // 随机播放时间 + int playedTime = new Random().Next(905, 1800); + // 观看该视频 + var request = new UploadVideoHeartbeatRequest() { - _logger.LogInformation("开始浏览"); - await Task.Delay(10 * 1000); + Aid = long.Parse(videoInfo.Aid), + Bvid = videoInfo.Bvid, + Cid = videoInfo.Cid, + Mid = long.Parse(_biliCookie.UserId), + Sid = randomSsid, + Epid = res.Value.Item2, + Csrf = _biliCookie.BiliJct, + Type = 4, + Sub_type = 1, + Start_ts = DateTime.Now.ToTimeStamp() - playedTime, + Played_time = playedTime, + Realtime = playedTime, + Real_played_time = playedTime + }; + BiliApiResponse apiResponse = await _videoApi.UploadVideoHeartbeat(request); + if (apiResponse.Code == 0) + { + return true; + } - var request = new ViewRequest(code); - var re = await _vipApi.ViewComplete(request); - if (re.Code == 0) - { - _logger.LogInformation("浏览完成"); - return true; - } + return false; + } - else - { - _logger.LogInformation("浏览失败:{msg}", re.ToJsonStr()); - return false; - } + /// + /// 从自定义的番剧ssid中选择其中的一部中的一集 + /// + /// 番剧ssid + /// + private async Task<(VideoInfoDto, long)?> GetBangumi(long randomSsid) + { + try + { + if (randomSsid is 0 or long.MinValue) + return null; + var bangumiInfo = await _videoApi.GetBangumiBySsid(randomSsid); + + // 从获取的剧集中随机获得其中的一集 + + var bangumi = bangumiInfo.Result.episodes[new Random().Next(0, bangumiInfo.Result.episodes.Count)]; + var videoInfo = new VideoInfoDto() + { + Bvid = bangumi.bvid, + Aid = bangumi.aid.ToString(), + Cid = bangumi.cid, + Copyright = 1, + Duration = bangumi.duration, + Title = bangumi.share_copy + }; + _logger.LogInformation("本次播放的正片为:{title}", bangumi.share_copy); + return (videoInfo, bangumi.ep_id); } + catch (Exception e) + { + _logger.LogError(e.Message); + } + + return null; } } diff --git a/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs b/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs index 5ba063782..ddd953779 100644 --- a/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs +++ b/src/Ray.BiliBiliTool.Config/Extensions/ServiceCollectionExtension.cs @@ -23,6 +23,7 @@ public static IServiceCollection AddBiliBiliConfigs(this IServiceCollection serv .Configure(configuration.GetSection("DailyTaskConfig")) .Configure(configuration.GetSection("LiveLotteryTaskConfig")) .Configure(configuration.GetSection("UnfollowBatchedTaskConfig")) + .Configure(configuration.GetSection("VipBigPointConfig")) .Configure(configuration.GetSection("Security")) .Configure(configuration.GetSection("ReceiveVipPrivilegeConfig")) .Configure(configuration.GetSection("LiveFansMedalTaskOptions")) diff --git a/src/Ray.BiliBiliTool.Config/Options/VipBigPointOptions.cs b/src/Ray.BiliBiliTool.Config/Options/VipBigPointOptions.cs new file mode 100644 index 000000000..ff142ab9a --- /dev/null +++ b/src/Ray.BiliBiliTool.Config/Options/VipBigPointOptions.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; + +namespace Ray.BiliBiliTool.Config.Options; + +public class VipBigPointOptions +{ + public string ViewBangumis { get; set; } + + public List ViewBangumiList + { + get + { + List re = new(); + if (string.IsNullOrWhiteSpace(ViewBangumis) | ViewBangumis == "-1") + return re; + + string[] array = ViewBangumis.Split(','); + foreach (string item in array) + { + if (long.TryParse(item.Trim(), out long upId)) + re.Add(upId); + else + re.Add(long.MinValue); + } + return re; + } + } +} diff --git a/src/Ray.BiliBiliTool.Console/appsettings.json b/src/Ray.BiliBiliTool.Console/appsettings.json index d92fc1e05..a32a6fb5f 100644 --- a/src/Ray.BiliBiliTool.Console/appsettings.json +++ b/src/Ray.BiliBiliTool.Console/appsettings.json @@ -38,7 +38,8 @@ }, "VipBigPointConfig": { - "Cron": "7 1 * * *" + "Cron": "7 1 * * *", + "ViewBangumis": "33378" // 自定义番剧的ssid,若不清楚含义请勿修改(默认为名侦探柯南) }, "LiveFansMedalTaskConfig": { @@ -55,8 +56,8 @@ "RandomSleepMaxMin": 0, //随机睡眠的最大时长(单位为分钟),用于使每天运行时间在范围内相对随机,值域[0,+];配置为0表示不进行休眠 "IntervalSecondsBetweenRequestApi": 20, //两次调用api之间的间隔[0,+](单位为秒)。因为有人担心在几秒内连续调用api会被b站安全机制发现,所以为不放心的朋友添加了间隔秒数配置,两次连续调用Api之间会大于该秒数 "IntervalMethodTypes": "GET,POST", //间隔秒数所针对的HttpMethod,多个用英文逗号隔开,当前有GET和POST两种,可配置如“GET,POST” - "UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41", //请求B站接口时头部传递的User-Agent - "WebProxy": "" //代理,user:password@host:port + "UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0", //请求B站接口时头部传递的User-Agent + "WebProxy": "" //代理,格式为http://host:port,如果有鉴权则为user:password@http://host:port }, // 推送 diff --git a/src/Ray.BiliBiliTool.DomainService/ArticleDomainService.cs b/src/Ray.BiliBiliTool.DomainService/ArticleDomainService.cs index bda778dba..2ff253492 100644 --- a/src/Ray.BiliBiliTool.DomainService/ArticleDomainService.cs +++ b/src/Ray.BiliBiliTool.DomainService/ArticleDomainService.cs @@ -54,7 +54,6 @@ public ArticleDomainService( } - public async Task LikeArticle(long cvid) { await _articleApi.Like(cvid, _biliCookie.BiliJct); @@ -66,7 +65,6 @@ public async Task LikeArticle(long cvid) /// public async Task AddCoinForArticles() { - var donateCoinsCounts = await CalculateDonateCoinsCounts(); if (donateCoinsCounts == 0) @@ -84,11 +82,17 @@ public async Task AddCoinForArticles() _logger.LogDebug("开始尝试第{num}次", i); var upId = GetUpFromConfigUps(); + if (upId == 0) + { + _logger.LogDebug("未能成功选择支持的Up主"); + continue; + } + // 当upId不符合时,会直接报错,需要将两者的判断分隔开 var cvid = await GetRandomArticleFromUp(upId); - if (upId == 0 || cvid == 0) + if (cvid == 0) { - _logger.LogInformation("未添加支持的Up主,任务跳过"); - return false; + _logger.LogDebug("第{num}次尝试,未能成功选择合适的专栏",i); + continue; } if (await AddCoinForArticle(cvid, upId)) @@ -97,12 +101,11 @@ public async Task AddCoinForArticles() if (_dailyTaskOptions.SelectLike) { await LikeArticle(cvid); - _logger.LogInformation("文章点赞成功"); + _logger.LogInformation("专栏点赞成功"); } + success++; } - - } if (success == donateCoinsCounts) @@ -112,14 +115,14 @@ public async Task AddCoinForArticles() _logger.LogInformation("投币尝试超过10次,已终止"); return false; } - + _logger.LogInformation("【硬币余额】{coin}", (await _accountApi.GetCoinBalance()).Data.Money ?? 0); return true; } - + /// /// 给某一篇专栏投币 /// @@ -176,17 +179,17 @@ private async Task GetRandomArticleFromUp(long mid) var req = new SearchArticlesByUpIdDto() { - Mid = mid, - Ps = 1, - Pn = new Random().Next(1, articleCount + 1) + mid = mid, + ps = 1, + pn = new Random().Next(1, articleCount + 1) }; var w_ridDto = await _wbiDomainService.GetWridAsync(req); var fullDto = new SearchArticlesByUpIdFullDto() { - Mid = mid, - Ps = req.Ps, - Pn = req.Pn, + mid = mid, + ps = req.ps, + pn = req.pn, w_rid = w_ridDto.w_rid, wts = w_ridDto.wts }; @@ -200,7 +203,7 @@ private async Task GetRandomArticleFromUp(long mid) ArticleInfo articleInfo = re.Data.Articles.FirstOrDefault(); - _logger.LogDebug("获取到的专栏{cvid}({title})", articleInfo.Id, articleInfo.Title); + _logger.LogInformation("获取到的专栏{cvid}({title})", articleInfo.Id, articleInfo.Title); // 检查是否可投 if (!await IsCanDonate(articleInfo.Id)) @@ -236,7 +239,8 @@ private long GetUpFromConfigUps() _logger.LogDebug("不能为自己投币"); return 0; } - _logger.LogDebug("挑选出的up主为{UpId}",randomUpId); + + _logger.LogDebug("挑选出的up主为{UpId}", randomUpId); return randomUpId; } catch (Exception e) @@ -257,14 +261,14 @@ private async Task GetArticleCountOfUp(long mid) { var req = new SearchArticlesByUpIdDto() { - Mid = mid + mid = mid }; var w_ridDto = await _wbiDomainService.GetWridAsync(req); var fullDto = new SearchArticlesByUpIdFullDto() { - Mid = mid, + mid = mid, w_rid = w_ridDto.w_rid, wts = w_ridDto.wts }; diff --git a/test/AppServiceTest/VipServiceTest.cs b/test/AppServiceTest/VipServiceTest.cs index f50bafe0d..ca5da50ce 100644 --- a/test/AppServiceTest/VipServiceTest.cs +++ b/test/AppServiceTest/VipServiceTest.cs @@ -1,5 +1,8 @@ using Microsoft.Extensions.DependencyInjection; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces; using Ray.BiliBiliTool.Application.Contracts; +using Ray.BiliBiliTool.DomainService.Dtos; using Ray.BiliBiliTool.Infrastructure; namespace AppServiceTest; @@ -18,4 +21,32 @@ public async Task VipExpressTest() var appService = scope.ServiceProvider.GetRequiredService(); await appService.VipExpress(); } + + [Fact] + public async Task WatchVideo() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var appService = scope.ServiceProvider.GetRequiredService(); + var res = await appService.WatchBangumi(); + Assert.True(res); + } + + + [Fact] + public async Task CompleteV2Test() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var api = scope.ServiceProvider.GetRequiredService(); + var res = await api.CompleteV2(new ReceiveOrCompleteTaskRequest("dress-view")); + Assert.True(res.Code == 0); + } + + [Fact] + public async Task ReceiveV2Test() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var api = scope.ServiceProvider.GetRequiredService(); + var res = await api.ReceiveV2(new ReceiveOrCompleteTaskRequest("ogvwatchnew")); + Assert.True(res.Code == 0); + } } diff --git a/test/BiliAgentTest/BiliAgentTest.csproj b/test/BiliAgentTest/BiliAgentTest.csproj index 5f8cefe40..bc95c8a9c 100644 --- a/test/BiliAgentTest/BiliAgentTest.csproj +++ b/test/BiliAgentTest/BiliAgentTest.csproj @@ -5,6 +5,8 @@ enable false + + a6e5b261-0fe9-49e1-82e1-02349db119b4 diff --git a/test/BiliAgentTest/VideoApiTest.cs b/test/BiliAgentTest/VideoApiTest.cs index 7ee21588c..512d35133 100644 --- a/test/BiliAgentTest/VideoApiTest.cs +++ b/test/BiliAgentTest/VideoApiTest.cs @@ -17,7 +17,7 @@ public class VideoApiTest { public VideoApiTest() { - Program.CreateHost(new[] { "--ENVIRONMENT=Development" });//ĬPrdָΪDev󣬿Զȡû + Program.CreateHost(new[] { "--ENVIRONMENT=Development" });//Ĭ��Prd����������ָ��ΪDev�󣬿��Զ�ȡ���û��������� } [Fact] @@ -40,5 +40,30 @@ public void GetLiveWalletStatus_Normal_Success() Assert.False(re.Code != 0); } } + + [Fact] + public async Task GetBangumiTest() + { + + using var scope = Global.ServiceProviderRoot.CreateScope(); + + var ck = scope.ServiceProvider.GetRequiredService(); + var api = scope.ServiceProvider.GetRequiredService(); + var req = await api.GetBangumiBySsid(46508); + + Assert.Equal(0,req.Code); + } + + [Fact] + public async Task GetRandomVideoOfRanking() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + + var ck = scope.ServiceProvider.GetRequiredService(); + var api = scope.ServiceProvider.GetRequiredService(); + var req = await api.GetRegionRankingVideosV2(); + + Assert.Equal(0, req.Code); + } } } diff --git a/test/BiliAgentTest/VipApiTest.cs b/test/BiliAgentTest/VipApiTest.cs index 3e540a0a2..793fa0531 100644 --- a/test/BiliAgentTest/VipApiTest.cs +++ b/test/BiliAgentTest/VipApiTest.cs @@ -7,6 +7,9 @@ using Ray.BiliBiliTool.Infrastructure; using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces; using Xunit.Abstractions; +using System; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.ViewMall; + namespace BiliAgentTest; public class VipApiTest @@ -18,6 +21,22 @@ public VipApiTest(ITestOutputHelper output) Program.CreateHost(new[] { "--ENVIRONMENT=Development" }); } + [Fact] + public async Task SignTaskTest() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + + var ck = scope.ServiceProvider.GetRequiredService(); + var api = scope.ServiceProvider.GetRequiredService(); + + var re = await api.Sign(new SignRequest() + { + // Csrf = ck.BiliJct + }); + _output.WriteLine(re.ToJsonStr()); + Assert.Equal(0, re.Code); + } + [Fact] public async Task VipInfoTest() { @@ -56,4 +75,33 @@ public async Task GetVipExperienceTest() _output.WriteLine(re.Message); } + + [Fact] + public async Task ViewVipMallTest() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + + var ck = scope.ServiceProvider.GetRequiredService(); + var api = scope.ServiceProvider.GetRequiredService(); + // var test = await api.ViewvipMall("{\r\n\"csrf\":\"33e5d4564b6b69cb4ed829bc404158cb\",\r\n\"eventId\":\"hevent_oy4b7h3epeb\"\r\n}"); + var re = await api.ViewVipMall(new ViewVipMallRequest() + { + Csrf = ck.BiliJct, + EventId = "hevent_oy4b7h3epeb" + }); + _output.WriteLine(re.Message); + + } + + [Fact] + public async Task DressViewTest() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + + var ck = scope.ServiceProvider.GetRequiredService(); + var api = scope.ServiceProvider.GetRequiredService(); + var re = await api.Complete(new ReceiveOrCompleteTaskRequest( + "dress-view")); + _output.WriteLine(re.Message); + } } From b82a8126572bc134926efaab12c812c18f414cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A87=E6=A5=BC?= <31154238+RayWangQvQ@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:12:35 +0800 Subject: [PATCH 2/4] Update tag.yml --- .github/workflows/tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 84cbf8ffc..3b3bc1103 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -22,7 +22,7 @@ jobs: - name: Get current version id: current_version run: | - version=$(grep -oP '(?<=).*?(?=<\/Version>)' ./scripts/common.props) + version=$(grep -oP '(?<=).*?(?=<\/Version>)' ./common.props) echo "Curent version: $version" echo "current_version=$version" >> $GITHUB_OUTPUT From fe1bc8c5cde62d1c5db9a3535c754f310f89486f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A87=E6=A5=BC?= <31154238+RayWangQvQ@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:15:08 +0800 Subject: [PATCH 3/4] Update tag.yml --- .github/workflows/tag.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 3b3bc1103..6b88a0620 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -28,5 +28,5 @@ jobs: - name: Tag and push run: | - git tag "$new_tag" - git push origin "$new_tag" + git tag "$GITHUB_OUTPUT" + git push origin "$GITHUB_OUTPUT" From 01da40d60af0c2c01fede742f6011b8c48155263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A87=E6=A5=BC?= <31154238+RayWangQvQ@users.noreply.github.com> Date: Mon, 22 Apr 2024 01:19:30 +0800 Subject: [PATCH 4/4] Update tag.yml --- .github/workflows/tag.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 6b88a0620..81d28dfb3 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -28,5 +28,6 @@ jobs: - name: Tag and push run: | - git tag "$GITHUB_OUTPUT" - git push origin "$GITHUB_OUTPUT" + new_tag="${{ steps.current_version.outputs.current_version }}" + git tag "$new_tag" + git push origin "$new_tag"