diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LikeLiveRoomRequest.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LikeLiveRoomRequest.cs
index e7515ac31..18001fe40 100644
--- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LikeLiveRoomRequest.cs
+++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/Live/LikeLiveRoomRequest.cs
@@ -8,16 +8,32 @@ namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class LikeLiveRoomRequest
{
- public LikeLiveRoomRequest(long roomid, string csrf)
+ public LikeLiveRoomRequest(long roomid, string csrf, int clickTime, long anchorId, string uid)
{
Roomid = roomid;
- Csrf= csrf;
+ Csrf = csrf;
+ Click_Time = clickTime;
+ Anchor_Id = anchorId;
+ Uid = uid;
}
public long Roomid { get; set; }
public string Csrf { get; set; }
- public string Csrf_token => Csrf;
+ public string Csrf_Token => Csrf;
+
+ public int Click_Time { get; set; }
+
+ public long Anchor_Id { get; set; }
+
+ public string Uid { get; set; }
+
+
+ public string RawTextBuild()
+ {
+ return
+ $"click_time={Click_Time.ToString()}&room_id={Roomid.ToString()}&uid={Uid}&anchor_id={Anchor_Id}&csrf_token={Csrf_Token}&csrf={Csrf}";
+ }
}
-}
+}
\ No newline at end of file
diff --git a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs
index 0db0ae863..02c0fc52a 100644
--- a/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs
+++ b/src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Interfaces/ILiveApi.cs
@@ -144,8 +144,8 @@ public interface ILiveApi : IBiliBiliApi
///
/// 点赞直播间
///
- [HttpPost("/xlive/web-ucenter/v1/interact/likeInteract")]
+ [HttpPost("/xlive/app-ucenter/v1/like_info_v3/like/likeReportV3")]
[Header("Referer", "https://live.bilibili.com/")]
[Header("Origin", "https://live.bilibili.com")]
- Task LikeLiveRoom([FormContent] LikeLiveRoomRequest request);
-}
+ Task LikeLiveRoom([RawFormContent] string request);
+}
\ No newline at end of file
diff --git a/src/Ray.BiliBiliTool.Config/Options/LiveFansMedalTaskOptions.cs b/src/Ray.BiliBiliTool.Config/Options/LiveFansMedalTaskOptions.cs
index 0e60cc608..3581df1fc 100644
--- a/src/Ray.BiliBiliTool.Config/Options/LiveFansMedalTaskOptions.cs
+++ b/src/Ray.BiliBiliTool.Config/Options/LiveFansMedalTaskOptions.cs
@@ -37,22 +37,18 @@ public class LiveFansMedalTaskOptions
public const int HeartBeatInterval = 60;
///
- /// 点赞次数
+ /// 点赞次数,默认值为30(用于点亮粉丝勋章)
///
- public int LikeNumber { get; set; } = 55;
-
- ///
- /// 点赞发送失败多少次时放弃
- ///
- public int LikeGiveUpThreshold { get; set; } = 5;
+ public int LikeNumber { get; set; } = 30;
///
/// 发送弹幕次数
///
- public int SendDanmakuNumber { get; set; } = 15;
+ public int SendDanmakuNumber { get; set; } = 1;
+
///
/// 弹幕发送失败多少次时放弃
///
- public int SendDanmakugiveUpThreshold { get; set; } = 5;
+ public int SendDanmakugiveUpThreshold { get; set; } = 3;
}
-}
+}
\ No newline at end of file
diff --git a/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs b/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs
index 91cc26e68..704e93d89 100644
--- a/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs
+++ b/src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs
@@ -432,8 +432,6 @@ public async Task SendDanmakuToFansMedalLive()
while (successCount < _liveFansMedalTaskOptions.SendDanmakuNumber &&
failedCount < _liveFansMedalTaskOptions.SendDanmakugiveUpThreshold)
{
- await Task.Delay(2000);
-
var sendResult = await _liveApi.SendLiveDanmuku(new SendLiveDanmukuRequest(
_biliCookie.BiliJct,
spaceInfo.Data.Live_room.Roomid,
@@ -447,6 +445,9 @@ public async Task SendDanmakuToFansMedalLive()
}
else
successCount++;
+
+ var delay = new Random().Next(2000, 4000);
+ await Task.Delay(delay);
}
@@ -460,7 +461,7 @@ public async Task SendHeartBeatToFansMedalLive()
if (!await CheckLiveCookie()) return;
var infoList = new List();
- (await GetFansMedalInfoList()).ForEach(medal =>
+ (await GetFansMedalInfoList()).FindAll(info => info.LiveRoomInfo.Live_Status != 0).ForEach(medal =>
infoList.Add(new(medal.RoomId, medal.LiveRoomInfo, new(), 0, 0))
);
@@ -559,38 +560,36 @@ public async Task SendHeartBeatToFansMedalLive()
_logger.LogInformation("【直播观看时长】完成情况:{success}/{total} ", successCount, infoList.Count);
}
+ ///
+ /// 点赞直播间
+ ///
public async Task LikeFansMedalLive()
{
if (!await CheckLiveCookie()) return;
var infoList = await GetFansMedalInfoList();
- infoList = infoList.FindAll(info => info.LiveRoomInfo.Live_Status != 1);
-
+ infoList = infoList.FindAll(info => info.LiveRoomInfo.Live_Status != 0);
+ _logger.LogInformation("当前开播直播间数量:{num}", infoList.Count);
foreach (var info in infoList)
{
- var successCount = 0;
- var failedCount = 0;
- while (successCount < _liveFansMedalTaskOptions.LikeNumber &&
- failedCount < _liveFansMedalTaskOptions.LikeGiveUpThreshold)
- {
- var result = await _liveApi.LikeLiveRoom(new LikeLiveRoomRequest(info.RoomId, _biliCookie.BiliJct));
- if (result.Code == 0)
- {
- // _logger.LogInformation("【点赞直播间】{roomId} 完成", info.RoomId);
- successCount++;
- }
- else
- {
- _logger.LogError("【点赞直播间】{roomId} 时候出现错误", info.RoomId);
- _logger.LogError("【原因】{message}", result.Message);
- failedCount++;
- }
+ // Clike_Time 暂时设置为等于设置的LikeNumber,不清楚是否会被风控,我自己抓包最大值为10
+ var request = new LikeLiveRoomRequest(info.RoomId, _biliCookie.BiliJct,
+ _liveFansMedalTaskOptions.LikeNumber,
+ info.LiveRoomInfo.Uid, _biliCookie.UserId);
- await Task.Delay(500);
+ var result = await _liveApi.LikeLiveRoom(request.RawTextBuild());
+ if (result.Code == 0)
+ {
+ _logger.LogInformation("【点赞直播间】{roomId} 完成", info.RoomId);
+ }
+ else
+ {
+ _logger.LogError("【点赞直播间】{roomId} 时候出现错误", info.RoomId);
+ _logger.LogError("【原因】{message}", result.Message);
}
- _logger.LogInformation("【点赞直播间】{romeId}完成情况:{success}/{total}", info.RoomId, successCount,
- failedCount + successCount);
+ var delay = new Random().Next(5000, 8000);
+ await Task.Delay(delay);
}
}