支持过滤房间ID,用户信息添加头像地址,用户主页ID,粉丝团信息数据。
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
<configuration>
|
||||
<!--配置更改后重启才能生效-->
|
||||
<appSettings>
|
||||
|
||||
<!--过滤Websocket数据源进程,可用','进行分隔,程序将会监听以下进程的弹幕信息-->
|
||||
<add key="processFilter" value="直播伴侣,chrome,msedge"/>
|
||||
|
||||
<!--Websocket监听端口-->
|
||||
<add key="wsListenPort" value="8888"/>
|
||||
<!--在控制台输出弹幕-->
|
||||
@@ -16,10 +18,12 @@
|
||||
<add key="filterHostName" value="true"/>
|
||||
<!--已知的弹幕域名列表 ','分隔 用作过滤规则中,凡是webcast开头的域名程序都会自动列入白名单-->
|
||||
<add key="hostNameFilter" value="
|
||||
webcast3-ws-web-hl.douyin.com,
|
||||
webcast3-ws-web-lf.douyin.com,
|
||||
webcast100-ws-web-lq.amemv.com,
|
||||
frontier-im.douyin.com,
|
||||
webcast3-ws-web-hl.douyin.com,
|
||||
webcast3-ws-web-lf.douyin.com,
|
||||
webcast100-ws-web-lq.amemv.com,
|
||||
frontier-im.douyin.com,
|
||||
"/>
|
||||
<!--要进行过滤的房间ID,不填代表监听所有,多项使用','分隔,浏览器进入直播间 F12 控制台输入 'window.localStorage.playRoom' 即可快速看到房间ID(不是地址栏中的那个) -->
|
||||
<add key="roomIds" value=""/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -25,7 +25,7 @@ namespace BarrageGrab
|
||||
PrintFilter = Enum.GetValues(typeof(BarrageMsgType)).Cast<int>().ToArray();
|
||||
FilterHostName = bool.Parse(AppSettings["filterHostName"].Trim());
|
||||
HostNameFilter = AppSettings["hostNameFilter"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).ToArray();
|
||||
//RoomIds = AppSettings["roomIds"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).Select(s => long.Parse(s)).ToArray();
|
||||
RoomIds = AppSettings["roomIds"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).Select(s => long.Parse(s)).ToArray();
|
||||
|
||||
var printFilter = AppSettings["printFilter"].Trim().ToLower();
|
||||
if (printFilter != "all")
|
||||
|
||||
@@ -73,6 +73,22 @@
|
||||
public long RoomId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 粉丝团信息
|
||||
/// </summary>
|
||||
public class FansClubInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 粉丝团名称
|
||||
/// </summary>
|
||||
public string ClubName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 粉丝团等级,没加入则0
|
||||
/// </summary>
|
||||
public int Level { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户弹幕信息
|
||||
/// </summary>
|
||||
@@ -103,6 +119,21 @@
|
||||
/// </summary>
|
||||
public int Gender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 头像地址
|
||||
/// </summary>
|
||||
public string HeadImgUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户主页地址
|
||||
/// </summary>
|
||||
public string SecUid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 粉丝团信息
|
||||
/// </summary>
|
||||
public FansClubInfo FansClub { get; set; }
|
||||
|
||||
public string GenderToString()
|
||||
{
|
||||
return Gender == 1 ? "男" : Gender == 2 ? "女" : "妖";
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BarrageGrab.ProtoEntity
|
||||
{
|
||||
#pragma warning disable CS0612, CS0618, CS1591, CS3021, IDE0079, IDE1006, RCS1036, RCS1057, RCS1085, RCS1192
|
||||
@@ -1017,6 +1019,17 @@ namespace BarrageGrab.ProtoEntity
|
||||
[global::System.ComponentModel.DefaultValue("")]
|
||||
public string displayId { get; set; } = "";
|
||||
|
||||
[global::ProtoBuf.ProtoMember(39)]
|
||||
[global::System.ComponentModel.DefaultValue("")]
|
||||
public string verified_content { get; set; } = "";
|
||||
|
||||
[global::ProtoBuf.ProtoMember(46)]
|
||||
[global::System.ComponentModel.DefaultValue("")]
|
||||
public string sec_uid { get; set; } = "";
|
||||
|
||||
[global::ProtoBuf.ProtoMember(47)]
|
||||
public int user_role { get; set; } = 0;
|
||||
|
||||
[global::ProtoBuf.ProtoContract()]
|
||||
public partial class UserAttr : global::ProtoBuf.IExtensible
|
||||
{
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Titanium.Web.Proxy.Http;
|
||||
|
||||
namespace BarrageGrab.Proxy.ProxyEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Http 响应事件参数
|
||||
/// </summary>
|
||||
public class HttpResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 响应对象
|
||||
/// </summary>
|
||||
public HttpWebClient HttpClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程ID
|
||||
/// </summary>
|
||||
public int ProcessID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程名
|
||||
/// </summary>
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
public string HostName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BarrageGrab.Proxy.ProxyEventArgs
|
||||
{
|
||||
public class WsMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息体
|
||||
/// </summary>
|
||||
public byte[] Payload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程ID
|
||||
/// </summary>
|
||||
public int ProcessID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程名
|
||||
/// </summary>
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
public string HostName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Fiddler;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using BarrageGrab.Proxy.ProxyEventArgs;
|
||||
|
||||
namespace BarrageGrab.Proxy
|
||||
{
|
||||
@@ -9,6 +10,8 @@ namespace BarrageGrab.Proxy
|
||||
{
|
||||
event EventHandler<WsMessageEventArgs> OnWebSocketData;
|
||||
|
||||
event EventHandler<HttpResponseEventArgs> OnResponse;
|
||||
|
||||
/// <summary>
|
||||
/// 域名过滤器
|
||||
/// </summary>
|
||||
@@ -20,27 +23,5 @@ namespace BarrageGrab.Proxy
|
||||
void Start();
|
||||
}
|
||||
|
||||
public class WsMessageEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息体
|
||||
/// </summary>
|
||||
public byte[] Payload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程ID
|
||||
/// </summary>
|
||||
public int ProcessID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进程名
|
||||
/// </summary>
|
||||
public string ProcessName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 域名
|
||||
/// </summary>
|
||||
public string HostName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using BarrageGrab.Proxy.ProxyEventArgs;
|
||||
|
||||
namespace BarrageGrab.Proxy
|
||||
{
|
||||
@@ -23,6 +24,11 @@ namespace BarrageGrab.Proxy
|
||||
/// </summary>
|
||||
public event EventHandler<WsMessageEventArgs> OnWebSocketData;
|
||||
|
||||
/// <summary>
|
||||
/// 接收到http响应事件
|
||||
/// </summary>
|
||||
public event EventHandler<HttpResponseEventArgs> OnResponse;
|
||||
|
||||
/// <summary>
|
||||
/// 代理端口
|
||||
/// </summary>
|
||||
@@ -57,6 +63,15 @@ namespace BarrageGrab.Proxy
|
||||
OnWebSocketData?.Invoke(this, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发http响应事件
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
protected void FireOnResponse(HttpResponseEventArgs args)
|
||||
{
|
||||
OnResponse?.Invoke(this, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取进程名称
|
||||
/// </summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BarrageGrab.Proxy.ProxyEventArgs;
|
||||
using Microsoft.Win32;
|
||||
using Titanium.Web.Proxy;
|
||||
using Titanium.Web.Proxy.EventArguments;
|
||||
@@ -43,12 +44,28 @@ namespace BarrageGrab.Proxy
|
||||
|
||||
proxyServer.ServerCertificateValidationCallback += ProxyServer_ServerCertificateValidationCallback; ;
|
||||
proxyServer.BeforeResponse += ProxyServer_BeforeResponse;
|
||||
proxyServer.AfterResponse += ProxyServer_AfterResponse;
|
||||
|
||||
explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, ProxyPort, true);
|
||||
explicitEndPoint.BeforeTunnelConnectRequest += ExplicitEndPoint_BeforeTunnelConnectRequest;
|
||||
proxyServer.AddEndPoint(explicitEndPoint);
|
||||
}
|
||||
|
||||
private Task ProxyServer_AfterResponse(object sender, SessionEventArgs e)
|
||||
{
|
||||
string hostname = e.HttpClient.Request.RequestUri.Host;
|
||||
var processid = e.HttpClient.ProcessId.Value;
|
||||
|
||||
this.FireOnResponse(new HttpResponseEventArgs()
|
||||
{
|
||||
ProcessID = processid,
|
||||
HostName = hostname,
|
||||
ProcessName = base.GetProcessName(processid),
|
||||
HttpClient = e.HttpClient
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task ProxyServer_ServerCertificateValidationCallback(object sender, CertificateValidationEventArgs e)
|
||||
{
|
||||
@@ -60,7 +77,6 @@ namespace BarrageGrab.Proxy
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
private async Task ProxyServer_BeforeResponse(object sender, SessionEventArgs e)
|
||||
{
|
||||
string hostname = e.HttpClient.Request.RequestUri.Host;
|
||||
|
||||
@@ -65,8 +65,19 @@ namespace BarrageGrab
|
||||
Gender = data.Gender,
|
||||
Id = data.Id,
|
||||
Level = data.Level,
|
||||
Nickname = data.Nickname
|
||||
Nickname = data.Nickname,
|
||||
HeadImgUrl = data.avatarThumb.urlLists.FirstOrDefault()??"",
|
||||
SecUid = data.sec_uid
|
||||
};
|
||||
if (data.fansClub.Data != null)
|
||||
{
|
||||
user.FansClub = new FansClubInfo()
|
||||
{
|
||||
ClubName = data.fansClub.Data.clubName,
|
||||
Level = data.fansClub.Data.Level
|
||||
};
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using BarrageGrab.ProtoEntity;
|
||||
using ProtoBuf;
|
||||
using ColorConsole;
|
||||
using BarrageGrab.Proxy;
|
||||
using BarrageGrab.Proxy.ProxyEventArgs;
|
||||
|
||||
namespace BarrageGrab
|
||||
{
|
||||
@@ -70,7 +71,7 @@ namespace BarrageGrab
|
||||
public WssBarrageGrab()
|
||||
{
|
||||
proxy.OnWebSocketData += Proxy_OnWebSocketData;
|
||||
proxy.HostNameFilter = HostNameChecker;
|
||||
proxy.HostNameFilter = HostNameChecker;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@@ -83,7 +84,6 @@ namespace BarrageGrab
|
||||
proxy.Dispose();
|
||||
}
|
||||
|
||||
|
||||
//域名过滤器
|
||||
private bool HostNameChecker(string hostName)
|
||||
{
|
||||
@@ -122,7 +122,6 @@ namespace BarrageGrab
|
||||
if (buff.Length == 0) return;
|
||||
if (buff[0] != 0x08) return;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var enty = Serializer.Deserialize<WssResponse>(new ReadOnlyMemory<byte>(buff));
|
||||
@@ -147,6 +146,8 @@ namespace BarrageGrab
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
//发送事件
|
||||
private void DoMessage(Message msg)
|
||||
{
|
||||
|
||||
@@ -117,6 +117,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Appsetting.cs" />
|
||||
<Compile Include="Proxy\EventArgs\HttpResponseEventArgs.cs" />
|
||||
<Compile Include="Proxy\EventArgs\WsMessageEventArgs.cs" />
|
||||
<Compile Include="Proxy\ISystemProxy.cs" />
|
||||
<Compile Include="JsonEntity\BarrageMessages.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
|
||||
@@ -323,6 +323,8 @@ message User{
|
||||
AnchorInfo anchorInfo = 36;
|
||||
int32 linkMicStats = 37;
|
||||
string displayId = 38;
|
||||
string sec_uid = 46; //用户主页ID
|
||||
int32 user_role = 47; //用户角色
|
||||
|
||||
message UserAttr {
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ VisualStudioVersion = 17.2.32408.312
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WssBarrageService", "BarrageGrab\WssBarrageService.csproj", "{A07BB1DA-D5C2-4EEA-9F3F-E42AADB9C1D6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiddlerCore4", "FiddlerCore4\FiddlerCore4.csproj", "{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -23,14 +21,6 @@ Global
|
||||
{A07BB1DA-D5C2-4EEA-9F3F-E42AADB9C1D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A07BB1DA-D5C2-4EEA-9F3F-E42AADB9C1D6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A07BB1DA-D5C2-4EEA-9F3F-E42AADB9C1D6}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6E137484-17DC-4AB2-A1BB-2E6E050A9F54}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user