diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 5ffeae35..59c33b3c 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -851,43 +851,51 @@ public void InitializePlayInfo(List playInfos, int index) private List FilterFrostDanmaku(IEnumerable danmakus) { - var needDistinct = DanmuSettingMerge.IsOn; - var level = DanmuSettingShieldLevel.Value; - var max = Convert.ToInt32(DanmuSettingMaxNum.Value); - //云屏蔽 - danmakus = danmakus.Where(x => x.Weight >= level); - //去重 - danmakus = danmakus.DistinctIf(needDistinct, new CompareDanmakuItem()); - - //关键词 - foreach (var item in settingVM.ShieldWords) - { - danmakus = danmakus.Where(x => !x.Text.Contains(item)); - } - //用户 - foreach (var item in settingVM.ShieldUsers) - { - danmakus = danmakus.Where(x => !x.MidHash.Equals(item)); - } - //正则 - foreach (var item in settingVM.ShieldRegulars) + try { - danmakus = danmakus.Where(x => !Regex.IsMatch(x.Text, item)); - } + var needDistinct = DanmuSettingMerge.IsOn; + var level = DanmuSettingShieldLevel.Value; + var max = Convert.ToInt32(DanmuSettingMaxNum.Value); + //云屏蔽 + danmakus = danmakus.Where(x => x.Weight >= level); + //去重 + danmakus = danmakus.DistinctIf(needDistinct, new CompareDanmakuItem()); - // 同屏密度 - if (max > 0) - { - // 弹幕按每秒分组,每组取前x项 - danmakus = danmakus.GroupBy(x => (x.StartMs / 1000) * 1000) - .ToDictionary(x => (int)x.Key, x => x.ToList()) - .SelectMany(x => x.Value.Take(max)); - } + //关键词 + foreach (var item in settingVM.ShieldWords) + { + danmakus = danmakus.Where(x => !x.Text.Contains(item)); + } + //用户 + foreach (var item in settingVM.ShieldUsers) + { + danmakus = danmakus.Where(x => !x.MidHash.Equals(item)); + } + //正则 + foreach (var item in settingVM.ShieldRegulars) + { + danmakus = danmakus.Where(x => !Regex.IsMatch(x.Text, item)); + } + + // 同屏密度 + if (max > 0) + { + // 弹幕按每秒分组,每组取前x项 + danmakus = danmakus.GroupBy(x => (x.StartMs / 1000) * 1000) + .ToDictionary(x => (int)x.Key, x => x.ToList()) + .SelectMany(x => x.Value.Take(max)); + } - // 移除当前播放时间之前的弹幕,避免弹幕堆叠 - danmakus = danmakus.Where(x => x.StartMs > Player.Position * 1000); + // 移除当前播放时间之前的弹幕,避免弹幕堆叠 + danmakus = danmakus.Where(x => x.StartMs > Player.Position * 1000); - return danmakus.ToList(); + return danmakus.ToList(); + } + catch (Exception ex) + { + _logger.Error("弹幕筛选错误:" + ex.Message, ex); + return new List(); + } } private async Task SelectNsDanmakuAndLoad(int position, double level, bool needDistinct, int max) @@ -929,8 +937,9 @@ private async Task SelectNsDanmakuAndLoad(int position, double level, bool needD data = null; } } - catch (Exception) + catch (Exception ex) { + _logger.Error("弹幕筛选错误:" + ex.Message, ex); } }