Skip to content

Commit

Permalink
init VIP big point ogv watch API
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Jan 4, 2025
1 parent bfd05d6 commit 9e08fc7
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ headers {
session_id: e04d2e05
env: prod
app-key: android64
user-agent: Mozilla/5.0 BiliDroid/7.72.0 ([email protected]) os/android model/Nexus mobi_app/android build/7720200 channel/yingyongbao innerVer/7720210 osVer/10 network/2
user-agent: {{user-agent}}
x-bili-trace-id: 0564afa825e0e1ec59164fe59367755a:59164fe59367755a:0:0
x-bili-aurora-eid: UlAAQFkMBVkH
x-bili-mid: {{mid}}
Expand Down
29 changes: 29 additions & 0 deletions src/Ray.BiliBiliTool.Agent/BiliBiliAgent/Dtos/BaseAppRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;

public class BaseAppRequest
{
// public string access_key { get; set; }
// public string appkey { get; set; }

public string build { get; } = "7720200";

public string c_locale { get; } = "zh_CN";

public string channel { get; } = Constants.Channel;

public int disable_rcmd { get; } = 0;

public string from_spmid { get; } = "united.player-video-detail.player.continue";

public string mobi_app { get; } = "android";

public string platform { get; } = "android";

public string s_locale { get; } = "zh_CN";

public string statistics { get; } = "{\"appId\":1,\"platform\":3,\"version\":\"7.72.0\",\"abtest\":\"\"}";

// public long ts { get; set; }

public string sign { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;

public class CompleteOgvWatchRequest: BaseAppRequest
{
public CompleteOgvWatchRequest(long taskId, string token)
{
task_id = taskId;
this.token = token;
}

public long task_id { get; set; }

public string token { get; set; }

public string task_sign { get; set; }

public long timestamp { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;

public class StartOgvWatchRequest: BaseAppRequest
{
public long ep_id { get; } = 328482;

public long season_id { get; } = 12548;

public string Activity_code { get; } = "";

public string spmid { get; } = "united.player-video-detail.0.0";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;

public class StartOgvWatchResponse
{
public string closeType { get; set; }

public string showTime { get; set; }

public long task_id { get; set; }

public string token { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask
public class ViewRequest
{
public class ViewRequest
public ViewRequest(string position)
{
public ViewRequest(string position)
{
this.position=position;
}
this.position=position;
}

public string position { get; set; }
public string position { get; }

public string c_locale { get; set; } = "zh_CN";
public string c_locale { get; } = "zh_CN";

public string channel { get; set; } = "html5_search_baidu";
public string channel { get; } = Constants.Channel;

public int disable_rcmd { get; set; } = 0;
public int disable_rcmd { get; } = 0;

public string mobi_app { get; set; } = "android";
public string mobi_app { get; } = "android";

public string platform { get; set; } = "android";
public string platform { get; } = "android";

public string s_locale { get; set; } = "zh_CN";
public string s_locale { get; } = "zh_CN";

public string statistics { get; set; } = "{\"appId\":1,\"platform\":3,\"version\":\"6.85.0\",\"abtest\":\"\"}";
}
}
public string statistics { get; } = "{\"appId\":1,\"platform\":3,\"version\":\"6.85.0\",\"abtest\":\"\"}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces;
/// <summary>
/// 大会员大积分
/// </summary>
[Header("Host", "api.bilibili.com")]
[Header("Host", "api.bilibili.com")]
[Header("Referer", "https://big.bilibili.com/mobile/bigPoint/task")]
[LogFilter]
public interface IVipBigPointApi
Expand Down Expand Up @@ -81,4 +81,18 @@ public interface IVipBigPointApi
/// <returns></returns>
[HttpPost("/x/vip/experience/add")]
Task<BiliApiResponse> ObtainVipExperienceAsync([FormContent] VipExperienceRequest request);

/// <summary>
/// 开始观看剧集任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<BiliApiResponse<StartOgvWatchResponse>> StartOgvWatchAsync(StartOgvWatchRequest request);

/// <summary>
/// 完成观看剧集任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<BiliApiResponse> CompleteOgvWatchAsync(CompleteOgvWatchRequest request);
}
6 changes: 6 additions & 0 deletions src/Ray.BiliBiliTool.Agent/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Ray.BiliBiliTool.Agent;

public static class Constants
{
public const string Channel = "yingyongbao";
}
42 changes: 29 additions & 13 deletions src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override async Task DoTaskAsync(CancellationToken cancellationToken = def
taskInfo = await ViewDressMall(taskInfo);

//观看剧集内容
taskInfo = await ViewVideo(taskInfo);
taskInfo = await OgvWatchAsync(taskInfo);

taskInfo.LogInfo(_logger);
}
Expand Down Expand Up @@ -393,11 +393,11 @@ private async Task<VipTaskInfo> ViewVipMall(VipTaskInfo info)
return info;
}

[TaskInterceptor("观看剧集内容", TaskLevel.Two, false)]
private async Task<VipTaskInfo> ViewVideo(VipTaskInfo info)
[TaskInterceptor("浏览装扮商城主页", TaskLevel.Two, false)]
private async Task<VipTaskInfo> ViewDressMall(VipTaskInfo info)
{
const string moduleCode = "日常任务";
const string taskCode = "ogvwatchnew";
const string taskCode = "dress-view";

CommonTaskItem targetTask = GetTarget(info, moduleCode, taskCode);

Expand All @@ -407,7 +407,7 @@ private async Task<VipTaskInfo> ViewVideo(VipTaskInfo info)
return info;
}

// 如果状态不等于3,则做
//如果状态不等于3,则做
if (targetTask.state == 3)
{
_logger.LogInformation("已完成,跳过");
Expand All @@ -422,18 +422,27 @@ private async Task<VipTaskInfo> ViewVideo(VipTaskInfo info)
}

_logger.LogInformation("开始完成任务");
var re = await CompleteV2(targetTask.task_code);

//确认
if (re)
{
var infoResult = await _vipApi.GetTaskListAsync();
if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr());
info = infoResult.Data;
targetTask = GetTarget(info, moduleCode, taskCode);

// 观看剧集内容
_logger.LogInformation("api变更,暂未实现");
_logger.LogInformation("确认:{re}", targetTask.state == 3 && targetTask.complete_times >= 1);
}

return info;
}

[TaskInterceptor("浏览装扮商城主页", TaskLevel.Two, false)]
private async Task<VipTaskInfo> ViewDressMall(VipTaskInfo info)
[TaskInterceptor("观看剧集", TaskLevel.Two, false)]
private async Task<VipTaskInfo> OgvWatchAsync(VipTaskInfo info)
{
const string moduleCode = "日常任务";
const string taskCode = "dress-view";
const string taskCode = "ogvwatchnew";

CommonTaskItem targetTask = GetTarget(info, moduleCode, taskCode);

Expand All @@ -457,11 +466,18 @@ private async Task<VipTaskInfo> ViewDressMall(VipTaskInfo info)
await TryReceive(targetTask.task_code);
}

_logger.LogInformation("开始完成任务");
var re = await CompleteV2(targetTask.task_code);
_logger.LogInformation("开始任务");
var startResult = await _vipApi.StartOgvWatchAsync(new StartOgvWatchRequest());

_logger.LogInformation("开始浏览");
await Task.Delay(10 * 1000);

_logger.LogInformation("开始上报");
var request = new CompleteOgvWatchRequest(startResult.Data.task_id, startResult.Data.token); // todo: sign
var re = await _vipApi.CompleteOgvWatchAsync(request);

//确认
if (re)
if (re.Code == 0)
{
var infoResult = await _vipApi.GetTaskListAsync();
if (infoResult.Code != 0) throw new Exception(infoResult.ToJsonStr());
Expand Down

0 comments on commit 9e08fc7

Please sign in to comment.