copy pdb on build
fix crash
log sort room
update text on settings page
add betaid as userid
change log file name
change log level
This commit is contained in:
Genteure 2020-12-19 17:27:45 +08:00
parent b787fbda02
commit 0344adfa32
14 changed files with 115 additions and 32 deletions

View File

@ -120,7 +120,7 @@ namespace BililiveRecorder.Core
return distinct[random.Next(distinct.Length)];
}
}
throw new Exception("没有直播播放地址");
return null;
}
/// <summary>

View File

@ -14,7 +14,7 @@
<OldToolsVersion>2.0</OldToolsVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PropertyGroup>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

View File

@ -281,17 +281,24 @@ namespace BililiveRecorder.Core
{
if (IsRecording)
{
logger.Log(RoomId, LogLevel.Debug, "已经在录制中了");
// TODO: 这里逻辑可能有问题StartupTask 会变成当前这个已经结束的
logger.Log(RoomId, LogLevel.Warn, "已经在录制中了");
return;
}
// HttpWebRequest request = null;
cancellationTokenSource = new CancellationTokenSource();
var token = cancellationTokenSource.Token;
try
{
string flv_path = await BililiveAPI.GetPlayUrlAsync(RoomId);
var flv_path = await BililiveAPI.GetPlayUrlAsync(RoomId);
if (string.IsNullOrWhiteSpace(flv_path))
{
if (_retry)
{
StreamMonitor.Check(TriggerType.HttpApiRecheck, (int)_config.TimingStreamRetry);
}
return;
}
unwrap_redir:

View File

@ -13,7 +13,7 @@
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PropertyGroup>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

View File

@ -83,6 +83,10 @@ namespace BililiveRecorder.FlvProcessor
}
Tags.Clear();
}
catch (IOException ex)
{
logger.Warn(ex, "保存剪辑文件时出错");
}
catch (Exception ex)
{
logger.Error(ex, "保存剪辑文件时出错");

View File

@ -1,4 +1,4 @@
using NLog;
using NLog;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -384,6 +384,10 @@ namespace BililiveRecorder.FlvProcessor
_targetFile?.Seek(13 + 11, SeekOrigin.Begin);
_targetFile?.Write(metadata, 0, metadata.Length);
}
catch (IOException ex)
{
logger.Warn(ex, "保存录制文件时出错");
}
catch (Exception ex)
{
logger.Error(ex, "保存录制文件时出错");

View File

@ -29,7 +29,6 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowedReferenceRelatedFileExtensions>-</AllowedReferenceRelatedFileExtensions>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>full</DebugType>
<Optimize>true</Optimize>

View File

@ -9,8 +9,8 @@
<target name="WPFLogger" xsi:type="MethodCall" className="BililiveRecorder.WPF.Models.LogModel, BililiveRecorder.WPF" methodName="AddLog">
<parameter layout="[${date:format=HH\:mm\:ss}] ${level:upperCase=true} ${event-properties:item=roomid} ${message} ${exception:format=Message}" />
</target>
<target name="file" xsi:type="File" encoding="utf-8" lineEnding="CRLF" fileName="logs/log.txt"
maxArchiveFiles="15" archiveFileName="logs/log_archive.{#}.txt" archiveNumbering="Date"
<target name="file" xsi:type="File" encoding="utf-8" lineEnding="CRLF" fileName="${basedir}/logs/log.current.txt"
maxArchiveFiles="15" archiveFileName="${basedir}/logs/log.{#}.txt" archiveNumbering="Date"
archiveEvery="Day" archiveDateFormat="yyyyMMdd">
<layout xsi:type="JsonLayout">
<attribute name='time' layout='${longdate}'/>

View File

@ -18,9 +18,11 @@ namespace BililiveRecorder.WPF
Title = "B站录播姬 " + BuildInfo.Version + " " + BuildInfo.HeadShaShort;
SingleInstance.NotificationReceived += (sender, e) => SuperActivateAction();
SingleInstance.NotificationReceived += SingleInstance_NotificationReceived;
}
private void SingleInstance_NotificationReceived(object sender, EventArgs e) => SuperActivateAction();
public event EventHandler NativeBeforeWindowClose;
internal Action<string, string, BalloonIcon> ShowBalloonTipCallback { get; set; }
@ -33,12 +35,17 @@ namespace BililiveRecorder.WPF
internal void SuperActivateAction()
{
Show();
WindowState = WindowState.Normal;
Topmost = true;
Activate();
Topmost = false;
Focus();
try
{
Show();
WindowState = WindowState.Normal;
Topmost = true;
Activate();
Topmost = false;
Focus();
}
catch (Exception)
{ }
}
private void Window_StateChanged(object sender, EventArgs e)
@ -81,6 +88,7 @@ namespace BililiveRecorder.WPF
}
else
{
SingleInstance.NotificationReceived -= SingleInstance_NotificationReceived;
NativeBeforeWindowClose?.Invoke(this, EventArgs.Empty);
return;
}

View File

@ -9,8 +9,8 @@
<target name="WPFLogger" xsi:type="MethodCall" className="BililiveRecorder.WPF.Models.LogModel, BililiveRecorder.WPF" methodName="AddLog">
<parameter layout="[${date:format=HH\:mm\:ss}] ${level:upperCase=true} ${event-properties:item=roomid} ${message} ${exception:format=Message}" />
</target>
<target name="file" xsi:type="File" encoding="utf-8" lineEnding="CRLF" fileName="logs/log.txt"
maxArchiveFiles="15" archiveFileName="logs/log_archive.{#}.txt" archiveNumbering="Date"
<target name="file" xsi:type="File" encoding="utf-8" lineEnding="CRLF" fileName="${basedir}/logs/log.current.txt"
maxArchiveFiles="15" archiveFileName="${basedir}/logs/log.{#}.txt" archiveNumbering="Date"
archiveEvery="Day" archiveDateFormat="yyyyMMdd">
<layout xsi:type="JsonLayout">
<attribute name='time' layout='${longdate}'/>

View File

@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
@ -11,6 +13,7 @@ using System.Windows.Controls;
using BililiveRecorder.Core;
using BililiveRecorder.WPF.Controls;
using ModernWpf.Controls;
using NLog;
namespace BililiveRecorder.WPF.Pages
{
@ -191,6 +194,8 @@ namespace BililiveRecorder.WPF.Pages
internal class SortedItemsSourceView : IList, IReadOnlyList<IRecordedRoom>, IKeyIndexMapping, INotifyCollectionChanged
{
private static Logger logger = LogManager.GetCurrentClassLogger();
private ICollection<IRecordedRoom> _data;
private SortedBy sortedBy;
@ -235,9 +240,12 @@ namespace BililiveRecorder.WPF.Pages
private void Sort()
{
logger.Debug("Sort called with {sortedBy} and {count} rooms.", SortedBy, Data?.Count ?? -1);
if (Data is null)
{
Sorted = NullRoom.ToList();
logger.Debug("Sort returned NullRoom.");
}
else
{
@ -247,7 +255,41 @@ namespace BililiveRecorder.WPF.Pages
SortedBy.Status => Data.OrderByDescending(x => x.IsRecording).ThenByDescending(x => x.IsMonitoring),
_ => Data,
};
Sorted = orderedData.Concat(NullRoom).ToList();
var result = orderedData.Concat(NullRoom).ToList();
logger.Debug("Sorted with {count} items.", result.Count);
{ // 崩溃问题信息收集。。虽然不觉得是这里的问题
var dup = result.GroupBy(x => x?.Guid ?? Guid.Empty).Where(x => x.Count() != 1);
if (dup.Any())
{
var sb = new StringBuilder("排序调试信息\n重复:\n");
foreach (var item in dup)
{
sb.Append("-Guid: ");
sb.AppendLine(item.Key.ToString());
foreach (var room in item)
{
sb.Append("RoomId: ");
sb.AppendLine(room?.RoomId.ToString());
}
}
sb.Append("原始:");
foreach (var room in result)
{
sb.Append("-Guid: ");
sb.AppendLine((room?.Guid ?? Guid.Empty).ToString());
sb.Append("RoomId: ");
sb.AppendLine(room?.RoomId.ToString());
}
logger.Debug(sb.ToString());
// trigger sentry
logger.Error(new SortedItemsSourceViewException(), "排序房间时发生了错误");
return;
}
}
Sorted = result;
}
// Instead of tossing out existing elements and re-creating them,
@ -356,7 +398,13 @@ namespace BililiveRecorder.WPF.Pages
}
#endregion
public class SortedItemsSourceViewException : Exception
{
public SortedItemsSourceViewException() { }
public SortedItemsSourceViewException(string message) : base(message) { }
public SortedItemsSourceViewException(string message, Exception innerException) : base(message, innerException) { }
protected SortedItemsSourceViewException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
}

View File

@ -23,16 +23,16 @@
<TextBlock Text="设置" Style="{StaticResource TitleTextBlockStyle}" FontFamily="Microsoft Yahei" Margin="0,10"/>
<GroupBox Header="弹幕录制">
<StackPanel>
<ui:ToggleSwitch IsOn="{Binding RecordDanmaku}" Name="RecordDanmakuCheckbox" OnContent="录播时保存弹幕" OffContent="录播时不保存弹幕"/>
<ui:ToggleSwitch IsOn="{Binding RecordDanmaku}" Name="RecordDanmakuCheckbox" OnContent="保存弹幕&#160;&#160;(当前为保存)" OffContent="不保存弹幕(当前为不保存)"/>
<StackPanel Margin="0,7,0,0" Visibility="{Binding ElementName=RecordDanmakuCheckbox,Path=IsOn,Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuRaw}"
OnContent="同时保存 弹幕原始数据" OffContent="不保存 弹幕原始数据"/>
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuSuperChat}"
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuSuperChat}"
OnContent="同时保存 SuperChat" OffContent="不保存 SuperChat"/>
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuGift}"
OnContent="同时保存 送礼信息" OffContent="不保存 送礼信息"/>
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuGuard}"
OnContent="同时保存 舰长购买" OffContent="不保存 舰长购买"/>
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuGift}"
OnContent="同时保存 送礼信息" OffContent="不保存 送礼信息"/>
<ui:ToggleSwitch IsEnabled="{Binding RecordDanmaku}" IsOn="{Binding RecordDanmakuRaw}"
OnContent="同时保存 弹幕原始数据" OffContent="不保存 弹幕原始数据"/>
</StackPanel>
</StackPanel>
</GroupBox>

View File

@ -34,6 +34,19 @@ namespace BililiveRecorder.WPF
o.AddExceptionFilterForType<System.Net.Http.HttpRequestException>();
}))
{
SentrySdk.ConfigureScope(s =>
{
try
{
var path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "..", "packages", ".betaId"));
if (!File.Exists(path)) return;
var content = File.ReadAllText(path);
if (Guid.TryParse(content, out var id))
s.User = new Sentry.Protocol.User { Id = id.ToString() };
}
catch (Exception) { }
});
var app = new App();
app.InitializeComponent();
app.DispatcherUnhandledException += App_DispatcherUnhandledException;

View File

@ -53,14 +53,14 @@ namespace BililiveRecorder.WPF
public static void Cleanup()
{
singleInstanceMutex?.Close();
singleInstanceMutex = null;
if (channel != null)
{
ChannelServices.UnregisterChannel(channel);
channel = null;
}
singleInstanceMutex?.Close();
singleInstanceMutex = null;
}
private static void ActivateFirstInstanceCallback() => NotificationReceived?.Invoke(null, EventArgs.Empty);