Skip to content

Commit

Permalink
Merge branch 'release/0.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed Feb 12, 2023
2 parents 185f4bd + 7ae8109 commit 6c5f95d
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
ghcrTagWithVersion="${{ env.GHC_IMG_NAME }}:$targetVersion"
dockerTagWithLatest=""
ghcrTagWithLatest=""
if [ "${{ github.event.inputs.autoWithLatestTag }}" == "true" ] ; then
if [ "${{ github.event.inputs.autoWithLatestTag }}" == "true" ] || [ ${{ github.event.release.created_at }} ]; then
dockerTagWithLatest="$dockerImage:latest"
ghcrTagWithLatest="$ghcrImage:latest"
fi
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,8 @@
## 0.4.2
- Merfe PRs #425 #426 #427 : Enhancement docker things, thx @zclkkk
## 0.4.3
- Feature #419 : Add a auto shell script for install with docker
- Feature #396 : Publish docker image to GitHub pkg
- Feature #419 : Add a auto shell script for installing with docker
- Feature #396 : Publish docker image to GitHub pkg
## 0.4.4
- Fix #228 : Try to fix sharing video error
- Feature: Change default docker image from dockerhub to github
2 changes: 1 addition & 1 deletion Ray.BiliBiliTool.sln
Original file line number Diff line number Diff line change
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} = {120917DC-474C-448B-9EBB-1B3BA3A20B9D}
{110D3D21-8E9B-45AB-9667-6DA1DB3862AC} = {AF21E067-3307-4E7F-8CE8-C695E6B61876}
{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.4.3</Version>
<Version>0.4.4</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
11 changes: 7 additions & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ docker compose pull && docker compose up -d

```
# 生成并运行容器
docker pull zai7lou/bilibili_tool_pro
docker pull ghcr.io/raywangqvq/bilibili_tool_pro
docker run -d --name="bili" \
-v /bili/Logs:/app/Logs \
-e Ray_DailyTaskConfig__Cron="0 15 * * *" \
-e Ray_LiveLotteryTaskConfig__Cron="0 22 * * *" \
-e Ray_UnfollowBatchedTaskConfig__Cron="0 6 1 * *" \
-e Ray_VipBigPointConfig__Cron="7 1 * * *" \
zai7lou/bilibili_tool_pro
ghcr.io/raywangqvq/bilibili_tool_pro
# 查看实时日志
docker logs -f bili
Expand Down Expand Up @@ -141,7 +141,10 @@ docker run --rm \

## 6. 自己构建镜像(非必须)

目前我提供和维护的镜像:`[zai7lou/bilibili_tool_pro](https://hub.docker.com/repository/docker/zai7lou/bilibili_tool_pro)`;
目前我提供和维护的镜像:

- DockerHub: `[zai7lou/bilibili_tool_pro](https://hub.docker.com/repository/docker/zai7lou/bilibili_tool_pro)`
- GitHub: `[bilibili_tool_pro](https://github.com/RayWangQvQ/BiliBiliToolPro/pkgs/container/bilibili_tool_pro)`

如果有需要(大部分都不需要),可以使用源码自己构建镜像,如下:

Expand All @@ -159,4 +162,4 @@ docker run --rm \

apt-get 包源用的国内网易的

如果下载github资源有问题,可以尝试添加或删除代理url`https://ghproxy.com/`
如果下载`github`资源有问题,可以尝试添加或删除代理url`https://ghproxy.com/`
12 changes: 6 additions & 6 deletions docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
###
# @Author: Ray [email protected]
# @Date: 2023-02-11 23:13:19
# @LastEditors: Ray [email protected]
# @LastEditTime: 2023-02-12 02:48:22
# @LastEditors: Ray [email protected]
# @LastEditTime: 2023-02-12 18:30:10
# @FilePath: \BiliBiliToolPro\docker\install.sh
# @Description:
###
Expand Down Expand Up @@ -90,10 +90,10 @@ runContainer() {
} || {
docker pull zai7lou/bilibili_tool_pro
docker run -d --name="bili" \
-v $base_dir/Logs:/app/Logs \
-v $base_dir/appsettings.json:/app/appsettings.json \
-v $base_dir/cookies.json:/app/cookies.json \
zai7lou/bilibili_tool_pro
-v $base_dir/Logs:/app/Logs \
-v $base_dir/appsettings.json:/app/appsettings.json \
-v $base_dir/cookies.json:/app/cookies.json \
ghcr.io/raywangqvq/bilibili_tool_pro
} || {
say_err "创建容器失败,请检查"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion docker/sample/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'
services:
bilibili_tool:
image: zai7lou/bilibili_tool_pro
image: ghcr.io/raywangqvq/bilibili_tool_pro
container_name: bili
restart: unless-stopped
tty: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos
{
Expand All @@ -17,5 +13,13 @@ public ShareVideoRequest(long aid, string csrf)
public long Aid { get; set; }

public string Csrf { get; set; }

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

public string Ramval { get; set; } = $"{new Random().Next(3, 20)}";

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 @@ -16,9 +16,8 @@ public interface IVideoApi : IBiliBiliApi
/// 分享视频
/// </summary>
/// <param name="request"></param>
/// <remarks>ck中必须要有buvid3,否则几率性-403</remarks>
/// <returns></returns>
[Header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")]
[Header("Referer", "https://www.bilibili.com/")]
[Header("Origin", "https://www.bilibili.com")]
[HttpPost("/x/web-interface/share/add")]
Task<BiliApiResponse> ShareVideo([FormContent] ShareVideoRequest request);
Expand Down
15 changes: 12 additions & 3 deletions src/Ray.BiliBiliTool.Agent/BiliCookie.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net.Http.Headers;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Ray.BiliBiliTool.Config;
using Ray.BiliBiliTool.Infrastructure;
using Ray.BiliBiliTool.Infrastructure.Cookie;

namespace Ray.BiliBiliTool.Agent
{
Expand Down Expand Up @@ -106,9 +106,18 @@ public override void Check()

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

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static IServiceCollection AddBiliBiliClientApi<TInterface>(this IService
httpClientBuilder.ConfigureHttpClient((sp, c) =>
{
var ck = sp.GetRequiredService<BiliCookie>();
c.DefaultRequestHeaders.Add("Cookie", ck.CookieStr);
c.DefaultRequestHeaders.Add("Cookie", ck.ToString());
});

return services;
Expand Down
1 change: 0 additions & 1 deletion src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos;
Expand Down
9 changes: 5 additions & 4 deletions src/Ray.BiliBiliTool.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
Expand All @@ -18,21 +17,23 @@ namespace Ray.BiliBiliTool.Console
{
public class Program
{
public static void Main(string[] args)
public static async Task<int> Main(string[] args)
{
IHost host = CreateHost(args);

try
{
host.Run();
await host.RunAsync();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
await Log.CloseAndFlushAsync();
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/Ray.BiliBiliTool.Console/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
//Cookie集合,取自浏览器,必填
"BiliBiliCookies": [ //Cookie字符串集合,登录bilibili后F12获取,形如"_uuid=abcd; buvid3=1234; sid=abc123"
""
],

"RunTasks": "Daily", //要运行的任务名称[Daily,LiveLottery,UnfollowBatched,VipBigPoint,Test],多个使用&分隔,如“Daily&LiveLottery”,建议使用命令行参数指定

//程序自定义个性化配置
Expand Down Expand Up @@ -56,7 +51,7 @@
"RandomSleepMaxMin": 10, //随机睡眠的最大时长(单位为分钟),用于使每天运行时间在范围内相对随机,值域[0,+];配置为0表示不进行休眠
"IntervalSecondsBetweenRequestApi": 20, //两次调用api之间的间隔[0,+](单位为秒)。因为有人担心在几秒内连续调用api会被b站安全机制发现,所以为不放心的朋友添加了间隔秒数配置,两次连续调用Api之间会大于该秒数
"IntervalMethodTypes": "GET,POST", //间隔秒数所针对的HttpMethod,多个用英文逗号隔开,当前有GET和POST两种,可配置如“GET,POST”
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55", //请求B站接口时头部传递的User-Agent
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41", //请求B站接口时头部传递的User-Agent
"WebProxy": "" //代理,user:password@host:port
},

Expand Down
5 changes: 1 addition & 4 deletions src/Ray.BiliBiliTool.DomainService/LiveDomainService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Timers;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
Expand All @@ -16,7 +13,7 @@
using Ray.BiliBiliTool.Config.Options;
using Ray.BiliBiliTool.DomainService.Dtos;
using Ray.BiliBiliTool.DomainService.Interfaces;
using Ray.BiliBiliTool.Infrastructure;
using Ray.BiliBiliTool.Infrastructure.Cookie;

namespace Ray.BiliBiliTool.DomainService
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ray.BiliBiliTool.DomainService/VideoDomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void WatchVideo(VideoInfoDto videoInfo)
/// <summary>
/// 分享视频
/// </summary>
/// <param name="aid">视频aid</param>
/// <param name="videoInfo">视频</param>
public void ShareVideo(VideoInfoDto videoInfo)
{
var request = new ShareVideoRequest(long.Parse(videoInfo.Aid), _biliBiliCookie.BiliJct);
Expand Down
5 changes: 1 addition & 4 deletions src/Ray.BiliBiliTool.Infrastructure/Cookie/CookieInfo.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Ray.BiliBiliTool.Infrastructure
namespace Ray.BiliBiliTool.Infrastructure.Cookie
{
public class CookieInfo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Serilog.Core;
using Serilog.Debugging;
using Serilog.Events;
Expand Down Expand Up @@ -100,7 +99,7 @@ protected virtual void EmitBatch(IEnumerable<LogEvent> events, string pushTitle

protected abstract PushService PushService { get; }

protected virtual void PushMessage(string message, string title = "BiliBiliTool任务推送")
protected virtual void PushMessage(string message, string title = "Bili推送")
{
//SelfLog.WriteLine($"Trying to send message: '{message}'.");
var result = PushService.PushMessage(message, title);
Expand Down Expand Up @@ -178,7 +177,7 @@ protected virtual string GetEmoji(LogEvent log)

protected virtual string GetPushTitle(LogEvent triggerLogEvent)
{
var title = "BiliBiliTool推送";
var title = "Bili";

var msg = RenderMessage(triggerLogEvent).Replace(Environment.NewLine, "");
var list = msg.Split('·').ToList();
Expand Down

0 comments on commit 6c5f95d

Please sign in to comment.