Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Jan 18, 2023
2 parents 36f4ea1 + ab9cf11 commit a2803da
Show file tree
Hide file tree
Showing 53 changed files with 1,186 additions and 72 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@
- Fix( #364 ),兼容青龙异形response数据类型
- Fix( #366 #361 ),修复一些低级bug
- Feature( #359 ),兼容读取不到`$QL_DIR`的情况
## 0.4.0
- 合并PR( #381 #383 ),新增直播间挂机功能,感谢@bakapiano
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ BiliBiliTool

- **扫码登录,自动更新cookie**
- **每日获取满额升级经验(登录、投币、点赞、分享视频)(支持指定支持up主)**
- **直播间挂机**
- **每天漫画签到**
- **每天直播签到**
- **直播中心银瓜子兑换为硬币**
Expand Down Expand Up @@ -69,7 +70,7 @@ BiliBiliTool

- **本应用仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!**
- **所有代码都是开源且透明的,任何人均可查看,程序不会保存或滥用任何用户的个人信息**
- **应用内几乎所有功能都开放为了配置(如任务开关、日期、id等),详细信息可阅读配置文档,请自己对配置负责**
- **应用内几乎所有功能都开放为了配置(如任务开关、日期、id等),详细信息可阅读配置文档,请对自己配置负责**

本地运行图示:

Expand Down Expand Up @@ -111,9 +112,7 @@ BiliBiliTool 实现自动完成任务的原理,是通过调用一系列开放

#### 1.1.5. 方式五:~~GitHub Actions~~

暂时删掉该方式避避风头。

**建议所有使用该方式运行的朋友,暂时先替换其他运行方式,避免造成不必要的损失。**
GitHub官方反对并抵制对Actions的滥用,建议所有使用该方式运行的朋友,暂时先替换其他运行方式,避免封号。

#### 1.1.6. 方式六:Chart部署

Expand Down Expand Up @@ -146,15 +145,15 @@ dotnet Ray.BiliBiliTool.Console.dll --runTasks=Daily&LiveLottery

任务列表如下:

| 任务名 | Code | 功能 | 默认WorkFlow文件 | GithHub Environments | 推荐运行频率 | 备注 |
| :----: | :----: | :----: | :----: | :----: | :----: | :----: |
| 扫码登录 | Login | 试用bili app扫码登录,用于第一次运行时初始化cookie,或cookie过期时的更新。不同平台会将cookie存储到不同地方,青龙存储到环境变量中,其他会存储到cookies。json中 | | Production | 手动 | |
| 每日任务 | Daily | 完成每日任务获取满额65点经验(登录、观看视频、分享视频、投币),以及签到、领福利和充电等附属功能 | bilibili-daily-task.yml | Production | 每天一次 | |
| 天选时刻抽奖 | LiveLottery | 直播中心天选时刻抽奖 | live-lottery-task.yml | LiveLottery | 建议每天运行0-4次内 | 对应Actions工作流默认是关闭的,需要添加key为`ISOPENLIVELOTTERYTASK`、值为`true`的secret来手动开启;大部分抽奖都需要关注主播,介意的不要开启 |
| 批量取关 | UnfollowBatched | 批量取关指定分组下的所有关注(主要用于清理天选抽奖而产生的关注) | unfollow-batched-task.yml || 需要时手动运行 | 需要通过配置指定2个参数:`GroupName`(分组名称,如`天选时刻`)和`Count`(目标取关个数,-1表示全部),应用会倒序从后往前取关指定个数 |
| 大会员大积分 | VipBigPoint | 大会员大积分任务(签到、浏览、观看) | || 每天凌晨一点运行 | |
| 测试Cookie | Test | 测试Cookie是否正常 | 无,可以使用empty-task.yml来运行 || 需要时手动运行 | 主要用于调试 |
| 空模板 | 无(只用于 GitHub Actions ) | 用于 GitHub Actions 运行指定的任意任务 | empty-task.yml || 需要时手动运行 | 需要通过配置指定要运行的任务Code(多个使用英文逗号分隔),主要用于调试 |
| 任务名 | Code | 功能 | 推荐运行频率 | 备注 |
| :----: | :----: | :----: | :----: | :----: |
| 扫码登录 | Login | 试用bili app扫码登录,用于第一次运行时初始化cookie,或cookie过期时的更新。不同平台会将cookie存储到不同地方,青龙存储到环境变量中,其他会存储到cookies。json中 | 手动 | |
| 每日任务 | Daily | 完成每日任务获取满额65点经验(登录、观看视频、分享视频、投币),以及签到、领福利和充电等附属功能 | 每天一次 | |
| 天选时刻抽奖 | LiveLottery | 直播中心天选时刻抽奖 | 建议每天运行0-4次 | 对应Actions工作流默认是关闭的,需要添加key为`ISOPENLIVELOTTERYTASK`、值为`true`的secret来手动开启;大部分抽奖都需要关注主播,介意的不要开启 |
| 批量取关 | UnfollowBatched | 批量取关指定分组下的所有关注(主要用于清理天选抽奖而产生的关注) | 需要时手动运行 | 需要通过配置指定2个参数:`GroupName`(分组名称,如`天选时刻`)和`Count`(目标取关个数,-1表示全部),应用会倒序从后往前取关指定个数 |
| 大会员大积分 | VipBigPoint | 大会员大积分任务(签到、浏览、观看) | 每天凌晨一点运行 | |
| 直播间挂机 | LiveFansMedal | 直播间挂机 | 每天一次 | |
| 测试Cookie | Test | 测试Cookie是否正常 | 需要时手动运行 | 主要用于调试 |

## 3. 个性化自定义配置

Expand Down Expand Up @@ -210,9 +209,9 @@ dotnet Ray.BiliBiliTool.Console.dll --runTasks=Daily&LiveLottery

* 搜索查看 Issue,确定是否已有人提过同类问题

* 确认没有同类 Issue 后,自己可新建 Issue,描述问题或建议
* 对于不确定的主题,为避免code结束后PR不被接受,可以先新建 Issue,描述问题或建议,讨论清楚后再动手编码

* 如果想自己解决,请 Fork 仓库后,在**develop 分支**进行编码开发,完成后**提交 PR 到 develop 分支**,并标注解决的 Issue 编号
* 如果确认自己可以解决,请 Fork 仓库后,在**develop 分支**进行编码开发,完成后**提交 PR 到 develop 分支**

我会尽快进行代码审核,测试成功后会合并入 main 主分支,提前感谢您的贡献。

Expand All @@ -221,8 +220,6 @@ dotnet Ray.BiliBiliTool.Console.dll --runTasks=Daily&LiveLottery

## 8. 捐赠支持

[>>捐赠留言及回复](docs/donate-list.md)

个人维护开源不易

如果觉得我写的程序对你小有帮助
Expand Down
4 changes: 2 additions & 2 deletions Ray.BiliBiliTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.WorkWeiXi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.Serilog.Sinks.MicrosoftTeamsBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.MicrosoftTeamsBatched\Ray.Serilog.Sinks.MicrosoftTeamsBatched.csproj", "{FB9A43DE-00F0-42C4-BF92-AF61D752CCA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ray.Serilog.Sinks.GotifyBatched", "src\Ray.Serilog.Sinks\Ray.Serilog.Sinks.GotifyBatched\Ray.Serilog.Sinks.GotifyBatched.csproj", "{B00FF75D-4C48-45ED-9A24-5C0D383317EE}"
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -254,7 +254,7 @@ Global
{DB227D60-0737-45C2-8CEA-F55FDA711301} = {38736647-2196-417E-8519-C48A012A63D9}
{114D45C8-E4BB-47EE-89AC-BD1DC6FA3BAD} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{2039BF6A-5EC4-439C-8D2E-77313075843A} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{110D3D21-8E9B-45AB-9667-6DA1DB3862AC} = {AF21E067-3307-4E7F-8CE8-C695E6B61876}
{110D3D21-8E9B-45AB-9667-6DA1DB3862AC} = {120917DC-474C-448B-9EBB-1B3BA3A20B9D}
{7188698C-0A9A-43B2-B3E2-5136B14FDE13} = {110D3D21-8E9B-45AB-9667-6DA1DB3862AC}
{3388A58D-91CC-4875-A29F-3E6FC3B44BF5} = {98051127-2868-4F5C-9B2C-2150975E05F3}
{B6AEDD60-9C06-4391-9171-65EBD5E9D77A} = {98051127-2868-4F5C-9B2C-2150975E05F3}
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.3.2</Version>
<Version>0.4.0</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions docker/crontab
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0 15 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=Daily >> /var/log/cron.log
0 22 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=LiveLottery >> /var/log/cron.log
7 1 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=VipBigPoint >> /var/log/cron.log
5 0 * * * dotnet /app/Ray.BiliBiliTool.Console.dll --runTasks=LiveFansMedal >> /var/log/cron.log
1 change: 1 addition & 0 deletions docker/sample/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- Ray_LiveLotteryTaskConfig__Cron=0 22 * * *
- Ray_UnfollowBatchedTaskConfig__Cron=0 6 1 * *
- Ray_VipBigPointConfig__Cron=7 1 * * *
- Ray_LiveFansMedalTaskConfig__Cron=5 0 * * *

# UA:
- Ray_Security__UserAgent=
Expand Down
29 changes: 16 additions & 13 deletions docker/scripts/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,38 @@ CRON_FILE="/etc/cron.d/bilicron"

# https://stackoverflow.com/questions/27771781/how-can-i-access-docker-set-environment-variables-from-a-cron-job
echo "[step 1/4]导入环境变量"
printenv | grep -v "no_proxy" > /etc/environment
declare -p | grep -v "no_proxy" > /etc/cron.env
printenv | grep -v "no_proxy" >/etc/environment
declare -p | grep -v "no_proxy" >/etc/cron.env
echo -e "=>完成\n"

echo "[step 2/4]配置cron定时任务"
echo "SHELL=/bin/bash" > $CRON_FILE
echo "BASH_ENV=/etc/cron.env" >> $CRON_FILE
if [ -z "$Ray_LiveLotteryTaskConfig__Cron$Ray_UnfollowBatchedTaskConfig__Cron$Ray_VipBigPointConfig__Cron" ]; then
echo "SHELL=/bin/bash" >$CRON_FILE
echo "BASH_ENV=/etc/cron.env" >>$CRON_FILE
if [ -z "$Ray_LiveLotteryTaskConfig__Cron$Ray_UnfollowBatchedTaskConfig__Cron$Ray_VipBigPointConfig__Cron$Ray_LiveFansMedalTaskConfig__Cron" ]; then
echo "=>使用默认的定时任务配置"
cat /app/scripts/crontab >> $CRON_FILE
cat /app/scripts/crontab >>$CRON_FILE
else
echo "=>使用用户指定的定时任务配置"
if ! [ -z "$Ray_DailyTaskConfig__Cron" ]; then
echo "$Ray_DailyTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=Daily" >> $CRON_FILE
echo "$Ray_DailyTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=Daily" >>$CRON_FILE
fi
if ! [ -z "$Ray_LiveLotteryTaskConfig__Cron" ]; then
echo "$Ray_LiveLotteryTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveLottery" >> $CRON_FILE
echo "$Ray_LiveLotteryTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveLottery" >>$CRON_FILE
fi
if ! [ -z "$Ray_UnfollowBatchedTaskConfig__Cron" ]; then
echo "$Ray_UnfollowBatchedTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=UnfollowBatched" >> $CRON_FILE
echo "$Ray_UnfollowBatchedTaskConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=UnfollowBatched" >>$CRON_FILE
fi
if ! [ -z "$Ray_VipBigPointConfig__Cron" ]; then
echo "$Ray_VipBigPointConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=VipBigPoint" >> $CRON_FILE
echo "$Ray_VipBigPointConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=VipBigPoint" >>$CRON_FILE
fi
if ! [ -z "$Ray_LiveFansMedalConfig__Cron" ]; then
echo "$Ray_LiveFansMedalConfig__Cron cd /app && dotnet $CONSOLE_DLL --runTasks=LiveFansMedal" >>$CRON_FILE
fi
fi

if ! [ -z "$Ray_Crontab" ]; then
echo "=>检测到自定义定时任务"
echo "$Ray_Crontab" >> $CRON_FILE
echo "$Ray_Crontab" >>$CRON_FILE
fi

cat $CRON_FILE
Expand All @@ -57,5 +60,5 @@ echo -e "[step 全部已完成]\n"

. /app/scripts/entry_after.sh

touch /var/log/cron.log #todo:debian似乎并没有记录cron的日志。。。
tail -f /var/log/cron.log # 追踪cron日志,避免当前脚本终止导致容器终止
touch /var/log/cron.log #todo:debian似乎并没有记录cron的日志。。。
tail -f /var/log/cron.log # 追踪cron日志,避免当前脚本终止导致容器终止
9 changes: 9 additions & 0 deletions qinglong/DefaultTasks/bili_task_liveFansMedal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# new Env("bili直播粉丝牌")
# cron 5 0 * * * bili_task_liveFansMedal.sh
. bili_task_base.sh

cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=LiveFansMedal && \
dotnet run --ENVIRONMENT=Production
9 changes: 9 additions & 0 deletions qinglong/DefaultTasks/dev/bili_dev_task_liveFansMedal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# new Env("bili直播粉丝牌[dev先行版]")
# cron 5 0 * * * bili_dev_task_liveFansMedal.sh
. bili_dev_task_base.sh

cd ./src/Ray.BiliBiliTool.Console

export Ray_RunTasks=LiveFansMedal && \
dotnet run --ENVIRONMENT=Production
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos
{
public class GetSpaceInfoResponse
{
public int Mid { get; set; }

public string Name { get; set; }

public SpaceLiveRoomInfoDto Live_room { get; set; }
}

public class SpaceLiveRoomInfoDto
{
public string Title { get; set; }

public int Roomid { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Newtonsoft.Json;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class EnterRoomRequest
{
public EnterRoomRequest(
int roomId,
int parentId,
int areaID,
int seqNumber, // 心跳包编号
long timestamp,
string userAgent,
string csrf,
int ruid,
string device)
{
Id = JsonConvert.SerializeObject(new[] { parentId, areaID, seqNumber, roomId });
Ts = timestamp;
Ua = userAgent;
Csrf = csrf;
Ruid = ruid;

Is_patch = 0;
Heart_beat = "[]";
Visit_id = "";
Device = device;
}
public string Id { get; set; }

public int Ruid { get; set; }

public long Ts { get; set; }

public int Is_patch { get; set; }

public string Heart_beat { get; set; }

public string Ua { get; set; }

public string Csrf_token => Csrf;

public string Csrf { get; set; }

public string Visit_id { get; set; }

public string Device { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 GetLiveRoomInfoResponse
{
public int Room_id { get; set; }

public int Area_id { get; set; }

public int Parent_area_id { get; set; }

public int Uid { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Utils;
using System;
using System.Collections.Generic;
using System.Text.Json;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.Live
{
public class HeartBeatRequest
{
public HeartBeatRequest(
int roomId,
int parentId,
int areaID,
int seqNumber, // 心跳包编号
string buvid, // cookie['LIVE_BUVID']
long timestamp,
long ets, // 由后端返回的 timestamp
string userAgent,
ICollection<int> secretRule,
string secretKey,
string csrf,
string uuid,
string device)
{
Id = JsonSerializer.Serialize(new[] { parentId, areaID, seqNumber, roomId });
Ets = ets;
Benchmark = secretKey;
Time = 60;
Ts = timestamp;
Ua = userAgent;
Csrf = csrf;
Device = device;

// 构造哈希值
var json = new
{
platform = "web",
parent_id = parentId,
area_id = areaID,
seq_id = seqNumber,
room_id = roomId,
buvid,
uuid,
ets,
time = 60,
ts = timestamp,
};
string jsonString = JsonSerializer.Serialize(json);
this.S = LiveHeartBeatCrypto.Sypder(jsonString, secretRule, secretKey);

this.Visit_id = "";
}

public string S { get; set; }

public string Id { get; set; }

public long Ets { get; set; }

public string Benchmark { get; set; }

public long Time { get; set; }

public long Ts { get; set; }

public string Ua { get; set; }

public string Csrf_token => Csrf;

public string Csrf { get; set; }

public string Visit_id { get; set; }

public string Device { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 HeartBeatResponse
{
public int Heartbeat_interval { get; set; }

public string Secret_key { get; set; }

public List<int> Secret_rule { get; set;}

public long Timestamp { get; set; }
}
}
Loading

0 comments on commit a2803da

Please sign in to comment.