From 86cd0231efae03153e9ba111fffe6c2deaff7455 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Feb 2022 17:59:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?bugfix:[#16]=E4=BF=AE=E5=A4=8D=E9=93=B6?= =?UTF-8?q?=E7=93=9C=E5=AD=90=E5=85=91=E6=8D=A2=E7=A1=AC=E5=B8=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + CHANGELOG.md | 2 + Ray.BiliBiliTool.sln | 8 ++ common.props | 2 +- .../Dtos/Live/LiveWalletStatusResponse.cs | 36 +++++++++ .../Dtos/Live/Silver2CoinRequest.cs | 44 +++++++++++ .../Dtos/Live/Silver2CoinResponse.cs | 20 +++++ .../BiliBiliAgent/Interfaces/ILiveApi.cs | 25 +++++- .../DailyTaskAppService.cs | 2 +- .../LiveDomainService.cs | 19 +++-- test/BiliAgentTest/BiliAgentTest.csproj | 39 ++++++++++ test/BiliAgentTest/LiveApiTest.cs | 78 +++++++++++++++++++ 12 files changed, 269 insertions(+), 9 deletions(-) create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LiveWalletStatusResponse.cs create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinRequest.cs create mode 100644 src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinResponse.cs create mode 100644 test/BiliAgentTest/BiliAgentTest.csproj create mode 100644 test/BiliAgentTest/LiveApiTest.cs diff --git a/.gitignore b/.gitignore index 4ddc8007f..e0bc0106a 100644 --- a/.gitignore +++ b/.gitignore @@ -356,3 +356,6 @@ MigrationBackup/ # .idea/ tencentScf/.env + +# UnitTest's config file +test/BiliAgentTest/appsettings.Production.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa27f27d..7c2c7b942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,5 @@ - 更新文档 - 天选抽奖新增黑名单功能 - 批量取关新增白名单功能 +## 0.0.3 +- 【#16】修复银瓜子兑换硬币bug diff --git a/Ray.BiliBiliTool.sln b/Ray.BiliBiliTool.sln index b2b7c7755..606ba63be 100644 --- a/Ray.BiliBiliTool.sln +++ b/Ray.BiliBiliTool.sln @@ -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 @@ -136,6 +137,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 @@ -210,6 +213,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 @@ -245,6 +252,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} diff --git a/common.props b/common.props index 68016ca12..3300b0725 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ Ray - 0.0.2 + 0.0.3 $(NoWarn);CS1591;CS0436 diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LiveWalletStatusResponse.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LiveWalletStatusResponse.cs new file mode 100644 index 000000000..da1563d14 --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LiveWalletStatusResponse.cs @@ -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 + { + /// + /// 硬币余额 + /// + public decimal Coin { get; set; } + + /// + /// 金瓜子余额 + /// + public decimal Gold { get; set; } + + /// + /// 银瓜子余额 + /// + public decimal Silver { get; set; } + + /// + /// 银瓜子兑换硬币剩余次数 + /// + public int Silver_2_coin_left { get; set; } + + /// + /// 硬币兑换银瓜子剩余次数 + /// + public int Coin_2_silver_left { get; set; } + } +} diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinRequest.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinRequest.cs new file mode 100644 index 000000000..d1850db12 --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinRequest.cs @@ -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; + + /// + /// + /// + /// 8u0w3cesz1o0 + /// 33moy4vugle0 + /// 9zys612vo0c0 + /// 3uu2mkxt21c0 + /// 8orqn5vf4i00 + 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(); + } +} diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinResponse.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinResponse.cs new file mode 100644 index 000000000..30119a3e0 --- /dev/null +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/Silver2CoinResponse.cs @@ -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; } + } +} diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs index ac155f462..f7036ca1e 100644 --- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs +++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs @@ -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; @@ -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 ExchangeSilver2Coin(); /// @@ -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> GetExchangeSilverStatus(); + /// + /// 银瓜子兑换硬币 + /// + /// + /// + //[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> Silver2Coin([FormContent]Silver2CoinRequest request); + + /// + /// 获取直播中心钱包状态 + /// + /// + //[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> GetLiveWalletStatus(); + [HttpGet("/xlive/web-interface/v1/index/getWebAreaList?source_id=2")] Task> GetAreaList(); diff --git a/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs b/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs index e0af3abdf..f71332138 100644 --- a/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs +++ b/src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs @@ -147,7 +147,7 @@ private void ExchangeSilver2Coin() //如果兑换成功,则打印硬币余额 var coinBalance = _coinDomainService.GetCoinBalance(); - _logger.LogInformation("【硬币余额】 {0}", coinBalance); + _logger.LogInformation("【硬币余额】 {coin}", coinBalance); } /// diff --git a/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs b/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs index 4a3f0cf06..cd790d7e5 100644 --- a/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs +++ b/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs @@ -100,21 +100,28 @@ public bool ExchangeSilver2Coin() return false; } - var response = _liveApi.ExchangeSilver2Coin().GetAwaiter().GetResult(); + BiliApiResponse queryStatus = _liveApi.GetLiveWalletStatus().GetAwaiter().GetResult(); + _logger.LogInformation("【银瓜子余额】 {silver}", queryStatus.Data.Silver); + _logger.LogInformation("【硬币余额】 {coin}", queryStatus.Data.Coin); + _logger.LogInformation("【今日剩余兑换次数】 {left}", queryStatus.Data.Silver_2_coin_left); + + if (queryStatus.Data.Silver_2_coin_left <= 0) return false; + + _logger.LogInformation("开始尝试兑换..."); + Silver2CoinRequest request = new(_biliCookie.BiliJct); + var response = _liveApi.Silver2Coin(request).GetAwaiter().GetResult(); if (response.Code == 0) { result = true; - _logger.LogInformation("【兑换结果】成功"); + _logger.LogInformation("【兑换结果】成功兑换 {coin} 枚硬币", response.Data.Coin); + _logger.LogInformation("【银瓜子余额】 {silver}", response.Data.Silver); } else { _logger.LogInformation("【兑换结果】失败"); - _logger.LogInformation("【原因】{0}", response.Message); + _logger.LogInformation("【原因】{reason}", response.Message); } - var queryStatus = _liveApi.GetExchangeSilverStatus().GetAwaiter().GetResult(); - _logger.LogInformation("【银瓜子余额】 {0}", queryStatus.Data.Silver); - return result; } diff --git a/test/BiliAgentTest/BiliAgentTest.csproj b/test/BiliAgentTest/BiliAgentTest.csproj new file mode 100644 index 000000000..54cad1195 --- /dev/null +++ b/test/BiliAgentTest/BiliAgentTest.csproj @@ -0,0 +1,39 @@ + + + + net6.0 + enable + + false + + + + + + + + + PreserveNewest + true + PreserveNewest + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/test/BiliAgentTest/LiveApiTest.cs b/test/BiliAgentTest/LiveApiTest.cs new file mode 100644 index 000000000..fae4be19f --- /dev/null +++ b/test/BiliAgentTest/LiveApiTest.cs @@ -0,0 +1,78 @@ +using Microsoft.Extensions.DependencyInjection; +using Ray.BiliBiliTool.Agent; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live; +using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces; +using Ray.BiliBiliTool.Console; +using Ray.BiliBiliTool.Infrastructure; +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using Xunit; + +namespace BiliAgentTest +{ + public class LiveApiTest + { + public LiveApiTest() + { + Program.CreateHost(null); + } + + [Fact] + [Obsolete] + public void GetExchangeSilverStatus_Normal_Success() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var api = scope.ServiceProvider.GetRequiredService(); + + BiliApiResponse re = api.GetExchangeSilverStatus().Result; + + Assert.True(re.Code == 0 && re.Message == "0"); + Assert.True(re.Data.Silver >= 0); + } + + [Fact] + public void Silver2Coin_Normal_Success() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var api = scope.ServiceProvider.GetRequiredService(); + var biliCookie = scope.ServiceProvider.GetRequiredService(); + + Silver2CoinRequest request = new(biliCookie.BiliJct); + + BiliApiResponse re = api.Silver2Coin(request).Result; + + Assert.True(re.Code >= 0); + + if (re.Code == 0) + { + Assert.True(re.Data.Coin == 1); + } + else + { + Assert.False(string.IsNullOrWhiteSpace(re.Message)); + } + } + + [Fact] + public void GetLiveWalletStatus_Normal_Success() + { + using var scope = Global.ServiceProviderRoot.CreateScope(); + var api = scope.ServiceProvider.GetRequiredService(); + + BiliApiResponse re = api.GetLiveWalletStatus().Result; + + Assert.True(re.Code >= 0); + + if (re.Code == 0) + { + Assert.True(re.Data.Silver_2_coin_left >= 0); + } + else + { + Assert.False(string.IsNullOrWhiteSpace(re.Message)); + } + } + } +} From 52296115e67897df379c0a33b8128aceaed4eb2b Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Feb 2022 20:17:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:[#18]=E4=BF=AE=E6=94=B9=E9=9D=92?= =?UTF-8?q?=E9=BE=99=E9=9D=A2=E6=9D=BF=E4=BB=A5Production=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + docs/configuration.md | 4 ++-- qinglong/DefaultTasks/bili_task_daily.sh | 2 +- qinglong/DefaultTasks/bili_task_liveLottery.sh | 2 +- qinglong/DefaultTasks/bili_task_test.sh | 2 +- qinglong/DefaultTasks/bili_task_unfollowBatched.sh | 2 +- src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs | 8 +++++--- src/Ray.BiliBiliTool.Console/Program.cs | 4 ++++ src/Ray.BiliBiliTool.Console/appsettings.json | 2 +- 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2c7b942..88980c00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,3 +7,4 @@ - 批量取关新增白名单功能 ## 0.0.3 - 【#16】修复银瓜子兑换硬币bug +- 【#18】修改青龙面板以`Production`环境运行 diff --git a/docs/configuration.md b/docs/configuration.md index 4f3736a20..540d73362 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -219,7 +219,7 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde" | ---------- | -------------- | | 配置Key | `Security__RandomSleepMaxMin` | | 值域 | 数字 | -| 默认值 | 10 | +| 默认值 | 20 | | 环境变量 | `Ray_Security__RandomSleepMaxMin` | | GitHub Secrets | `RANDOMSLEEPMAXMIN`| @@ -235,7 +235,7 @@ export Ray_Serilog__WriteTo__9__Args__token="abcde" | ---------- | -------------- | | 配置Key | `Security__IntervalSecondsBetweenRequestApi` | | 值域 | [0,+] | -| 默认值 | 3 | +| 默认值 | 20 | | 环境变量 | `Ray_Security__IntervalSecondsBetweenRequestApi` | | GitHub Secrets | `INTERVALSECONDSBETWEENREQUESTAPI` | diff --git a/qinglong/DefaultTasks/bili_task_daily.sh b/qinglong/DefaultTasks/bili_task_daily.sh index fb7264b41..8096ef639 100644 --- a/qinglong/DefaultTasks/bili_task_daily.sh +++ b/qinglong/DefaultTasks/bili_task_daily.sh @@ -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 diff --git a/qinglong/DefaultTasks/bili_task_liveLottery.sh b/qinglong/DefaultTasks/bili_task_liveLottery.sh index 519d82c35..5a63dc507 100644 --- a/qinglong/DefaultTasks/bili_task_liveLottery.sh +++ b/qinglong/DefaultTasks/bili_task_liveLottery.sh @@ -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 diff --git a/qinglong/DefaultTasks/bili_task_test.sh b/qinglong/DefaultTasks/bili_task_test.sh index 876e80b96..343a9c695 100644 --- a/qinglong/DefaultTasks/bili_task_test.sh +++ b/qinglong/DefaultTasks/bili_task_test.sh @@ -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 diff --git a/qinglong/DefaultTasks/bili_task_unfollowBatched.sh b/qinglong/DefaultTasks/bili_task_unfollowBatched.sh index 4c31a8151..0a975fcf6 100644 --- a/qinglong/DefaultTasks/bili_task_unfollowBatched.sh +++ b/qinglong/DefaultTasks/bili_task_unfollowBatched.sh @@ -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 diff --git a/src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs b/src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs index 2975035f4..606b63cc4 100644 --- a/src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs +++ b/src/Ray.BiliBiliTool.Console/BiliBiliToolHostedService.cs @@ -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()?.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); } } } diff --git a/src/Ray.BiliBiliTool.Console/Program.cs b/src/Ray.BiliBiliTool.Console/Program.cs index 4478be676..7741a69bf 100644 --- a/src/Ray.BiliBiliTool.Console/Program.cs +++ b/src/Ray.BiliBiliTool.Console/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; @@ -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 }); //应用配置: diff --git a/src/Ray.BiliBiliTool.Console/appsettings.json b/src/Ray.BiliBiliTool.Console/appsettings.json index 51f4bf91a..86aadd778 100644 --- a/src/Ray.BiliBiliTool.Console/appsettings.json +++ b/src/Ray.BiliBiliTool.Console/appsettings.json @@ -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": "" //代理 From 790ad06656d1993e254ba8f206c9cb43270e819f Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Feb 2022 20:52:15 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=E9=9D=92=E9=BE=99=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8B=89=E5=8F=96dev=E5=85=88=E8=A1=8C?= =?UTF-8?q?=E7=89=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +- Ray.BiliBiliTool.sln | 4 +++ qinglong/DefaultTasks/bili_dev_task_daily.sh | 5 ++++ .../DefaultTasks/bili_dev_task_liveLottery.sh | 5 ++++ qinglong/DefaultTasks/bili_dev_task_test.sh | 5 ++++ .../bili_dev_task_unfollowBatched.sh | 5 ++++ qinglong/README.md | 29 +++++++++++++++---- 7 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 qinglong/DefaultTasks/bili_dev_task_daily.sh create mode 100644 qinglong/DefaultTasks/bili_dev_task_liveLottery.sh create mode 100644 qinglong/DefaultTasks/bili_dev_task_test.sh create mode 100644 qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 88980c00c..c06c023c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,5 @@ - 批量取关新增白名单功能 ## 0.0.3 - 【#16】修复银瓜子兑换硬币bug -- 【#18】修改青龙面板以`Production`环境运行 +- 【#18】修改[青龙面板](https://github.com/whyour/qinglong)以`Production`环境运行 +- [青龙面板](https://github.com/whyour/qinglong)新增拉取dev先行版功能 diff --git a/Ray.BiliBiliTool.sln b/Ray.BiliBiliTool.sln index 606ba63be..a35e59842 100644 --- a/Ray.BiliBiliTool.sln +++ b/Ray.BiliBiliTool.sln @@ -124,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 diff --git a/qinglong/DefaultTasks/bili_dev_task_daily.sh b/qinglong/DefaultTasks/bili_dev_task_daily.sh new file mode 100644 index 000000000..ca97d5618 --- /dev/null +++ b/qinglong/DefaultTasks/bili_dev_task_daily.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# new Env("bili每日任务(dev先行版)") +# cron 0 9 * * * bili_task_daily.sh + +dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Daily diff --git a/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh new file mode 100644 index 000000000..7f82c85f3 --- /dev/null +++ b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# new Env("bili天选时刻(dev先行版)") +# cron 0 13 * * * bili_task_liveLottery.sh + +dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=LiveLottery diff --git a/qinglong/DefaultTasks/bili_dev_task_test.sh b/qinglong/DefaultTasks/bili_dev_task_test.sh new file mode 100644 index 000000000..ed9b1904e --- /dev/null +++ b/qinglong/DefaultTasks/bili_dev_task_test.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# new Env("bili测试ck(dev先行版)") +# cron 0 8 * * * bili_task_test.sh + +dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Test diff --git a/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh new file mode 100644 index 000000000..eed25b614 --- /dev/null +++ b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# new Env("bili批量取关主播(dev先行版)") +# cron 0 12 1 * * bili_task_unfollowBatched.sh + +dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=UnfollowBatched diff --git a/qinglong/README.md b/qinglong/README.md index 7e8477d76..4c43dd9ce 100644 --- a/qinglong/README.md +++ b/qinglong/README.md @@ -3,7 +3,19 @@ 开始前,请先确保你的青龙面板是运行正常的。 -## 第一步:在 `extra.sh` 中添加安装 `dotnet` 环境指令 + + +- [1.步骤](#1步骤) + - [1.1.安装 `dotnet` 环境](#11安装-dotnet-环境) + - [1.2.重启青龙容器](#12重启青龙容器) + - [1.3.登录青龙面板并添加相应配置](#13登录青龙面板并添加相应配置) + - [1.4.在青龙面板中添加拉库定时任务](#14在青龙面板中添加拉库定时任务) +- [2.先行版](#2先行版) + + +## 1.步骤 + +### 1.1.安装 `dotnet` 环境 找到 `extra.sh` 文件,安装青龙面板时一般已经通过 `volumes` 映射到宿主机青龙主目录下的 `data/config` 下,在容器内路径为 `/ql/config/extra.sh` 请将以下内容复制到 `extra.sh` 中: @@ -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"` @@ -40,7 +52,7 @@ abc为你抓取到的真实cookie字符串。 点击保存按钮,保存配置。 -## 在青龙面板中添加拉库定时任务 +### 1.4.在青龙面板中添加拉库定时任务 点击进入`定时任务`页面,点击右上角的`添加任务`按钮,填入以下信息: ``` @@ -55,4 +67,11 @@ abc为你抓取到的真实cookie字符串。 点击运行按钮傍的日志按钮,可查看运行日志。 -如果正常,拉库成功后,同时也会自动添加bilibili相关的task任务。 \ No newline at end of file +如果正常,拉库成功后,同时也会自动添加bilibili相关的task任务。 + +## 2.先行版 +修改拉库命令为`ql repo https://github.com/raywangqvq/bilibilitoolpro.git "bili_dev_task_" "" "" "develop"`可改为拉取develop分支的代码。 + +develop分支的代码会超前于默认的main分支,包含当前正在开发的新功能。 + +想提前体验新功能的朋友可以尝试切换先行版,但同时也意味着稳定性会相应降低(其实是相当于在帮我内测测试bug了~🤨)。 From fa5836c62a81cd0fec83096c1194b804b6268f29 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Feb 2022 21:06:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?bugfix:=E4=BF=AE=E5=A4=8D=E9=9D=92=E9=BE=99?= =?UTF-8?q?sh=E8=84=9A=E6=9C=AC=E7=9A=84=E4=BB=BB=E5=8A=A1=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E8=A2=AB=E8=AF=86=E5=88=AB=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qinglong/DefaultTasks/bili_dev_task_daily.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_liveLottery.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_test.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qinglong/DefaultTasks/bili_dev_task_daily.sh b/qinglong/DefaultTasks/bili_dev_task_daily.sh index ca97d5618..af8d8992f 100644 --- a/qinglong/DefaultTasks/bili_dev_task_daily.sh +++ b/qinglong/DefaultTasks/bili_dev_task_daily.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# new Env("bili每日任务(dev先行版)") +# new Env("bili每日任务[dev先行版]") # cron 0 9 * * * bili_task_daily.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Daily diff --git a/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh index 7f82c85f3..db5306e7f 100644 --- a/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh +++ b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# new Env("bili天选时刻(dev先行版)") +# new Env("bili天选时刻[dev先行版]") # cron 0 13 * * * bili_task_liveLottery.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=LiveLottery diff --git a/qinglong/DefaultTasks/bili_dev_task_test.sh b/qinglong/DefaultTasks/bili_dev_task_test.sh index ed9b1904e..e36ef5368 100644 --- a/qinglong/DefaultTasks/bili_dev_task_test.sh +++ b/qinglong/DefaultTasks/bili_dev_task_test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# new Env("bili测试ck(dev先行版)") +# new Env("bili测试ck[dev先行版]") # cron 0 8 * * * bili_task_test.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Test diff --git a/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh index eed25b614..c2b1b6266 100644 --- a/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh +++ b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# new Env("bili批量取关主播(dev先行版)") +# new Env("bili批量取关主播[dev先行版]") # cron 0 12 1 * * bili_task_unfollowBatched.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=UnfollowBatched From 8ab92c28e24a132a63795bb2b2a9e93d36d8cb4e Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 20 Feb 2022 21:28:23 +0800 Subject: [PATCH 5/5] bugfix:Update qinglong dev sh file's cron name --- qinglong/DefaultTasks/bili_dev_task_daily.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_liveLottery.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_test.sh | 2 +- qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qinglong/DefaultTasks/bili_dev_task_daily.sh b/qinglong/DefaultTasks/bili_dev_task_daily.sh index af8d8992f..323166ecf 100644 --- a/qinglong/DefaultTasks/bili_dev_task_daily.sh +++ b/qinglong/DefaultTasks/bili_dev_task_daily.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # new Env("bili每日任务[dev先行版]") -# cron 0 9 * * * bili_task_daily.sh +# cron 0 9 * * * bili_dev_task_daily.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Daily diff --git a/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh index db5306e7f..65ecd3cef 100644 --- a/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh +++ b/qinglong/DefaultTasks/bili_dev_task_liveLottery.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # new Env("bili天选时刻[dev先行版]") -# cron 0 13 * * * bili_task_liveLottery.sh +# cron 0 13 * * * bili_dev_task_liveLottery.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=LiveLottery diff --git a/qinglong/DefaultTasks/bili_dev_task_test.sh b/qinglong/DefaultTasks/bili_dev_task_test.sh index e36ef5368..0f8bad6c7 100644 --- a/qinglong/DefaultTasks/bili_dev_task_test.sh +++ b/qinglong/DefaultTasks/bili_dev_task_test.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # new Env("bili测试ck[dev先行版]") -# cron 0 8 * * * bili_task_test.sh +# cron 0 8 * * * bili_dev_task_test.sh dotnet run --project /ql/repo/raywangqvq_bilibilitoolpro_develop/src/Ray.BiliBiliTool.Console --ENVIRONMENT=Production --runTasks=Test diff --git a/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh index c2b1b6266..b49da16da 100644 --- a/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh +++ b/qinglong/DefaultTasks/bili_dev_task_unfollowBatched.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # new Env("bili批量取关主播[dev先行版]") -# cron 0 12 1 * * bili_task_unfollowBatched.sh +# 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