Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Feb 24, 2023
2 parents e50bdb2 + 7dec5f4 commit c5837ab
Show file tree
Hide file tree
Showing 78 changed files with 1,477 additions and 976 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,11 @@
- 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
- 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
14 changes: 14 additions & 0 deletions Ray.BiliBiliTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.Microsoft
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.GotifyBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.GotifyBatched\Ray.Serilog.Sinks.GotifyBatched.csproj", "{B00FF75D-4C48-45ED-9A24-5C0D383317EE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppServiceTest", "test\AppServiceTest\AppServiceTest.csproj", "{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainServiceTest", "test\DomainServiceTest\DomainServiceTest.csproj", "{26B21C30-7358-4E7B-A73E-2272F10A6CA8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -243,6 +247,14 @@ Global
{B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B00FF75D-4C48-45ED-9A24-5C0D383317EE}.Release|Any CPU.Build.0 = Release|Any CPU
{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81}.Release|Any CPU.Build.0 = Release|Any CPU
{26B21C30-7358-4E7B-A73E-2272F10A6CA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26B21C30-7358-4E7B-A73E-2272F10A6CA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26B21C30-7358-4E7B-A73E-2272F10A6CA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26B21C30-7358-4E7B-A73E-2272F10A6CA8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -283,6 +295,8 @@ Global
{099C4E10-1114-495C-A664-63A15E77B31A} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B}
{FB9A43DE-00F0-42C4-BF92-AF61D752CCA2} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B}
{B00FF75D-4C48-45ED-9A24-5C0D383317EE} = {4BAFC980-7A73-45C3-9460-8B8CCB87939B}
{1D9DFF34-71EA-44AE-85B0-1F10C9BA0D81} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{26B21C30-7358-4E7B-A73E-2272F10A6CA8} = {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.4.6</Version>
<Version>1.0.0</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion docker/scripts/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ else
if ! [ -z "$Ray_VipBigPointConfig__Cron" ]; then
echo "$Ray_VipBigPointConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=VipBigPoint" >>$CRON_FILE
fi
if ! [ -z "$Ray_LiveFansMedalTaskConfig__Cron " ]; then
if ! [ -z "$Ray_LiveFansMedalTaskConfig__Cron" ]; then
echo "$Ray_LiveFansMedalTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveFansMedal" >>$CRON_FILE
fi
fi
Expand Down
1 change: 1 addition & 0 deletions qinglong/DefaultTasks/bili_task_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ echo -e "bili仓库目录: $bili_repo_dir\n"

cd $bili_repo_dir
export Ray_PlateformType=QingLong
export DOTNET_ENVIRONMENT=Production
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_daily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=Daily && \
dotnet run --ENVIRONMENT=Production
dotnet run
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_liveFansMedal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=LiveFansMedal && \
dotnet run --ENVIRONMENT=Production
dotnet run
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_liveLottery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=LiveLottery && \
dotnet run --ENVIRONMENT=Production
dotnet run
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=Login && \
dotnet run --ENVIRONMENT=Production
dotnet run
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=Test && \
dotnet run --ENVIRONMENT=Production
dotnet run
7 changes: 4 additions & 3 deletions qinglong/DefaultTasks/bili_task_tryFix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ echo -e "清理缓存...\n"
cd $bili_repo_dir
find . -type d -name "bin" -exec rm -rf {} +
find . -type d -name "obj" -exec rm -rf {} +
echo "清理完成"
echo -e "清理完成\n"

echo "检测dotnet"
echo "检测dotnet..."
dotnetVersion=$(dotnet --version)
if [[ $dotnetVersion == 6.* ]]; then
echo "已安装dotnet,当前版本:$dotnetVersion"
else
echo "which dotnet: $(which dotnet)"
echo "Paht: $PATH"
rm -f /usr/local/bin/dotnet
fi
fi
echo "检测dotnet结束"
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_unfollowBatched.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=UnfollowBatched && \
dotnet run --ENVIRONMENT=Production
dotnet run
2 changes: 1 addition & 1 deletion qinglong/DefaultTasks/bili_task_vipBigPoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=VipBigPoint && \
dotnet run --ENVIRONMENT=Production
dotnet run
1 change: 1 addition & 0 deletions qinglong/DefaultTasks/dev/bili_dev_task_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ echo -e "bili仓库目录: $bili_repo_dir\n"

cd $bili_repo_dir
export Ray_PlateformType=QingLong
export DOTNET_ENVIRONMENT=Production
7 changes: 4 additions & 3 deletions qinglong/DefaultTasks/dev/bili_dev_task_tryFix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ echo -e "清理缓存...\n"
cd $bili_repo_dir
find . -type d -name "bin" -exec rm -rf {} +
find . -type d -name "obj" -exec rm -rf {} +
echo "清理完成"
echo -e "清理完成\n"

echo "检测dotnet"
echo "检测dotnet..."
dotnetVersion=$(dotnet --version)
if [[ $dotnetVersion == 6.* ]]; then
echo "已安装dotnet,当前版本:$dotnetVersion"
else
echo "which dotnet: $(which dotnet)"
echo "Paht: $PATH"
rm -f /usr/local/bin/dotnet
fi
fi
echo "检测dotnet结束"
2 changes: 2 additions & 0 deletions src/Ray.BiliBiliTool.Agent/Attributes/LogFilterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ protected override Task WriteLogAsync(ApiResponseContext context, LogMessage log
ILogger logger = loggerFactory.CreateLogger(categoryName);

if (logMessage.Exception == null)
{
logger.LogDebug(logMessage.ToString());//修改为Debug等级
}
else
{
if (_logError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,13 @@ public AddCoinRequest(long aid, string csrf)
public string Cross_domain { get; set; } = "true";

public string Csrf { get; set; }

public string Eab_x { get; set; } = "2";

public string Ramval { get; set; } = "3";

public string Source { get; set; } = "web_normal";

public string Ga { get; set; } = "1";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class MedalInfoDto
{
public string Medal_name { get; set; }

public int Medal_id { get; set; }
public long Medal_id { get; set; }

public int Target_id { get; set; }
public long Target_id { get; set; }

public int Level { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Passport
{
public class GetSsoListResponse
{
public List<string> sso { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/IHomeApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Ray.BiliBiliTool.Agent.Attributes;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
using WebApiClientCore.Attributes;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces
{
/// <summary>
/// 主站首页接口API
/// </summary>
public interface IHomeApi : IBiliBiliApi
{
[HttpGet("")]
Task<HttpResponseMessage> GetHomePageAsync([Header("Cookie")] string ck);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public interface IPassportApi : IBiliBiliApi
[HttpGet("/x/passport-login/web/qrcode/poll?qrcode_key={qrcode_key}&source=main_mini")]
//Task<BiliApiResponse<TokenDto>> CheckQrCodeHasScaned(string qrcode_key);
Task<HttpResponseMessage> CheckQrCodeHasScaned(string qrcode_key);

[HttpGet("/x/passport-login/web/sso/list?biliCSRF={csrf}")]
Task<BiliApiResponse<GetSsoListResponse>> GetSsoListAsync(string csrf);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Ray.BiliBiliTool.Agent.Attributes;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
using WebApiClientCore.Attributes;

Expand All @@ -26,6 +27,6 @@ public interface IUserInfoApi : IBiliBiliApi
/// <param name="userId">uid</param>
/// <returns></returns>
[HttpGet("/x/space/wbi/acc/info?mid={userId}")]
Task<BiliApiResponse<GetSpaceInfoResponse>> GetSpaceInfo(int userId);
Task<BiliApiResponse<GetSpaceInfoResponse>> GetSpaceInfo(long userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public interface IVideoApi : IBiliBiliApi
/// <param name="csrf"></param>
/// <returns></returns>
[Header("Content-Type", "application/x-www-form-urlencoded")]
[Header("Referer", "https://www.bilibili.com/")]
//[Header("Referer", "https://www.bilibili.com/")]
[Header("Origin", "https://www.bilibili.com")]
[HttpPost("/x/web-interface/coin/add?aid={aid}&multiply={multiply}&select_like={select_like}&cross_domain=true&csrf={csrf}")]
Task<BiliApiResponse> AddCoinForVideo([FormContent] AddCoinRequest request);
[HttpPost("/x/web-interface/coin/add")]
Task<BiliApiResponse> AddCoinForVideo([FormContent] AddCoinRequest request,[Header("referer")]string refer= "https://www.bilibili.com/video/BV123456/?spm_id_from=333.1007.tianma.1-1-1.click&vd_source=80c1601a7003934e7a90709c18dfcffd");

/// <summary>
/// 获取当前用户对<paramref name="aid"/>视频的投币信息
Expand Down
56 changes: 17 additions & 39 deletions src/Ray.BiliBiliTool.Agent/BiliCookie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,40 @@ public BiliCookie(List<string> ckStrList)
: this(NullLogger<BiliCookie>.Instance, new CookieStrFactory(ckStrList)) { }

public BiliCookie(ILogger<BiliCookie> logger, CookieStrFactory cookieStrFactory)
: this(logger, cookieStrFactory.GetCurrentCookieStr()) { }

private BiliCookie(ILogger<BiliCookie> logger, string ckStr)
: base(ckStr, null, v => v.Contains(',') ? Uri.EscapeDataString(v) : v)
//: base(ckStr, null, v => v)
: base(cookieStrFactory)
{
_logger = logger;
}

if (CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(UserId)), out string userId))
{
UserId = userId;
}
if (CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(BiliJct)), out string jct))
{
BiliJct = jct;
}
if (CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(SessData)), out string sess))
{
SessData = sess;
}
if (CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(LiveBuvid)), out string liveBuvid))
public override string CkValueBuild(string value)
{
value = base.CkValueBuild(value);

if (value.Contains(','))
{
LiveBuvid = liveBuvid;
value = Uri.EscapeDataString(value);
}

return value;
}

[Description("DedeUserID")]
public string UserId { get; set; }
public string UserId => CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(UserId)), out string userId) ? userId : "";

/// <summary>
/// SESSDATA
/// </summary>
[Description("SESSDATA")]
public string SessData { get; set; }
public string SessData => CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(SessData)), out string sess) ? sess : "";

[Description("bili_jct")]
public string BiliJct { get; set; }
public string BiliJct => CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(BiliJct)), out string jct) ? jct : "";

[Description("LIVE_BUVID")]
public string LiveBuvid { get; set; }
public string LiveBuvid => CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(LiveBuvid)), out string liveBuvid) ? liveBuvid : "";

[Description("buvid3")]
public string Buvid => CookieItemDictionary.TryGetValue(GetPropertyDescription(nameof(Buvid)), out string buvid) ? buvid : "";

/// <summary>
/// 检查是否已配置
Expand Down Expand Up @@ -104,22 +98,6 @@ public override void Check()
throw new Exception($"请正确配置Cookie后再运行,配置方式见 {Constants.SourceCodeUrl}");
}

public override string ToString()
{
var re = CookieStr;
if (re.IsNullOrEmpty()) return "";

// https://github.com/RayWangQvQ/BiliBiliToolPro/issues/228
if (!re.Contains("buvid3"))
{
//buvid3=G5F0F1C0-C1B5-D6E7-4CC0-13C1AAB7C1BC33815infoc;
var random = $"buvid3={Guid.NewGuid().ToString().ToUpper()}infoc; ";
re = random + re;
}

return re;
}

private string GetPropertyDescription(string propertyName)
{
return GetType().GetPropertyDescription(propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Ray.BiliBiliTool.Agent.QingLong;
using Ray.BiliBiliTool.Config.Options;
using Ray.BiliBiliTool.Infrastructure;
using Ray.BiliBiliTool.Infrastructure.Cookie;

namespace Ray.BiliBiliTool.Agent.Extensions
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public static IServiceCollection AddBiliBiliClientApi(this IServiceCollection se

return new CookieStrFactory(list);
});
services.AddTransient<BiliCookie>();
services.AddScoped<BiliCookie>();

//全局代理
services.SetGlobalProxy(configuration);
Expand All @@ -67,12 +68,10 @@ public static IServiceCollection AddBiliBiliClientApi(this IServiceCollection se
services.AddBiliBiliClientApi<IChargeApi>("https://api.bilibili.com");
services.AddBiliBiliClientApi<IVideoApi>("https://api.bilibili.com");
services.AddBiliBiliClientApi<IVideoWithoutCookieApi>("https://api.bilibili.com", false);

services.AddBiliBiliClientApi<IVipBigPointApi>("https://api.bilibili.com");

services.AddBiliBiliClientApi<IPassportApi>("http://passport.bilibili.com", false);

services.AddBiliBiliClientApi<ILiveTraceApi>("https://live-trace.bilibili.com");
services.AddBiliBiliClientApi<IHomeApi>("https://www.bilibili.com", false);

//qinglong
var qinglongHost = configuration["QL_URL"] ?? "http://localhost:5600";
Expand Down
7 changes: 3 additions & 4 deletions src/Ray.BiliBiliTool.Application.Contracts/IAppService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Application.Contracts
{
Expand All @@ -9,6 +8,6 @@ namespace Ray.BiliBiliTool.Application.Contracts
/// </summary>
public interface IAppService
{
void DoTask();
Task DoTaskAsync(CancellationToken cancellationToken);
}
}
Loading

0 comments on commit c5837ab

Please sign in to comment.