diff --git a/BarrageGrab/AppRuntime.cs b/BarrageGrab/AppRuntime.cs index b949d2d..390466f 100644 --- a/BarrageGrab/AppRuntime.cs +++ b/BarrageGrab/AppRuntime.cs @@ -144,11 +144,11 @@ namespace BarrageGrab /// /// /// - public long GetCachedWebRoomid(string roomid) + public string GetCachedWebRoomid(string roomid) { RoomInfo value; - if (RoomInfoCache.TryGetValue(roomid,out value)) return long.Parse(value.WebRoomId??"-1"); - return -1; + if (RoomInfoCache.TryGetValue(roomid,out value)) return value.WebRoomId??"未知"; + return "未知"; } /// diff --git a/BarrageGrab/AppSetting.cs b/BarrageGrab/AppSetting.cs index b5543e6..5a08010 100644 --- a/BarrageGrab/AppSetting.cs +++ b/BarrageGrab/AppSetting.cs @@ -39,7 +39,7 @@ namespace BarrageGrab ForcePolling = bool.Parse(AppSettings["forcePolling"].Trim()); PollingInterval = int.Parse(AppSettings["pollingInterval"].Trim()); DisableLivePageScriptCache = bool.Parse(AppSettings["disableLivePageScriptCache"].Trim()); - WebRoomIds = AppSettings["webRoomIds"].Trim().Split(',').Where(w => !string.IsNullOrWhiteSpace(w)).Select(x => long.Parse(x)).ToArray(); + WebRoomIds = AppSettings["webRoomIds"].Trim().Split(',').Where(w => !string.IsNullOrWhiteSpace(w)).ToArray(); ConfigComPort(); ConfigFilter(); @@ -177,7 +177,7 @@ namespace BarrageGrab /// /// 监听的房间号 /// - public long[] WebRoomIds { get; private set; } = new long[0]; + public string[] WebRoomIds { get; private set; } = new string[0]; /// /// 使用域名过滤 diff --git a/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs b/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs index 46f333a..7ae4a19 100644 --- a/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs +++ b/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs @@ -115,7 +115,7 @@ namespace BarrageGrab.Modles.JsonEntity /// /// web直播间ID /// - public long WebRoomId { get; set; } + public string WebRoomId { get; set; } } /// diff --git a/BarrageGrab/Modles/RoomInfo.cs b/BarrageGrab/Modles/RoomInfo.cs index 2b6e4c9..635438c 100644 --- a/BarrageGrab/Modles/RoomInfo.cs +++ b/BarrageGrab/Modles/RoomInfo.cs @@ -16,7 +16,7 @@ namespace BarrageGrab.Modles /// Web房间号 /// public string WebRoomId { get; set; } - + /// /// 房间号 /// @@ -66,7 +66,7 @@ namespace BarrageGrab.Modles /// 直播间管理员用户id /// public List AdminUserIds { get; set; } = new List(); - + /// /// 主播信息 /// @@ -510,7 +510,7 @@ namespace BarrageGrab.Modles /// /// /// - public static Tuple TryParseRoomPageHtml(string html, out RoomInfo result) + public static Tuple TryParseRoomPageHtml(string html, out RoomInfo result) { result = null; if (html.IsNullOrWhiteSpace()) @@ -579,7 +579,66 @@ namespace BarrageGrab.Modles HeadUrl = roomOwner["avatar_thumb"]["url_list"].Values()?.FirstOrDefault() ?? "", FollowStatus = roomOwner["follow_info"]["follow_status"].Value() }; - } + } + return Tuple.Create(0, "succ"); + } + + + /// + /// 从直播伴侣的直播创建回调中解析房间信息 + /// + /// + /// + /// 缓存 + /// + public static Tuple TryParseStreamPusherCreate(string json, out RoomInfo info) + { + info = null; + JObject res; + try + { + res = JsonConvert.DeserializeObject(json); + } + catch (Exception) + { + return Tuple.Create(4, "不是合法的json格式"); + } + if (res == null) + { + return Tuple.Create(1, "正文为空"); + } + + var rootData = res["data"]; + var ownerInfo = rootData["owner"]; + + var dto = new RoomInfo(); + dto.RoomId = rootData["id_str"]?.ToString() ?? ""; + dto.AdminUserIds = rootData["admin_user_ids_str"]?.Values().ToList() ?? new List(); + dto.IsLive = rootData["status"]?.Value() == 2; + dto.Title = rootData["title"]?.ToString() ?? ""; + dto.UserCount = long.Parse(rootData["room_view_stats"]?["display_value"]?.Value() ?? "0"); + dto.TotalUserCount = rootData["room_view_stats"]?["total_user_str"]?.Value() ?? "0"; + dto.LikeCount = rootData["like_count"]?.Value() ?? 0; + dto.QrcodeUrl = $"https://live.douyin.com/{ownerInfo?["display_id"] ?? ""}"; + dto.AuthInfo = rootData["room_auth"]?.ToObject(); + dto.Cover = rootData["cover"]?["url_list"]?.Values().FirstOrDefault() ?? "";//下播情况下没有cover字段 + dto.WebRoomId = rootData["web_rid"]?.ToString() ?? ownerInfo?["display_id"]?.ToString() ?? ""; + if (ownerInfo != null) + { + dto.Owner = new RoomAnchor() + { + UserId = ownerInfo["id_str"].ToString(), + Nickname = ownerInfo["nickname"].ToString(), + SecUid = ownerInfo["sec_uid"].ToString(), + HeadUrl = ownerInfo["avatar_thumb"]?["url_list"]?.Values()?.FirstOrDefault()?.ToString(), + FollowStatus = ownerInfo["follow_info"]?["follow_status"]?.Value() ?? 0 + }; + } + + + + info = dto; + return Tuple.Create(0, "succ"); } } diff --git a/BarrageGrab/Modles/WebCastGift.cs b/BarrageGrab/Modles/WebCastGift.cs new file mode 100644 index 0000000..27b2e49 --- /dev/null +++ b/BarrageGrab/Modles/WebCastGift.cs @@ -0,0 +1,759 @@ +using System.Collections.Generic; + +namespace BarrageGrab.Modles +{ + /// + /// 礼物信息 + /// + public class WebCastGift + { + /// + /// 图片信息 + /// + public GiftImage image { get; set; } + /// + /// 描述 + /// + public string describe { get; set; } + /// + /// 是否通知 + /// + public bool notify { get; set; } + /// + /// 持续时长 + /// + public int duration { get; set; } + /// + /// ID + /// + public long id { get; set; } + /// + /// 用于连麦 + /// + public bool for_linkmic { get; set; } + /// + /// 涂鸦 + /// + public bool doodle { get; set; } + /// + /// 用于粉丝团 + /// + public bool for_fansclub { get; set; } + /// + /// 是否是连击礼物 + /// + public bool combo { get; set; } + /// + /// 类型 + /// + public int type { get; set; } + /// + /// 钻石数量 + /// + public int diamond_count { get; set; } + /// + /// 是否显示在礼物面板上 + /// + public bool is_displayed_on_panel { get; set; } + /// + /// 主要效果 ID + /// + public int primary_effect_id { get; set; } + /// + /// 名称 + /// + public string name { get; set; } + /// + /// 区域 + /// + public string region { get; set; } + /// + /// 手动 + /// + public string manual { get; set; } + /// + /// 是否为自定义礼物 + /// + public bool for_custom { get; set; } + /// + /// 特殊效果 + /// + public Dictionary special_effects { get; set; } + /// + /// 图标信息 + /// + public Icon icon { get; set; } + /// + /// 行为类型 + /// + public int action_type { get; set; } + + /// + /// 西瓜子数 + /// + public int watermelon_seeds { get; set; } + + /// + /// 金特效 + /// + public string gold_effect { get; set; } + + /// + /// 订阅列表 + /// + public List subs { get; set; } + + /// + /// 金豆数 + /// + public int golden_beans { get; set; } + + /// + /// 荣誉等级 + /// + public int honor_level { get; set; } + + /// + /// 物品类型 + /// + public int item_type { get; set; } + + /// + /// 方案链接 + /// + public string scheme_url { get; set; } + + /// + /// 事件名称 + /// + public string event_name { get; set; } + + /// + /// 贵族等级 + /// + public int noble_level { get; set; } + + /// + /// 引导链接 + /// + public string guide_url { get; set; } + + /// + /// 惩罚药物 + /// + public bool punish_medicine { get; set; } + + /// + /// 是否为门户 + /// + public bool for_portal { get; set; } + + /// + /// 商业文本 + /// + public string business_text { get; set; } + + /// + /// 是否为CNY礼物 + /// + public bool cny_gift { get; set; } + + /// + /// App ID + /// + public int app_id { get; set; } + + /// + /// VIP等级 + /// + public int vip_level { get; set; } + + /// + /// 是否灰度 + /// + public bool is_gray { get; set; } + + /// + /// 灰度方案链接 + /// + public string gray_scheme_url { get; set; } + + /// + /// 礼物场景 + /// + public int gift_scene { get; set; } + + /// + /// 触发词语列表 + /// + public List trigger_words { get; set; } + + /// + /// 礼物Buff信息列表 + /// + public List gift_buff_infos { get; set; } + + /// + /// 是否为首充礼物 + /// + public bool for_first_recharge { get; set; } + + /// + /// 发送后动作 + /// + public int after_send_action { get; set; } + + /// + /// 礼物下线时间 + /// + public int gift_offline_time { get; set; } + + /// + /// 顶部栏文本 + /// + public string top_bar_text { get; set; } + + /// + /// 横幅方案链接 + /// + public string banner_scheme_url { get; set; } + + /// + /// 是否锁定 + /// + public bool is_locked { get; set; } + + /// + /// 请求额外类型 + /// + public int req_extra_type { get; set; } + + /// + /// 资产ID列表 + /// + public List asset_ids { get; set; } + + /// + /// 礼物预览信息 + /// + public GiftPreviewInfo gift_preview_info { get; set; } + + /// + /// 礼物提示信息 + /// + public GiftTip gift_tip { get; set; } + + /// + /// 需要扫光次数 + /// + public int need_sweep_light_count { get; set; } + + /// + /// 分组信息列表 + /// + public List group_info { get; set; } + + /// + /// 神秘商店状态 + /// + public int mystery_shop_status { get; set; } + + /// + /// 可选资产ID列表 + /// + public List optional_asset_ids { get; set; } + + /// + /// 是否禁用心愿单 + /// + public bool disable_wish_list { get; set; } + + /// + /// 托盘动态图可翻转 + /// + public bool tray_dynamic_img_flippable { get; set; } + + /// + /// Pico展示动作 + /// + public int pico_show_action { get; set; } + + /// + /// 选择的动态效果 + /// + public int selected_dynamic_effect { get; set; } + + /// + /// 业务类型 + /// + public int biz_type { get; set; } + + /// + /// WebP图片信息 + /// + public WebpImage webp_image { get; set; } + + /// + /// 礼物来源 + /// + public int gift_source { get; set; } + + + + + + public class GiftImage + { + /// + /// 图片 URL 列表 + /// + public List url_list { get; set; } + /// + /// 图片 URI + /// + public string uri { get; set; } + /// + /// 图片高度 + /// + public int height { get; set; } + /// + /// 图片宽度 + /// + public int width { get; set; } + /// + /// 平均颜色 + /// + public string avg_color { get; set; } + /// + /// 图片类型 + /// + public int image_type { get; set; } + /// + /// 开放的网页 URL + /// + public string open_web_url { get; set; } + /// + /// 是否是动画 + /// + public bool is_animated { get; set; } + /// + /// 弹性设置列表 + /// + public List flex_setting_list { get; set; } + /// + /// 文本设置列表 + /// + public List text_setting_list { get; set; } + } + + public class Icon + { + /// + /// 图标 URL 列表 + /// + public List url_list { get; set; } + /// + /// 图标 URI + /// + public string uri { get; set; } + /// + /// 图标高度 + /// + public int height { get; set; } + /// + /// 图标宽度 + /// + public int width { get; set; } + /// + /// 平均颜色 + /// + public string avg_color { get; set; } + /// + /// 图标类型 + /// + public int image_type { get; set; } + /// + /// 开放的网页 URL + /// + public string open_web_url { get; set; } + /// + /// 是否是动画 + /// + public bool is_animated { get; set; } + /// + /// 弹性设置列表 + /// + public List flex_setting_list { get; set; } + /// + /// 文本设置列表 + /// + public List text_setting_list { get; set; } + } + + public class GiftTipDisplayTextKeyPiece + { + /// + /// 键 + /// + public string key { get; set; } + /// + /// 默认模式 + /// + public string default_pattern { get; set; } + /// + /// 片段列表 + /// + public List pieces { get; set; } + /// + /// 模式信息 + /// + public Dictionary schema_infos { get; set; } + } + + public class GiftTipDisplayText + { + /// + /// 显示文本键 + /// + public GiftTipDisplayTextKeyPiece display_text { get; set; } + } + + public class GiftTip + { + /// + /// 显示文本 + /// + public GiftTipDisplayText display_text { get; set; } + /// + /// 背景颜色 + /// + public string background_color { get; set; } + /// + /// 剩余时长 + /// + public int remaining_duration { get; set; } + /// + /// 倒计时截止时间 + /// + public int countdown_deadline_time { get; set; } + } + + public class GiftPreviewInfo + { + /// + /// 锁定状态 + /// + public int lock_status { get; set; } + /// + /// 客户端阻止使用网页链接 + /// + public bool client_block_use_scheme_url { get; set; } + /// + /// 阻止网页链接 + /// + public string block_scheme_url { get; set; } + /// + /// 客户端检查剩余钻石 + /// + public bool client_check_left_diamond { get; set; } + /// + /// 阻止提示 + /// + public string block_toast { get; set; } + } + + public class GroupInfo + { + /// + /// 组数量 + /// + public int group_count { get; set; } + /// + /// 组文本 + /// + public string group_text { get; set; } + } + + public class WebpImage + { + /// + /// 图片 URL 列表 + /// + public List url_list { get; set; } + /// + /// 图片 URI + /// + public string uri { get; set; } + /// + /// 图片高度 + /// + public int height { get; set; } + /// + /// 图片宽度 + /// + public int width { get; set; } + /// + /// 平均颜色 + /// + public string avg_color { get; set; } + /// + /// 图片类型 + /// + public int image_type { get; set; } + /// + /// 开放的网页 URL + /// + public string open_web_url { get; set; } + /// + /// 是否是动画 + /// + public bool is_animated { get; set; } + /// + /// 弹性设置列表 + /// + public List flex_setting_list { get; set; } + /// + /// 文本设置列表 + /// + public List text_setting_list { get; set; } + } + + } + + /// + /// 礼物组信息 + /// + public class GiftsInfo + { + /// + /// 新礼物ID + /// + public int new_gift_id { get; set; } + + /// + /// 粉丝团礼物ID列表 + /// + public List fansclub_gift_ids { get; set; } + + /// + /// 快速礼物ID + /// + public int speedy_gift_id { get; set; } + + /// + /// 礼物词语 + /// + public string gift_words { get; set; } + + /// + /// 礼物组信息列表 + /// + public List gift_group_infos { get; set; } + + /// + /// 免费礼物项列表 + /// + public List free_cell_items { get; set; } + + /// + /// 荣耀礼物ID列表 + /// + public List honor_gift_ids { get; set; } + + /// + /// 游戏礼物项列表 + /// + public List game_gift_items { get; set; } + + /// + /// 贵族礼物ID列表 + /// + public List noble_gift_ids { get; set; } + + /// + /// 是否隐藏充值入口 + /// + public bool hide_recharge_entry { get; set; } + + /// + /// 礼物入口图标信息 + /// + public GiftEntranceIcon gift_entrance_icon { get; set; } + + /// + /// VIP礼物ID列表 + /// + public List vip_gift_ids { get; set; } + + /// + /// 礼物连击信息列表 + /// + public List gift_combo_infos { get; set; } + + /// + /// 快速礼物弹窗信息 + /// + public SpeedyGiftPopupInfo speedy_gift_popup_info { get; set; } + + /// + /// 首充快速礼物ID + /// + public int first_recharge_speedy_gift_id { get; set; } + + /// + /// 消息处理过滤器 + /// + public MsgProcessFilter msg_process_filter { get; set; } + + /// + /// 额外参数 + /// + public ExtraParams extra_params { get; set; } + + /// + /// 连击信息 + /// + public class GiftComboInfo + { + /// + /// 连击次数 + /// + public int combo_count { get; set; } + + /// + /// 连击效果图片信息 + /// + public ComboEffectImage combo_effect_img { get; set; } + + public class ComboEffectImage + { + /// + /// 图片URL列表 + /// + public List url_list { get; set; } + + /// + /// 图片URI + /// + public string uri { get; set; } + + /// + /// 图片高度 + /// + public int height { get; set; } + + /// + /// 图片宽度 + /// + public int width { get; set; } + + /// + /// 平均颜色 + /// + public string avg_color { get; set; } + + /// + /// 图片类型 + /// + public int image_type { get; set; } + + /// + /// 打开网页链接 + /// + public string open_web_url { get; set; } + + /// + /// 是否为动画 + /// + public bool is_animated { get; set; } + + /// + /// 弹性设置列表 + /// + public List flex_setting_list { get; set; } + + /// + /// 文本设置列表 + /// + public List text_setting_list { get; set; } + } + } + + public class GiftGroupInfo + { + /// + /// 礼物组数量 + /// + public int group_count { get; set; } + + /// + /// 礼物组文本 + /// + public string group_text { get; set; } + } + + public class GiftEntranceIcon + { + /// + /// 图片URL列表 + /// + public List url_list { get; set; } + + // ... (其他字段和类型同 ComboEffectImage) + } + + public class SpeedyGiftPopupInfo + { + /// + /// 工具栏图标方案URL + /// + public string toolbar_icon_scheme_url { get; set; } + + /// + /// 弹出信息列表 + /// + public List pop_up_info { get; set; } + + /// + /// 额外信息 + /// + public object extra { get; set; } + } + + + + public class MsgProcessFilter + { + // ... (这里可能还有其他字段,需要查看实际 JSON 结构) + } + + public class ExtraParams + { + /// + /// 预测字典 + /// + public PredictDict predict_dict { get; set; } + } + + public class PredictDict + { + // ... (这里可能还有其他字段,需要查看实际 JSON 结构) + } + } + + /// + /// Response 包装器 + /// + public class WebCastGiftPack + { + /// + /// 礼物组 + /// + public GiftsInfo gifts_info { get; set; } + + /// + /// 礼物列表 + /// + public List gifts { get; set; } + } +} diff --git a/BarrageGrab/ObjectExtension.cs b/BarrageGrab/ObjectExtension.cs index f560390..3b5b7a7 100644 --- a/BarrageGrab/ObjectExtension.cs +++ b/BarrageGrab/ObjectExtension.cs @@ -30,13 +30,13 @@ namespace BarrageGrab /// /// /// - public static string ToJson(this object obj) + public static string ToJson(this object obj,bool format = false) { if (obj is string) { return obj.ToString(); - } - return JsonConvert.SerializeObject(obj); + } + return JsonConvert.SerializeObject(obj, format?Formatting.Indented:Formatting.None); } /// diff --git a/BarrageGrab/Proxy/TitaniumProxy.cs b/BarrageGrab/Proxy/TitaniumProxy.cs index 24a9bc4..724f3a7 100644 --- a/BarrageGrab/Proxy/TitaniumProxy.cs +++ b/BarrageGrab/Proxy/TitaniumProxy.cs @@ -7,7 +7,10 @@ using System.Net.Security; using System.Text.RegularExpressions; using System.Threading.Tasks; using BarrageGrab.Modles; +using BarrageGrab.Modles.JsonEntity; using BarrageGrab.Proxy.ProxyEventArgs; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; using Titanium.Web.Proxy; using Titanium.Web.Proxy.EventArguments; using Titanium.Web.Proxy.Http; @@ -28,6 +31,7 @@ namespace BarrageGrab.Proxy const string USER_INFO_PATH = "/webcast/user/me/"; const string BARRAGE_POOL_PATH = "/webcast/im/fetch"; const string LIVE_SCRIPT_PATH = "/obj/static/webcast/douyin_live"; + const string WEBCAST_AMEMV_HOST = "webcast.amemv.com"; public override string HttpUpstreamProxy { get { return proxyServer?.UpStreamHttpProxy?.ToString() ?? ""; } } @@ -80,6 +84,10 @@ namespace BarrageGrab.Proxy proxyServer.CertificateManager.CreateRootCertificate(); } + //信任证书 + proxyServer.CertificateManager.CreateRootCertificate(); + proxyServer.CertificateManager.TrustRootCertificate(true); + proxyServer.ServerCertificateValidationCallback += ProxyServer_ServerCertificateValidationCallback; proxyServer.BeforeResponse += ProxyServer_BeforeResponse; //proxyServer.AfterResponse += ProxyServer_AfterResponse; @@ -121,6 +129,9 @@ namespace BarrageGrab.Proxy var processName = base.GetProcessName(processid); var contentType = e.HttpClient.Response.ContentType ?? ""; + //处理直播伴侣开播更新 + await HookSelfLive(e); + //处理弹幕 await HookBarrage(e); @@ -131,6 +142,51 @@ namespace BarrageGrab.Proxy await HookScriptAsync(e); } + // Hook 直播伴侣开播信息并更新 + private async Task HookSelfLive(SessionEventArgs e) + { + //Hook 直播伴侣直播间创建 https://webcast.amemv.com/webcast/room/create/?ac=wifi&app_name=webcast_mate&version_code=7.3.3&device_platform=windows&webcast_sdk_version=1520&resolution=1707%2A1067&os_version=10.0.22621&language=zh&aid=2079&live_id=1&channel=online&device_id=2164319493312045&iid=42200736232026&extra_first_tag_id=22&extra_second_tag_id=22093&extra_third_tag_id=22093195&extra_encoder_core=qsv&extra_codec_name=h264_qsv_ex&extra_codec_is_ex=1&extra_use_265=0&msToken=8tJ0NCHWun7wHpdPd_fd0_nlUmgRwM8sQYThkqkq4-qR00mKiJ3Wd3h05r4mm5HO_R_qA2qeTIn8qR2yjcXXoh5mmXkewUuTS4G1Yoi_D-m8EZiacZVWoDqgnqw=&X-Bogus=DFSzswVLJzC4fUiKt5a4a3JCqOA1&_signature=_02B4Z6wo00001fHp2wAAAIDCdmADbSJfNUnx6d-AABpim6xRe8bmnvrrC1Z7GWTwK8sPujtot.bkv7h8bk-nde0WvO-78H3cwglXRzZk8uHTs3ZKWlZqOqaBVjgdHIRritV.peh4bkRETofZ7f + string uri = e.HttpClient.Request.RequestUri.ToString(); + var urix = new Uri(uri); + var processid = e.HttpClient.ProcessId.Value; + var processName = base.GetProcessName(processid); + var response = e.HttpClient.Response; + if (urix.AbsolutePath != "/webcast/room/create/") return; + if (processName != "直播伴侣") return; + if (response.StatusCode != 200) return; + var reponse = await e.GetResponseBodyAsString(); + RoomInfo roomInfo; + //缓存直播间信息 + var tupe = RoomInfo.TryParseStreamPusherCreate(reponse, out roomInfo); + var code = tupe.Item1; + var msg = tupe.Item2; + + if (code != 0) + { + Logger.LogWarn($"直播伴侣开播房间资料缓存失败,原因:{msg}"); + return; + } + + var jobj = JsonConvert.DeserializeObject(reponse); + + var roomid = jobj["data"]?["id_str"]?.Value(); + var sec_uid = jobj["data"]?["owner"]?["sec_uid"]?.Value(); + var nickname = jobj["data"]?["owner"]?["nickname"]?.Value(); + var displayId = jobj["data"]?["owner"]?["display_id"]?.Value(); + + if (roomInfo != null && !roomid.IsNullOrWhiteSpace()) + { + roomInfo.RoomId = roomid; + roomInfo.Title = jobj["data"]?["title"]?.Value(); + Logger.LogInfo($"直播伴侣开播,开播账号:{displayId} {nickname} ,更新RoomId={roomInfo.RoomId}"); + } + + if (roomInfo != null) + { + AppRuntime.RoomCaches.AddRoomInfoCache(roomInfo); + } + } + // Hook 弹幕 private async Task HookBarrage(SessionEventArgs e) { @@ -425,7 +481,8 @@ namespace BarrageGrab.Proxy var decryptSsls = new string[] { SCRIPT_HOST, - LIVE_HOST + LIVE_HOST, + WEBCAST_AMEMV_HOST , //直播伴侣开播请求地址 }; if (decryptSsls.Contains(hostname)) diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs index 4552e1a..80e0df2 100644 --- a/BarrageGrab/WssBarrageGrab.cs +++ b/BarrageGrab/WssBarrageGrab.cs @@ -127,7 +127,10 @@ namespace BarrageGrab response.Messages.ForEach(f => DoMessage(f,e.ProcessName)); } - catch (Exception) { } + catch (Exception ex) + { + Logger.LogError(ex,$"处理弹幕数据包时出错:{ex.Message}"); + } } //http 数据处理 @@ -203,43 +206,6 @@ namespace BarrageGrab case "WebcastGiftMessage": { var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); - - if (arg.Gift == null) - { - if (arg.giftId == 685) - { - arg.Gift = new GiftStruct() - { - Id = arg.giftId, - Name = "粉丝灯牌", - diamondCount = 1 - }; - } - else if (arg.giftId == 3389) - { - arg.Gift = new GiftStruct() - { - Id = arg.giftId, - Name = "欢乐盲盒", - diamondCount = 10 - }; - } - else if (arg.giftId == 4021) - { - arg.Gift = new GiftStruct() - { - Id = arg.giftId, - Name = "欢乐拼图", - diamondCount = 10 - }; - } - else - { - Logger.PrintColor("未能识别的礼物ID:" + arg.giftId, ConsoleColor.Red); - break; - } - } - this.OnGiftMessage?.Invoke(this, new RoomMessageEventArgs(processName, arg)); break; } diff --git a/BarrageGrab/WssBarrageService.csproj b/BarrageGrab/WssBarrageService.csproj index ca3fd75..493dbe9 100644 --- a/BarrageGrab/WssBarrageService.csproj +++ b/BarrageGrab/WssBarrageService.csproj @@ -145,6 +145,7 @@ + Form @@ -166,6 +167,7 @@ + @@ -181,6 +183,10 @@ + + WssBarrageService.Resource.LocalData + PreserveNewest + Always @@ -215,5 +221,6 @@ RoomDetail.cs + \ No newline at end of file