Skip to content

Commit

Permalink
update bruno scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Jan 2, 2025
1 parent 39ba661 commit e8f538b
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 11 deletions.
1 change: 0 additions & 1 deletion bruno/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pwd=
mid=
buvid=
csrf=
appKey=
access_key=
cookieStr=
device_id=
50 changes: 50 additions & 0 deletions bruno/app.bilibili.com/folder.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
meta {
name: app.bilibili.com
}

script:pre-request {
const CryptoJS = require('crypto-js');

console.log("start");

const md5 = (str) => CryptoJS.MD5(str).toString(CryptoJS.enc.Hex);

const replacePlaceholders = (body) => {
for (const key in body) {
if (typeof body[key] === 'string') {
// Check if value contains {{}} placeholders
const matches = body[key].match(/{{(.*?)}}/g);
if (matches) {
matches.forEach(match => {
const placeholder = match.slice(2, -2); // Remove the {{ and }}
const value = bru.getEnvVar(placeholder);
body[key] = body[key].replace(match, value);
});
}
}
}
};

function appSign(params, appkey, appsec) {
params.appkey = appkey;
delete body.sign;
delete body.task_sign;
const sortedKeys = Object.keys(params).sort();
const sortedParams = sortedKeys.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join('&');
console.log(sortedParams);
return md5(sortedParams + appsec);
}

const body = req.getBody();

if (body.hasOwnProperty('sign')) {
replacePlaceholders(body);
const sign = appSign(body, bru.getEnvVar("appKey"), bru.getEnvVar("appSec"));
console.log("calculate sign:" + sign);

body.sign = sign;
body.task_sign = sign;
}

req.setBody(body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ body:form-urlencoded {
ts: 1735744215
sign: 132d2532467ef649a925aece247cdb4b
}

docs {
终端:APP

作用:开始大会员赚大积分任务-观看剧集内容

入口:
- 我的->会员中心->赚大积分->查看8项任务,点击“观看剧集内容”后自动触发
}
37 changes: 33 additions & 4 deletions bruno/app.bilibili.com/pgc/activity/deliver/task/complete.bru
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ 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: a301946d9621645a707b40973f67755c:707b40973f67755c:0:0
x-bili-aurora-eid: UlAAQFkMBVkH
x-bili-mid: {{mid}}
x-bili-aurora-zone:
x-bili-gaia-vtoken:
x-bili-ticket: eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzU3NzI2NDcsImlhdCI6MTczNTc0MzU0NywiYnV2aWQiOiJYVzcyNEQxNzI0Njg3MTlDQzI1NjA1REIyNDI0NzhEMkUxMjE5In0.eafhpooLoe2q6cA45_Xrgq1VO-y490pxP5gwJ4qm_ik
bili-http-engine: cronet
content-type: application/x-www-form-urlencoded; charset=utf-8
}

body:form-urlencoded {
access_key: {{access_key}}
appkey: {{appKey}}
build: 7720200
c_locale: zh_CN
Expand All @@ -41,9 +39,40 @@ body:form-urlencoded {
s_locale: zh_CN
statistics: {"appId":1,"platform":3,"version":"7.72.0","abtest":""}
task_id: 4320003
token: 6c54c1256a
access_key: {{access_key}}
task_sign: 78cf66f2699393751c41c2fda27c2ccf
timestamp: 1735744760834
token: 4c2cba3427
ts: 1735744760
sign: 2292d647d9b3f6dbd2f99b5a90cbddaf
}

script:pre-request {
const CryptoJS = require('crypto-js');

console.log("start");

const md5 = (str) => CryptoJS.MD5(str).toString(CryptoJS.enc.Hex);

function appSign(params, appkey, appsec) {
console.log("appkey:"+appkey);
console.log("appsec:"+appsec);
params.appkey = appkey;
const sortedKeys = Object.keys(params).sort();
const sortedParams = sortedKeys.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join('&');
console.log(sortedParams);
return md5(sortedParams + appsec);
}

const body = req.getBody();

if (body.hasOwnProperty('sign')) {
body.access_key=bru.getEnvVar("access_key");
const sign = appSign(body, bru.getEnvVar("appKey"), bru.getEnvVar("appSec"));
console.log("calculate sign:" + sign);

body.sign = sign;
}

req.setBody(body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ body:form-urlencoded {

docs {
终端:APP

作用:领取大会员赚大积分任务-购买指定装扮商品

入口:
- 我的->会员中心->赚大积分->查看8项任务->领取任务
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ body:form-urlencoded {

docs {
终端:APP

作用:领取大会员赚大积分任务-观看剧集内容

入口:
- 我的->会员中心->赚大积分->查看8项任务->领取任务
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ body:form-urlencoded {

docs {
终端:APP

作用:领取大会员赚大积分任务-购买单点付费影片

入口:
- 我的->会员中心->赚大积分->查看8项任务->领取任务
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ body:form-urlencoded {

docs {
终端:APP

作用:领取大会员赚大积分任务-购买指定会员购商品

入口:
- 我的->会员中心->赚大积分->查看8项任务->领取任务
}
9 changes: 9 additions & 0 deletions bruno/app.bilibili.com/x/vip_point/task/combine.bru
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ headers {
x-bili-ticket: eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzU3NjE2NjQsImlhdCI6MTczNTczMjU2NCwiYnV2aWQiOiJYVzcyNEQxNzI0Njg3MTlDQzI1NjA1REIyNDI0NzhEMkUxMjE5In0.YVtwH53dLJ1l6n6aFcvwNZ4MBkgnBPtxE8UfD7u9J4I
bili-http-engine: cronet
}

docs {
终端:APP

作用:获取大会员赚大积分的任务列表

入口:
- 我的->会员中心->赚大积分->查看8项任务
}
4 changes: 3 additions & 1 deletion bruno/environments/default.bru
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ vars {
mid: {{process.env.mid}}
buvid: {{process.env.buvid}}
csrf: {{process.env.csrf}}
appKey: {{process.env.appKey}}
appKey: 1d8b6e7d45233436
access_key: {{process.env.access_key}}
cookieStr: {{process.env.cookieStr}}
user-agent: Mozilla/5.0 (Linux; Android 10; Nexus Build/KOT49H; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.186 Mobile Safari/537.36 os/android model/Nexus build/7720200 osVer/10 sdkInt/29 network/2 BiliApp/7720200 mobi_app/android channel/yingyongbao Buvid/{{buvid}} sessionID/92c5ad7a innerVer/7720210 c_locale/zh_CN s_locale/zh_CN disable_rcmd/0 7.72.0 os/android model/Nexus mobi_app/android build/7720200 channel/yingyongbao innerVer/7720210 osVer/10 network/2
device_id: {{device_id}}
user-agent-simple: Mozilla/5.0 (Linux; Android 12; SM-S9080 Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36 os/android model/SM-S9080 build/7760700 osVer/12 sdkInt/32 network/2 BiliApp/7760700 mobi_app/android channel/bili innerVer/7760710 c_locale/zh_CN s_locale/zh_CN disable_rcmd/0 7.76.0 os/android model/SM-S9080 mobi_app/android build/7760700 channel/bili innerVer/7760710 osVer/12 network/2
appSec: 560c52ccd288fed045859ed18bffd973
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Ray.BiliBiliTool.Agent.Attributes;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;
using System;
using WebApiClientCore.Attributes;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces;
Expand Down Expand Up @@ -34,20 +35,39 @@ public interface IVipBigPointApi
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Obsolete]
[HttpPost("/pgc/activity/score/task/receive")]
Task<BiliApiResponse> Receive([JsonContent] ReceiveOrCompleteTaskRequest request);

/// <summary>
/// 领取任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("/pgc/activity/score/task/receive/v2")]
Task<BiliApiResponse> ReceiveV2([FormContent] ReceiveOrCompleteTaskRequest request);


/// <summary>
/// 完成任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("/pgc/activity/score/task/complete")]
Task<BiliApiResponse> CompleteAsync([JsonContent] ReceiveOrCompleteTaskRequest request);

/// <summary>
/// 完成任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("/pgc/activity/score/task/complete/v2")]
Task<BiliApiResponse> CompleteV2([FormContent] ReceiveOrCompleteTaskRequest request);


/// <summary>
/// 完成浏览页面任务
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost("/pgc/activity/deliver/task/complete")]
Task<BiliApiResponse> ViewComplete([FormContent] ViewRequest request);

Expand Down
1 change: 1 addition & 0 deletions src/Ray.BiliBiliTool.Agent/BiliHosts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public static class BiliHosts
{
public const string Api = "https://api.bilibili.com";
public const string App = "https://app.bilibili.com";
public const string Show = "https://show.bilibili.com";
public const string Passport = "http://passport.bilibili.com";
public const string LiveTrace = "https://live-trace.bilibili.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static IServiceCollection AddBiliBiliClientApi(this IServiceCollection se
services.AddBiliBiliClientApi<IAccountApi>(BiliHosts.Account, config);
services.AddBiliBiliClientApi<ILiveApi>(BiliHosts.Live, config);

services.AddBiliBiliClientApi<IVipBigPointApi>(BiliHosts.Api, configApp);
services.AddBiliBiliClientApi<IVipBigPointApi>(BiliHosts.App, configApp);


//qinglong
Expand Down
4 changes: 2 additions & 2 deletions src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private async Task<VipTaskInfo> ReceiveTasksAsync(VipTaskInfo info)

foreach (var targetTask in needReceiveTasks)
{
_logger.LogInformation("开始领取任务");
_logger.LogInformation("开始领取任务:{task}", targetTask.title);
await TryReceive(targetTask.task_code);
}

Expand Down Expand Up @@ -493,7 +493,7 @@ private async Task TryReceive(string taskCode)
try
{
var request = new ReceiveOrCompleteTaskRequest(taskCode);
re = await _vipApi.Receive(request);
re = await _vipApi.ReceiveV2(request);
if (re.Code == 0)
_logger.LogInformation("领取任务成功");
else
Expand Down

0 comments on commit e8f538b

Please sign in to comment.