Skip to content

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Feb 20, 2022
2 parents 7bae43a + 8ab92c2 commit c6cd0a5
Show file tree
Hide file tree
Showing 25 changed files with 335 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,6 @@ MigrationBackup/
#
.idea/
tencentScf/.env

# UnitTest's config file
test/BiliAgentTest/appsettings.Production.json
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
- 更新文档
- 天选抽奖新增黑名单功能
- 批量取关新增白名单功能
## 0.0.3
-#16】修复银瓜子兑换硬币bug
-#18】修改[青龙面板](https://github.com/whyour/qinglong)`Production`环境运行
- [青龙面板](https://github.com/whyour/qinglong)新增拉取dev先行版功能
12 changes: 12 additions & 0 deletions Ray.BiliBiliTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
clean.cmd = clean.cmd
common.props = common.props
DockerBuild.cmd = DockerBuild.cmd
Expand Down Expand Up @@ -123,6 +124,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "qinglong", "qinglong", "{1C
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DefaultTasks", "DefaultTasks", "{DE60A16C-CA3B-45E9-8A9D-0E91ACEBDEE0}"
ProjectSection(SolutionItems) = preProject
qinglong\DefaultTasks\bili_dev_task_daily.sh = qinglong\DefaultTasks\bili_dev_task_daily.sh
qinglong\DefaultTasks\bili_dev_task_liveLottery.sh = qinglong\DefaultTasks\bili_dev_task_liveLottery.sh
qinglong\DefaultTasks\bili_dev_task_test.sh = qinglong\DefaultTasks\bili_dev_task_test.sh
qinglong\DefaultTasks\bili_dev_task_unfollowBatched.sh = qinglong\DefaultTasks\bili_dev_task_unfollowBatched.sh
qinglong\DefaultTasks\bili_task_daily.sh = qinglong\DefaultTasks\bili_task_daily.sh
qinglong\DefaultTasks\bili_task_liveLottery.sh = qinglong\DefaultTasks\bili_task_liveLottery.sh
qinglong\DefaultTasks\bili_task_test.sh = qinglong\DefaultTasks\bili_task_test.sh
Expand All @@ -136,6 +141,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEM
.github\ISSUE_TEMPLATE\other----.md = .github\ISSUE_TEMPLATE\other----.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BiliAgentTest", "test\BiliAgentTest\BiliAgentTest.csproj", "{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -210,6 +217,10 @@ Global
{F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2AFCE4C-42A2-4EB1-873B-7C9EB062C002}.Release|Any CPU.Build.0 = Release|Any CPU
{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -245,6 +256,7 @@ Global
{1C6CC38A-A5D5-41EF-9072-70AEEEA211F7} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1}
{DE60A16C-CA3B-45E9-8A9D-0E91ACEBDEE0} = {1C6CC38A-A5D5-41EF-9072-70AEEEA211F7}
{830361B7-BCC1-4853-879A-761B0FD86826} = {73DD457B-E06E-45ED-A6BA-7E3C02F8BDF1}
{F6B8ED3A-5428-4D26-8172-8B41FBF0C4CF} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {197319DA-1148-4A99-847C-8B270B6A29AB}
Expand Down
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Authors>Ray</Authors>
<Version>0.0.2</Version>
<Version>0.0.3</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde"
| ---------- | -------------- |
| 配置Key | `Security__RandomSleepMaxMin` |
| 值域 | 数字 |
| 默认值 | 10 |
| 默认值 | 20 |
| 环境变量 | `Ray_Security__RandomSleepMaxMin` |
| GitHub Secrets | `RANDOMSLEEPMAXMIN`|

Expand All @@ -235,7 +235,7 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde"
| ---------- | -------------- |
| 配置Key | `Security__IntervalSecondsBetweenRequestApi` |
| 值域 | [0,+] |
| 默认值 | 3 |
| 默认值 | 20 |
| 环境变量 | `Ray_Security__IntervalSecondsBetweenRequestApi` |
| GitHub Secrets | `INTERVALSECONDSBETWEENREQUESTAPI` |

Expand Down
5 changes: 5 additions & 0 deletions qinglong/DefaultTasks/bili_dev_task_daily.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# new Env("bili每日任务[dev先行版]")
# cron 0 9 * * * bili_dev_task_daily.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Daily
5 changes: 5 additions & 0 deletions qinglong/DefaultTasks/bili_dev_task_liveLottery.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# new Env("bili天选时刻[dev先行版]")
# cron 0 13 * * * bili_dev_task_liveLottery.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=LiveLottery
5 changes: 5 additions & 0 deletions qinglong/DefaultTasks/bili_dev_task_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# new Env("bili测试ck[dev先行版]")
# cron 0 8 * * * bili_dev_task_test.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Test
5 changes: 5 additions & 0 deletions qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# new Env("bili批量取关主播[dev先行版]")
# cron 0 12 1 * * bili_dev_task_unfollowBatched.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=UnfollowBatched
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_daily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# new Env("bili每日任务")
# cron 0 9 * * * bili_task_daily.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console Production -runTasks=Daily
dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Daily
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_liveLottery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# new Env("bili天选时刻")
# cron 0 13 * * * bili_task_liveLottery.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console -runTasks=LiveLottery
dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=LiveLottery
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# new Env("bili测试ck")
# cron 0 8 * * * bili_task_test.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console -runTasks=Test
dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Test
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_unfollowBatched.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# new Env("bili批量取关主播")
# cron 0 12 1 * * bili_task_unfollowBatched.sh

dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console -runTasks=UnfollowBatched
dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=UnfollowBatched
29 changes: 24 additions & 5 deletions qinglong/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@

开始前,请先确保你的青龙面板是运行正常的。

## 第一步:在 `extra.sh` 中添加安装 `dotnet` 环境指令
<!-- TOC depthFrom:2 -->

- [1.步骤](#1步骤)
- [1.1.安装 `dotnet` 环境](#11安装-dotnet-环境)
- [1.2.重启青龙容器](#12重启青龙容器)
- [1.3.登录青龙面板并添加相应配置](#13登录青龙面板并添加相应配置)
- [1.4.在青龙面板中添加拉库定时任务](#14在青龙面板中添加拉库定时任务)
- [2.先行版](#2先行版)

<!-- /TOC -->
## 1.步骤

### 1.1.安装 `dotnet` 环境
找到 `extra.sh` 文件,安装青龙面板时一般已经通过 `volumes` 映射到宿主机青龙主目录下的 `data/config` 下,在容器内路径为 `/ql/config/extra.sh`

请将以下内容复制到 `extra.sh` 中:
Expand All @@ -22,10 +34,10 @@ dotnet --version
echo -e "\n-------set up dot net env finish-------"
```

## 重启青龙容器
### 1.2.重启青龙容器
重启青龙容器,或在宿主机中执行 `docker exec -it qinglong bash /ql/config/extra.sh`,其中 `qinglong` 是你的容器名。

## 登录青龙面板并添加相应配置
### 1.3.登录青龙面板并添加相应配置
访问青龙面板并登录(通常面板地址为 `ip:5700` ),然后进入`配置文件`页面。

修改 `RepoFileExtensions="js py"``RepoFileExtensions="js py sh"`
Expand All @@ -40,7 +52,7 @@ abc为你抓取到的真实cookie字符串。

点击保存按钮,保存配置。

## 在青龙面板中添加拉库定时任务
### 1.4.在青龙面板中添加拉库定时任务
点击进入`定时任务`页面,点击右上角的`添加任务`按钮,填入以下信息:

```
Expand All @@ -55,4 +67,11 @@ abc为你抓取到的真实cookie字符串。

点击运行按钮傍的日志按钮,可查看运行日志。

如果正常,拉库成功后,同时也会自动添加bilibili相关的task任务。
如果正常,拉库成功后,同时也会自动添加bilibili相关的task任务。

## 2.先行版
修改拉库命令为`ql repo https://github.com/raywangqvq/bilibilitoolpro.git "bili_dev_task_" "" "" "develop"`可改为拉取develop分支的代码。

develop分支的代码会超前于默认的main分支,包含当前正在开发的新功能。

想提前体验新功能的朋友可以尝试切换先行版,但同时也意味着稳定性会相应降低(其实是相当于在帮我内测测试bug了~🤨)。
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class LiveWalletStatusResponse
{
/// <summary>
/// 硬币余额
/// </summary>
public decimal Coin { get; set; }

/// <summary>
/// 金瓜子余额
/// </summary>
public decimal Gold { get; set; }

/// <summary>
/// 银瓜子余额
/// </summary>
public decimal Silver { get; set; }

/// <summary>
/// 银瓜子兑换硬币剩余次数
/// </summary>
public int Silver_2_coin_left { get; set; }

/// <summary>
/// 硬币兑换银瓜子剩余次数
/// </summary>
public int Coin_2_silver_left { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Ray.BiliBiliTool.Infrastructure.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class Silver2CoinRequest
{
public Silver2CoinRequest(string csrf)
{
Csrf = csrf;
}

public string Csrf { get; set; }

public string Csrf_token => Csrf;

/// <summary>
///
/// </summary>
/// <sample>8u0w3cesz1o0</sample>
/// <sample>33moy4vugle0</sample>
/// <sample>9zys612vo0c0</sample>
/// <sample>3uu2mkxt21c0</sample>
/// <sample>8orqn5vf4i00</sample>
public string Visit_id { get; set; } = _visitId;//todo

public static string GetRandomVisitId()
{
var ran = new Random();
int first = ran.Next(1, 10);
int last = 0;

var s = new RandomHelper().GenerateCode(10).ToLower();

return $"{first}{s}{last}";
}

private static string _visitId = GetRandomVisitId();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Ray.BiliBiliTool.Infrastructure.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class Silver2CoinResponse
{
public long Coin { get; set; }

public long Gold { get; set; }

public long Silver { get; set; }

public string Tid { get; set; }
}
}
25 changes: 24 additions & 1 deletion src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live;
using WebApiClientCore.Attributes;
Expand Down Expand Up @@ -29,6 +30,7 @@ public interface ILiveApi : IBiliBiliApi
[Header("Origin", "https://link.bilibili.com")]
[Header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")]
[HttpGet("/pay/v1/Exchange/silver2coin")]
[Obsolete]
Task<BiliApiResponse> ExchangeSilver2Coin();

/// <summary>
Expand All @@ -38,8 +40,29 @@ public interface ILiveApi : IBiliBiliApi
[Header("Referer", "https://link.bilibili.com/")]
[Header("Origin", "https://link.bilibili.com")]
[HttpGet("/pay/v1/Exchange/getStatus")]
[Obsolete]
Task<BiliApiResponse<ExchangeSilverStatusResponse>> GetExchangeSilverStatus();

/// <summary>
/// 银瓜子兑换硬币
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
//[Header("Referer", "https://link.bilibili.com/p/center/index?visit_id=1ddo4yl01q00")]
[Header("Content-Type", "application/x-www-form-urlencoded")]
[Header("Origin", "https://link.bilibili.com")]
[HttpPost("/xlive/revenue/v1/wallet/silver2coin")]
Task<BiliApiResponse<Silver2CoinResponse>> Silver2Coin([FormContent]Silver2CoinRequest request);

/// <summary>
/// 获取直播中心钱包状态
/// </summary>
/// <returns></returns>
//[Header("Referer", "https://link.bilibili.com/p/center/index?visit_id=1ddo4yl01q00")]
[Header("Origin", "https://link.bilibili.com")]
[HttpGet("/xlive/revenue/v1/wallet/getStatus")]
Task<BiliApiResponse<LiveWalletStatusResponse>> GetLiveWalletStatus();

[HttpGet("/xlive/web-interface/v1/index/getWebAreaList?source_id=2")]
Task<BiliApiResponse<GetArteaListResponse>> GetAreaList();

Expand Down
2 changes: 1 addition & 1 deletion src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void ExchangeSilver2Coin()

//如果兑换成功,则打印硬币余额
var coinBalance = _coinDomainService.GetCoinBalance();
_logger.LogInformation("【硬币余额】 {0}", coinBalance);
_logger.LogInformation("【硬币余额】 {coin}", coinBalance);
}

/// <summary>
Expand Down
8 changes: 5 additions & 3 deletions src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ private void DoTasks(string[] tasks)
private void LogAppInfo()
{
_logger.LogInformation(
"{newLine}--------------- Ray.BiliBiliTool-v{version} in {env} env.",
"{newLine}--------------- RayBiliBiliToolPro-v{version} in {env} env.{newLine}开源 by {url}",
Environment.NewLine,
typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion,
Global.HostingEnvironment.EnvironmentName);
Global.HostingEnvironment.EnvironmentName,
Environment.NewLine,
Constants.SourceCodeUrl
);
//_logger.LogInformation("【当前IP】{ip} ", IpHelper.GetIp());
_logger.LogInformation("开源 by {url}" + Environment.NewLine, Constants.SourceCodeUrl);
}
}
}
4 changes: 4 additions & 0 deletions src/Ray.BiliBiliTool.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -55,6 +56,9 @@ internal static IHostBuilder CreateHostBuilder(string[] args)
Environment.SetEnvironmentVariable(HostDefaults.EnvironmentKey, Environment.GetEnvironmentVariable(Global.EnvironmentKey));
hostConfigurationBuilder.AddEnvironmentVariables();
var hostCmdArgs= args.ToList().Where(x=>x.StartsWith("--")).ToArray();
hostConfigurationBuilder.AddCommandLine(hostCmdArgs);//没指定mapping,则命令行入参必须是--形式,因为-会去寻找mapping
});

//应用配置:
Expand Down
2 changes: 1 addition & 1 deletion src/Ray.BiliBiliTool.Console/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"Security": {
"IsSkipDailyTask": false, //是否跳过执行任务,用于特殊情况下,通过配置灵活的开启和关闭任务
"RandomSleepMaxMin": 20, //随机睡眠的最大时长(单位为分钟),用于使每天运行时间在范围内相对随机,值域[0,+];配置为0表示不进行休眠
"IntervalSecondsBetweenRequestApi": 30, //两次调用api之间的间隔[0,+](单位为秒)。因为有人担心在几秒内连续调用api会被b站安全机制发现,所以为不放心的朋友添加了间隔秒数配置,两次连续调用Api之间会大于该秒数
"IntervalSecondsBetweenRequestApi": 20, //两次调用api之间的间隔[0,+](单位为秒)。因为有人担心在几秒内连续调用api会被b站安全机制发现,所以为不放心的朋友添加了间隔秒数配置,两次连续调用Api之间会大于该秒数
"IntervalMethodTypes": "GET,POST", //间隔秒数所针对的HttpMethod,多个用英文逗号隔开,当前有GET和POST两种,可配置如“GET,POST”
"UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36 Edg/87.0.664.41", //请求B站接口时头部传递的User-Agent
"WebProxy": "" //代理
Expand Down
Loading

0 comments on commit c6cd0a5

Please sign in to comment.