mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
feat: add stream started desktop notification
This commit is contained in:
parent
9c7e99944a
commit
33f4e98a46
|
@ -28,6 +28,7 @@ namespace BililiveRecorder.Cli.Configure
|
|||
WebHookUrls,
|
||||
WebHookUrlsV2,
|
||||
WpfShowTitleAndArea,
|
||||
WpfNotifyStreamStart,
|
||||
Cookie,
|
||||
LiveApiHost,
|
||||
TimingCheckInterval,
|
||||
|
@ -80,6 +81,7 @@ namespace BililiveRecorder.Cli.Configure
|
|||
GlobalConfig.Add(GlobalConfigProperties.WebHookUrls, new ConfigInstruction<GlobalConfig, string>(config => config.HasWebHookUrls = false, (config, value) => config.WebHookUrls = value) { Name = "WebHookUrls", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.WebHookUrlsV2, new ConfigInstruction<GlobalConfig, string>(config => config.HasWebHookUrlsV2 = false, (config, value) => config.WebHookUrlsV2 = value) { Name = "WebHookUrlsV2", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.WpfShowTitleAndArea, new ConfigInstruction<GlobalConfig, bool>(config => config.HasWpfShowTitleAndArea = false, (config, value) => config.WpfShowTitleAndArea = value) { Name = "WpfShowTitleAndArea", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.WpfNotifyStreamStart, new ConfigInstruction<GlobalConfig, bool>(config => config.HasWpfNotifyStreamStart = false, (config, value) => config.WpfNotifyStreamStart = value) { Name = "WpfNotifyStreamStart", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.Cookie, new ConfigInstruction<GlobalConfig, string>(config => config.HasCookie = false, (config, value) => config.Cookie = value) { Name = "Cookie", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.LiveApiHost, new ConfigInstruction<GlobalConfig, string>(config => config.HasLiveApiHost = false, (config, value) => config.LiveApiHost = value) { Name = "LiveApiHost", CanBeOptional = true });
|
||||
GlobalConfig.Add(GlobalConfigProperties.TimingCheckInterval, new ConfigInstruction<GlobalConfig, uint>(config => config.HasTimingCheckInterval = false, (config, value) => config.TimingCheckInterval = value) { Name = "TimingCheckInterval", CanBeOptional = true });
|
||||
|
|
|
@ -125,10 +125,15 @@ namespace BililiveRecorder.Core.Config.V3
|
|||
public string? WebHookUrlsV2 => this.GetPropertyValue<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 在界面显示标题和分区
|
||||
/// 桌面版在界面显示标题和分区
|
||||
/// </summary>
|
||||
public bool WpfShowTitleAndArea => this.GetPropertyValue<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// 桌面版开播时弹出系统通知
|
||||
/// </summary>
|
||||
public bool WpfNotifyStreamStart => this.GetPropertyValue<bool>();
|
||||
|
||||
/// <summary>
|
||||
/// Cookie
|
||||
/// </summary>
|
||||
|
@ -304,13 +309,21 @@ namespace BililiveRecorder.Core.Config.V3
|
|||
public Optional<string?> OptionalWebHookUrlsV2 { get => this.GetPropertyValueOptional<string>(nameof(this.WebHookUrlsV2)); set => this.SetPropertyValueOptional(value, nameof(this.WebHookUrlsV2)); }
|
||||
|
||||
/// <summary>
|
||||
/// 在界面显示标题和分区
|
||||
/// 桌面版在界面显示标题和分区
|
||||
/// </summary>
|
||||
public bool WpfShowTitleAndArea { get => this.GetPropertyValue<bool>(); set => this.SetPropertyValue(value); }
|
||||
public bool HasWpfShowTitleAndArea { get => this.GetPropertyHasValue(nameof(this.WpfShowTitleAndArea)); set => this.SetPropertyHasValue<bool>(value, nameof(this.WpfShowTitleAndArea)); }
|
||||
[JsonProperty(nameof(WpfShowTitleAndArea)), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public Optional<bool> OptionalWpfShowTitleAndArea { get => this.GetPropertyValueOptional<bool>(nameof(this.WpfShowTitleAndArea)); set => this.SetPropertyValueOptional(value, nameof(this.WpfShowTitleAndArea)); }
|
||||
|
||||
/// <summary>
|
||||
/// 桌面版开播时弹出系统通知
|
||||
/// </summary>
|
||||
public bool WpfNotifyStreamStart { get => this.GetPropertyValue<bool>(); set => this.SetPropertyValue(value); }
|
||||
public bool HasWpfNotifyStreamStart { get => this.GetPropertyHasValue(nameof(this.WpfNotifyStreamStart)); set => this.SetPropertyHasValue<bool>(value, nameof(this.WpfNotifyStreamStart)); }
|
||||
[JsonProperty(nameof(WpfNotifyStreamStart)), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public Optional<bool> OptionalWpfNotifyStreamStart { get => this.GetPropertyValueOptional<bool>(nameof(this.WpfNotifyStreamStart)); set => this.SetPropertyValueOptional(value, nameof(this.WpfNotifyStreamStart)); }
|
||||
|
||||
/// <summary>
|
||||
/// Cookie
|
||||
/// </summary>
|
||||
|
@ -450,6 +463,8 @@ namespace BililiveRecorder.Core.Config.V3
|
|||
|
||||
public bool WpfShowTitleAndArea => true;
|
||||
|
||||
public bool WpfNotifyStreamStart => false;
|
||||
|
||||
public string Cookie => @"";
|
||||
|
||||
public string LiveApiHost => @"https://api.live.bilibili.com";
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace BililiveRecorder.Core
|
|||
event EventHandler<AggregatedRoomEventArgs<RecordFileClosedEventArgs>>? RecordFileClosed;
|
||||
event EventHandler<AggregatedRoomEventArgs<IOStatsEventArgs>>? IOStats;
|
||||
event EventHandler<AggregatedRoomEventArgs<RecordingStatsEventArgs>>? RecordingStats;
|
||||
event EventHandler<IRoom> StreamStarted;
|
||||
|
||||
IRoom AddRoom(int roomid);
|
||||
IRoom AddRoom(int roomid, bool enabled);
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace BililiveRecorder.Core
|
|||
public event EventHandler<AggregatedRoomEventArgs<RecordFileClosedEventArgs>>? RecordFileClosed;
|
||||
public event EventHandler<AggregatedRoomEventArgs<IOStatsEventArgs>>? IOStats;
|
||||
public event EventHandler<AggregatedRoomEventArgs<RecordingStatsEventArgs>>? RecordingStats;
|
||||
public event EventHandler<IRoom>? StreamStarted;
|
||||
#pragma warning disable CS0067 // The event 'Recorder.PropertyChanged' is never used
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
#pragma warning restore CS0067 // The event 'Recorder.PropertyChanged' is never used
|
||||
|
@ -175,6 +176,7 @@ namespace BililiveRecorder.Core
|
|||
if (room.Streaming)
|
||||
{
|
||||
_ = Task.Run(async () => await this.basicWebhookV2.SendStreamStartedAsync(new StreamStartedEventArgs(room)).ConfigureAwait(false));
|
||||
_ = Task.Run(() => StreamStarted?.Invoke(this, room));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
<MenuItem Header="{l:Loc RoomListPage_Menu_Sort_RoomId}" Tag="{x:Static local:SortedBy.RoomId}" Click="MenuItem_SortBy_Click"/>
|
||||
<MenuItem Header="{l:Loc RoomListPage_Menu_Sort_Status}" Tag="{x:Static local:SortedBy.Status}" Click="MenuItem_SortBy_Click"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="开播时弹出系统通知" IsCheckable="True" IsChecked="{Binding Config.Global.WpfNotifyStreamStart}"/>
|
||||
<MenuItem Header="{l:Loc RoomListPage_Menu_View_ShowTitleAndAreaCheckBox}" IsCheckable="True" IsChecked="{Binding Config.Global.WpfShowTitleAndArea}"/>
|
||||
<MenuItem Header="{l:Loc RoomListPage_Menu_View_ShowLogCheckBox}" IsCheckable="True" Checked="MenuItem_ShowLog_Click" Unchecked="MenuItem_HideLog_Click"/>
|
||||
</MenuItem>
|
||||
|
|
|
@ -267,6 +267,21 @@ You can uninstall me in system settings.", "安装成功 Installed", MessageBoxB
|
|||
(Application.Current.MainWindow as NewMainWindow)!.HideToTray = true;
|
||||
NetworkChangeDetector.Enable();
|
||||
|
||||
// 开播提醒系统通知,乱,但它能跑起来 ┑( ̄Д  ̄)┍
|
||||
recorder.StreamStarted += (sender, room) =>
|
||||
{
|
||||
if (!recorder.Config.Global.WpfNotifyStreamStart)
|
||||
return;
|
||||
|
||||
_ = this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||
{
|
||||
if (Application.Current.MainWindow is NewMainWindow nmw)
|
||||
{
|
||||
nmw.ShowBalloonTipCallback?.Invoke(room.Name + " 开播了", $"{room.AreaNameParent} · {room.AreaNameChild}\n{room.Title}", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.None);
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(150);
|
||||
|
|
|
@ -107,6 +107,9 @@
|
|||
</Border>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox Header="开播通知">
|
||||
<ui:ToggleSwitch IsOn="{Binding WpfNotifyStreamStart}" OnContent="直播间开播时弹出系统通知" OffContent="直播间开播时弹出系统通知"/>
|
||||
</GroupBox>
|
||||
<GroupBox Header="录制画质">
|
||||
<StackPanel MaxWidth="400" HorizontalAlignment="Left">
|
||||
<Button Margin="5,0,0,0" Command="{x:Static m:Commands.OpenLink}" CommandParameter="https://rec.danmuji.org/docs/basic/settings/#%E7%9B%B4%E6%92%AD%E7%94%BB%E8%B4%A8">
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace BililiveRecorder.Web
|
|||
public event EventHandler<AggregatedRoomEventArgs<IOStatsEventArgs>>? IOStats;
|
||||
public event EventHandler<AggregatedRoomEventArgs<RecordingStatsEventArgs>>? RecordingStats;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
public event EventHandler<IRoom>? StreamStarted;
|
||||
#pragma warning restore CS0067
|
||||
|
||||
public IRoom AddRoom(int roomid) => null!;
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace BililiveRecorder.Web.Models
|
|||
public Optional<string?>? OptionalWebHookUrls { get; set; }
|
||||
public Optional<string?>? OptionalWebHookUrlsV2 { get; set; }
|
||||
public Optional<bool>? OptionalWpfShowTitleAndArea { get; set; }
|
||||
public Optional<bool>? OptionalWpfNotifyStreamStart { get; set; }
|
||||
public Optional<string?>? OptionalCookie { get; set; }
|
||||
public Optional<string?>? OptionalLiveApiHost { get; set; }
|
||||
public Optional<uint>? OptionalTimingCheckInterval { get; set; }
|
||||
|
@ -86,6 +87,7 @@ namespace BililiveRecorder.Web.Models
|
|||
if (this.OptionalWebHookUrls.HasValue) config.OptionalWebHookUrls = this.OptionalWebHookUrls.Value;
|
||||
if (this.OptionalWebHookUrlsV2.HasValue) config.OptionalWebHookUrlsV2 = this.OptionalWebHookUrlsV2.Value;
|
||||
if (this.OptionalWpfShowTitleAndArea.HasValue) config.OptionalWpfShowTitleAndArea = this.OptionalWpfShowTitleAndArea.Value;
|
||||
if (this.OptionalWpfNotifyStreamStart.HasValue) config.OptionalWpfNotifyStreamStart = this.OptionalWpfNotifyStreamStart.Value;
|
||||
if (this.OptionalCookie.HasValue) config.OptionalCookie = this.OptionalCookie.Value;
|
||||
if (this.OptionalLiveApiHost.HasValue) config.OptionalLiveApiHost = this.OptionalLiveApiHost.Value;
|
||||
if (this.OptionalTimingCheckInterval.HasValue) config.OptionalTimingCheckInterval = this.OptionalTimingCheckInterval.Value;
|
||||
|
@ -137,6 +139,7 @@ namespace BililiveRecorder.Web.Models.Rest
|
|||
public Optional<string?> OptionalWebHookUrls { get; set; }
|
||||
public Optional<string?> OptionalWebHookUrlsV2 { get; set; }
|
||||
public Optional<bool> OptionalWpfShowTitleAndArea { get; set; }
|
||||
public Optional<bool> OptionalWpfNotifyStreamStart { get; set; }
|
||||
public Optional<string?> OptionalCookie { get; set; }
|
||||
public Optional<string?> OptionalLiveApiHost { get; set; }
|
||||
public Optional<uint> OptionalTimingCheckInterval { get; set; }
|
||||
|
@ -193,6 +196,7 @@ namespace BililiveRecorder.Web.Models.Graphql
|
|||
this.Field(x => x.OptionalWebHookUrls, type: typeof(HierarchicalOptionalType<string>));
|
||||
this.Field(x => x.OptionalWebHookUrlsV2, type: typeof(HierarchicalOptionalType<string>));
|
||||
this.Field(x => x.OptionalWpfShowTitleAndArea, type: typeof(HierarchicalOptionalType<bool>));
|
||||
this.Field(x => x.OptionalWpfNotifyStreamStart, type: typeof(HierarchicalOptionalType<bool>));
|
||||
this.Field(x => x.OptionalCookie, type: typeof(HierarchicalOptionalType<string>));
|
||||
this.Field(x => x.OptionalLiveApiHost, type: typeof(HierarchicalOptionalType<string>));
|
||||
this.Field(x => x.OptionalTimingCheckInterval, type: typeof(HierarchicalOptionalType<uint>));
|
||||
|
@ -227,6 +231,7 @@ namespace BililiveRecorder.Web.Models.Graphql
|
|||
this.Field(x => x.WebHookUrls);
|
||||
this.Field(x => x.WebHookUrlsV2);
|
||||
this.Field(x => x.WpfShowTitleAndArea);
|
||||
this.Field(x => x.WpfNotifyStreamStart);
|
||||
this.Field(x => x.Cookie);
|
||||
this.Field(x => x.LiveApiHost);
|
||||
this.Field(x => x.TimingCheckInterval);
|
||||
|
@ -279,6 +284,7 @@ namespace BililiveRecorder.Web.Models.Graphql
|
|||
this.Field(x => x.OptionalWebHookUrls, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
|
||||
this.Field(x => x.OptionalWebHookUrlsV2, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
|
||||
this.Field(x => x.OptionalWpfShowTitleAndArea, nullable: true, type: typeof(HierarchicalOptionalInputType<bool>));
|
||||
this.Field(x => x.OptionalWpfNotifyStreamStart, nullable: true, type: typeof(HierarchicalOptionalInputType<bool>));
|
||||
this.Field(x => x.OptionalCookie, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
|
||||
this.Field(x => x.OptionalLiveApiHost, nullable: true, type: typeof(HierarchicalOptionalInputType<string>));
|
||||
this.Field(x => x.OptionalTimingCheckInterval, nullable: true, type: typeof(HierarchicalOptionalInputType<uint>));
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
}
|
||||
},
|
||||
"WpfShowTitleAndArea": {
|
||||
"description": "在界面显示标题和分区\n默认: true",
|
||||
"markdownDescription": "在界面显示标题和分区 \n默认: `true `\n\n",
|
||||
"description": "桌面版在界面显示标题和分区\n默认: true",
|
||||
"markdownDescription": "桌面版在界面显示标题和分区 \n默认: `true `\n\n",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
@ -70,6 +70,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"WpfNotifyStreamStart": {
|
||||
"description": "桌面版开播时弹出系统通知\n默认: false",
|
||||
"markdownDescription": "桌面版开播时弹出系统通知 \n默认: `false `\n\n",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"HasValue": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"Value": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"Cookie": {
|
||||
"description": "Cookie\n默认: ",
|
||||
"markdownDescription": "Cookie \n默认: ` `\n\n",
|
||||
|
|
|
@ -109,11 +109,18 @@ export const data: Array<ConfigEntry> = [
|
|||
},
|
||||
{
|
||||
id: "WpfShowTitleAndArea",
|
||||
name: "在界面显示标题和分区",
|
||||
name: "桌面版在界面显示标题和分区",
|
||||
type: "bool",
|
||||
configType: "globalOnly",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: "WpfNotifyStreamStart",
|
||||
name: "桌面版开播时弹出系统通知",
|
||||
type: "bool",
|
||||
configType: "globalOnly",
|
||||
default: false
|
||||
},
|
||||
{
|
||||
id: "Cookie",
|
||||
name: "Cookie",
|
||||
|
|
Loading…
Reference in New Issue
Block a user