mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
Minor updates
This commit is contained in:
parent
e2c1e978df
commit
97e005a4d3
|
@ -85,8 +85,8 @@ namespace BililiveRecorder.Core.Api.Http
|
||||||
var text = await resp.Content.ReadAsStringAsync().ConfigureAwait(false);
|
var text = await resp.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
var obj = JsonConvert.DeserializeObject<BilibiliApiResponse<T>>(text);
|
var obj = JsonConvert.DeserializeObject<BilibiliApiResponse<T>>(text);
|
||||||
if (obj.Code != 0)
|
if (obj?.Code != 0)
|
||||||
throw new BilibiliApiResponseCodeNotZeroException("Bilibili api code: " + (obj.Code?.ToString() ?? "(null)") + "\n" + text);
|
throw new BilibiliApiResponseCodeNotZeroException("Bilibili api code: " + (obj?.Code?.ToString() ?? "(null)") + "\n" + text);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,10 @@ namespace BililiveRecorder.Core.Config
|
||||||
#pragma warning disable CS0612
|
#pragma warning disable CS0612
|
||||||
var v1Data = JsonConvert.DeserializeObject<V1.ConfigV1>(v1.Data ?? string.Empty);
|
var v1Data = JsonConvert.DeserializeObject<V1.ConfigV1>(v1.Data ?? string.Empty);
|
||||||
#pragma warning restore CS0612
|
#pragma warning restore CS0612
|
||||||
var newConfig = ConfigMapper.Map1To2(v1Data);
|
if (v1Data is null)
|
||||||
|
return new V2.ConfigV2();
|
||||||
|
|
||||||
|
var newConfig = ConfigMapper.Map1To2(v1Data);
|
||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
case V2.ConfigV2 v2:
|
case V2.ConfigV2 v2:
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace BililiveRecorder.Core
|
||||||
durationOfBreak: TimeSpan.FromMinutes(2),
|
durationOfBreak: TimeSpan.FromMinutes(2),
|
||||||
onBreak: (_, _) =>
|
onBreak: (_, _) =>
|
||||||
{
|
{
|
||||||
logger.Warning("检测到被屏蔽,暂停发送请求");
|
logger.Warning("检测到被屏蔽(HTTP 412),暂停发送请求");
|
||||||
},
|
},
|
||||||
onReset: () =>
|
onReset: () =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,6 @@ namespace BililiveRecorder.WPF
|
||||||
|
|
||||||
private void SystemEvents_TimeChanged(object sender, System.EventArgs e) => this.loggerSystemEvents.Debug("TimeChanged");
|
private void SystemEvents_TimeChanged(object sender, System.EventArgs e) => this.loggerSystemEvents.Debug("TimeChanged");
|
||||||
|
|
||||||
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) => this.loggerSystemEvents.Warning("PowerModeChanged {Mode}", e.Mode);
|
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) => this.loggerSystemEvents.Debug("PowerModeChanged {Mode}", e.Mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,6 @@
|
||||||
<Compile Include="Converters\MultiBoolToValueConverter.cs" />
|
<Compile Include="Converters\MultiBoolToValueConverter.cs" />
|
||||||
<Compile Include="Converters\NullValueTemplateSelector.cs" />
|
<Compile Include="Converters\NullValueTemplateSelector.cs" />
|
||||||
<Compile Include="Converters\RatioToColorBrushConverter.cs" />
|
<Compile Include="Converters\RatioToColorBrushConverter.cs" />
|
||||||
<Compile Include="Converters\RoomListInterceptConverter.cs" />
|
|
||||||
<Compile Include="Pages\ToolboxAutoFixPage.xaml.cs">
|
<Compile Include="Pages\ToolboxAutoFixPage.xaml.cs">
|
||||||
<DependentUpon>ToolboxAutoFixPage.xaml</DependentUpon>
|
<DependentUpon>ToolboxAutoFixPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace BililiveRecorder.WPF.Controls
|
namespace BililiveRecorder.WPF.Controls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -10,7 +11,7 @@ namespace BililiveRecorder.WPF.Controls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AddRoomCard : UserControl
|
public partial class AddRoomCard : UserControl
|
||||||
{
|
{
|
||||||
public event EventHandler<string> AddRoomRequested;
|
public event EventHandler<string>? AddRoomRequested;
|
||||||
|
|
||||||
public AddRoomCard()
|
public AddRoomCard()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using BililiveRecorder.Core;
|
using BililiveRecorder.Core;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace BililiveRecorder.WPF.Controls
|
namespace BililiveRecorder.WPF.Controls
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,9 +17,9 @@ namespace BililiveRecorder.WPF.Controls
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler DeleteRequested;
|
public event EventHandler? DeleteRequested;
|
||||||
|
|
||||||
public event EventHandler ShowSettingsRequested;
|
public event EventHandler? ShowSettingsRequested;
|
||||||
|
|
||||||
private void MenuItem_StartRecording_Click(object sender, RoutedEventArgs e) => (this.DataContext as IRoom)?.StartRecord();
|
private void MenuItem_StartRecording_Click(object sender, RoutedEventArgs e) => (this.DataContext as IRoom)?.StartRecord();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace BililiveRecorder.WPF.Converters
|
namespace BililiveRecorder.WPF.Converters
|
||||||
{
|
{
|
||||||
public class RatioToArrowIconConverter : DependencyObject, IValueConverter
|
public class RatioToArrowIconConverter : DependencyObject, IValueConverter
|
||||||
|
@ -13,7 +14,7 @@ namespace BililiveRecorder.WPF.Converters
|
||||||
public object UpArrow { get => this.GetValue(UpArrowProperty); set => this.SetValue(UpArrowProperty, value); }
|
public object UpArrow { get => this.GetValue(UpArrowProperty); set => this.SetValue(UpArrowProperty, value); }
|
||||||
public object DownArrow { get => this.GetValue(DownArrowProperty); set => this.SetValue(DownArrowProperty, value); }
|
public object DownArrow { get => this.GetValue(DownArrowProperty); set => this.SetValue(DownArrowProperty, value); }
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||||
value is double num ? num < 0.97 ? this.DownArrow : num > 1.03 ? this.UpArrow : null : null;
|
value is double num ? num < 0.97 ? this.DownArrow : num > 1.03 ? this.UpArrow : null : null;
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using BililiveRecorder.Core;
|
|
||||||
|
|
||||||
namespace BililiveRecorder.WPF.Converters
|
|
||||||
{
|
|
||||||
internal class RoomListInterceptConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return value is RecorderWrapper ? value : value is IRecorder recorder ? new RecorderWrapper(recorder) : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class RecorderWrapper : ObservableCollection<IRoom>
|
|
||||||
{
|
|
||||||
private readonly IRecorder recorder;
|
|
||||||
|
|
||||||
public RecorderWrapper(IRecorder recorder) : base(recorder.Rooms)
|
|
||||||
{
|
|
||||||
this.recorder = recorder;
|
|
||||||
this.Add(null);
|
|
||||||
|
|
||||||
// TODO fix me
|
|
||||||
//recorder.Rooms.CollectionChanged += (sender, e) =>
|
|
||||||
//{
|
|
||||||
// switch (e.Action)
|
|
||||||
// {
|
|
||||||
// case NotifyCollectionChangedAction.Add:
|
|
||||||
// if (e.NewItems.Count != 1) throw new NotImplementedException("Wrapper Add Item Count != 1");
|
|
||||||
// this.InsertItem(e.NewStartingIndex, e.NewItems[0] as IRecordedRoom);
|
|
||||||
// break;
|
|
||||||
// case NotifyCollectionChangedAction.Remove:
|
|
||||||
// if (e.OldItems.Count != 1) throw new NotImplementedException("Wrapper Remove Item Count != 1");
|
|
||||||
// if (!this.Remove(e.OldItems[0] as IRecordedRoom)) throw new NotImplementedException("Wrapper Remove Item Sync Fail");
|
|
||||||
// break;
|
|
||||||
// case NotifyCollectionChangedAction.Replace:
|
|
||||||
// throw new NotImplementedException("Wrapper Replace Item");
|
|
||||||
// case NotifyCollectionChangedAction.Move:
|
|
||||||
// throw new NotImplementedException("Wrapper Move Item");
|
|
||||||
// case NotifyCollectionChangedAction.Reset:
|
|
||||||
// this.ClearItems();
|
|
||||||
// this.Add(null);
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,11 +5,12 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace BililiveRecorder.WPF.Models
|
namespace BililiveRecorder.WPF.Models
|
||||||
{
|
{
|
||||||
public class AboutModel : INotifyPropertyChanged
|
public class AboutModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
public string InformationalVersion => GitVersionInformation.InformationalVersion;
|
public string InformationalVersion => GitVersionInformation.InformationalVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,17 @@ using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using BililiveRecorder.Core;
|
using BililiveRecorder.Core;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
namespace BililiveRecorder.WPF.Models
|
namespace BililiveRecorder.WPF.Models
|
||||||
{
|
{
|
||||||
internal class RootModel : INotifyPropertyChanged, IDisposable
|
internal class RootModel : INotifyPropertyChanged, IDisposable
|
||||||
{
|
{
|
||||||
private bool disposedValue;
|
private bool disposedValue;
|
||||||
private IRecorder recorder;
|
private IRecorder? recorder;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
public IRecorder Recorder { get => this.recorder; internal set => this.SetField(ref this.recorder, value); }
|
public IRecorder? Recorder { get => this.recorder; internal set => this.SetField(ref this.recorder, value); }
|
||||||
|
|
||||||
public RootModel()
|
public RootModel()
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,9 @@ namespace BililiveRecorder.WPF
|
||||||
|
|
||||||
public bool PromptCloseConfirm { get; set; } = true;
|
public bool PromptCloseConfirm { get; set; } = true;
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
if (this.PromptCloseConfirm && !this.CloseConfirmed)
|
if (this.PromptCloseConfirm && !this.CloseConfirmed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,16 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
_ = this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Func<Task>)(async () => await this.LoadAnnouncementAsync(ignore_cache: false, show_error: false)));
|
_ = this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Func<Task>)(async () => await this.LoadAnnouncementAsync(ignore_cache: false, show_error: false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Button_Click(object sender, RoutedEventArgs e) => await this.LoadAnnouncementAsync(ignore_cache: true, show_error: Keyboard.Modifiers.HasFlag(ModifierKeys.Control));
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
|
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await this.LoadAnnouncementAsync(ignore_cache: true, show_error: Keyboard.Modifiers.HasFlag(ModifierKeys.Control));
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
|
||||||
private async Task LoadAnnouncementAsync(bool ignore_cache, bool show_error)
|
private async Task LoadAnnouncementAsync(bool ignore_cache, bool show_error)
|
||||||
{
|
{
|
||||||
|
@ -110,7 +119,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void Button_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
private async void Button_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control) || !Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) return;
|
if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control) || !Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) return;
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
SingleInstance.Cleanup();
|
SingleInstance.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void RootPage_Loaded(object sender, RoutedEventArgs e)
|
private async void RootPage_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
var first_time = true;
|
var first_time = true;
|
||||||
var from_argument = false;
|
var from_argument = false;
|
||||||
|
|
|
@ -49,7 +49,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void Fix_Button_Click(object sender, RoutedEventArgs e)
|
private async void Fix_Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
AutoFixProgressDialog? progressDialog = null;
|
AutoFixProgressDialog? progressDialog = null;
|
||||||
try
|
try
|
||||||
|
@ -74,6 +76,7 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
EnsureValidNames = true,
|
EnsureValidNames = true,
|
||||||
NavigateToShortcut = true,
|
NavigateToShortcut = true,
|
||||||
OverwritePrompt = false,
|
OverwritePrompt = false,
|
||||||
|
InitialDirectory = Path.GetDirectoryName(inputPath),
|
||||||
DefaultDirectory = Path.GetDirectoryName(inputPath),
|
DefaultDirectory = Path.GetDirectoryName(inputPath),
|
||||||
DefaultFileName = Path.GetFileName(inputPath)
|
DefaultFileName = Path.GetFileName(inputPath)
|
||||||
};
|
};
|
||||||
|
@ -129,7 +132,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void Analyze_Button_Click(object sender, RoutedEventArgs e)
|
private async void Analyze_Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
AutoFixProgressDialog? progressDialog = null;
|
AutoFixProgressDialog? progressDialog = null;
|
||||||
try
|
try
|
||||||
|
@ -192,7 +197,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
private async void Export_Button_Click(object sender, RoutedEventArgs e)
|
private async void Export_Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
#pragma warning restore VSTHRD100 // Avoid async void methods
|
||||||
{
|
{
|
||||||
AutoFixProgressDialog? progressDialog = null;
|
AutoFixProgressDialog? progressDialog = null;
|
||||||
try
|
try
|
||||||
|
@ -216,6 +223,8 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
EnsurePathExists = true,
|
EnsurePathExists = true,
|
||||||
EnsureValidNames = true,
|
EnsureValidNames = true,
|
||||||
NavigateToShortcut = true,
|
NavigateToShortcut = true,
|
||||||
|
OverwritePrompt = false,
|
||||||
|
InitialDirectory = Path.GetDirectoryName(inputPath),
|
||||||
DefaultDirectory = Path.GetDirectoryName(inputPath),
|
DefaultDirectory = Path.GetDirectoryName(inputPath),
|
||||||
DefaultFileName = Path.GetFileNameWithoutExtension(inputPath) + ".brec.xml.gz"
|
DefaultFileName = Path.GetFileNameWithoutExtension(inputPath) + ".brec.xml.gz"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user