BililiveRecorder/BililiveRecorder.Core/Config/V1/ConfigV1.cs

194 lines
7.9 KiB
C#
Raw Normal View History

2021-01-01 14:46:27 +08:00
using System;
2018-11-01 23:40:50 +08:00
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
2020-11-27 18:51:02 +08:00
using Newtonsoft.Json;
2018-11-01 23:40:50 +08:00
2021-02-23 18:03:37 +08:00
#nullable disable
2021-01-01 14:46:27 +08:00
namespace BililiveRecorder.Core.Config.V1
2018-11-01 23:40:50 +08:00
{
2021-01-01 14:46:27 +08:00
[Obsolete]
2018-11-01 23:40:50 +08:00
[JsonObject(memberSerialization: MemberSerialization.OptIn)]
public class ConfigV1 : INotifyPropertyChanged
{
2021-02-23 18:03:37 +08:00
//private static readonly Logger logger = LogManager.GetCurrentClassLogger();
2018-11-01 23:40:50 +08:00
/// <summary>
/// 房间号列表
/// </summary>
[JsonProperty("roomlist")]
public List<RoomV1> RoomList { get; set; } = new List<RoomV1>();
/// <summary>
/// 启用的功能
/// </summary>
2021-02-23 18:03:37 +08:00
//[JsonProperty("feature")]
//public EnabledFeature EnabledFeature { get => this._enabledFeature; set => this.SetField(ref this._enabledFeature, value); }
2018-11-01 23:40:50 +08:00
/// <summary>
/// 剪辑-过去的时长(秒)
/// </summary>
[JsonProperty("clip_length_future")]
2021-01-01 14:46:27 +08:00
public uint ClipLengthFuture { get => this._clipLengthFuture; set => this.SetField(ref this._clipLengthFuture, value); }
2018-11-01 23:40:50 +08:00
/// <summary>
/// 剪辑-将来的时长(秒)
/// </summary>
[JsonProperty("clip_length_past")]
2021-01-01 14:46:27 +08:00
public uint ClipLengthPast { get => this._clipLengthPast; set => this.SetField(ref this._clipLengthPast, value); }
2018-11-01 23:40:50 +08:00
2018-11-07 06:07:49 +08:00
/// <summary>
/// 自动切割模式
/// </summary>
[JsonProperty("cutting_mode")]
2021-02-23 18:03:37 +08:00
public V2.CuttingMode CuttingMode { get => this._cuttingMode; set => this.SetField(ref this._cuttingMode, value); }
2018-11-07 06:07:49 +08:00
/// <summary>
/// 自动切割数值(分钟/MiB
/// </summary>
[JsonProperty("cutting_number")]
2021-01-01 14:46:27 +08:00
public uint CuttingNumber { get => this._cuttingNumber; set => this.SetField(ref this._cuttingNumber, value); }
2018-11-07 06:07:49 +08:00
2018-12-18 00:16:24 +08:00
/// <summary>
/// 录制断开重连时间间隔 毫秒
/// </summary>
[JsonProperty("timing_stream_retry")]
2021-01-01 14:46:27 +08:00
public uint TimingStreamRetry { get => this._timingStreamRetry; set => this.SetField(ref this._timingStreamRetry, value); }
2018-12-18 00:16:24 +08:00
/// <summary>
/// 连接直播服务器超时时间 毫秒
/// </summary>
[JsonProperty("timing_stream_connect")]
2021-01-01 14:46:27 +08:00
public uint TimingStreamConnect { get => this._timingStreamConnect; set => this.SetField(ref this._timingStreamConnect, value); }
2018-12-18 00:16:24 +08:00
/// <summary>
/// 弹幕服务器重连时间间隔 毫秒
/// </summary>
[JsonProperty("timing_danmaku_retry")]
2021-01-01 14:46:27 +08:00
public uint TimingDanmakuRetry { get => this._timingDanmakuRetry; set => this.SetField(ref this._timingDanmakuRetry, value); }
2018-12-18 00:16:24 +08:00
/// <summary>
/// HTTP API 检查时间间隔 秒
/// </summary>
[JsonProperty("timing_check_interval")]
2021-01-01 14:46:27 +08:00
public uint TimingCheckInterval { get => this._timingCheckInterval; set => this.SetField(ref this._timingCheckInterval, value); }
2018-12-18 00:16:24 +08:00
2018-12-19 21:24:39 +08:00
/// <summary>
/// 最大未收到新直播数据时间 毫秒
/// </summary>
[JsonProperty("timing_watchdog_timeout")]
2021-01-01 14:46:27 +08:00
public uint TimingWatchdogTimeout { get => this._timingWatchdogTimeout; set => this.SetField(ref this._timingWatchdogTimeout, value); }
2018-12-19 21:24:39 +08:00
2019-10-31 22:02:19 +08:00
/// <summary>
/// 请求 API 时使用的 Cookie
/// </summary>
[JsonProperty("cookie")]
2021-01-01 14:46:27 +08:00
public string Cookie { get => this._cookie; set => this.SetField(ref this._cookie, value); }
2019-10-31 22:02:19 +08:00
2020-11-23 17:35:42 +08:00
/// <summary>
/// 是否同时录制弹幕
/// </summary>
[JsonProperty("record_danmaku")]
2021-01-01 14:46:27 +08:00
public bool RecordDanmaku { get => this._recordDanmaku; set => this.SetField(ref this._recordDanmaku, value); }
2020-11-23 17:35:42 +08:00
2020-11-27 18:51:02 +08:00
/// <summary>
/// 是否记录弹幕原始数据
/// </summary>
[JsonProperty("record_danmaku_raw")]
2021-01-01 14:46:27 +08:00
public bool RecordDanmakuRaw { get => this._recordDanmakuRaw; set => this.SetField(ref this._recordDanmakuRaw, value); }
2020-11-27 18:51:02 +08:00
2020-11-24 20:15:21 +08:00
/// <summary>
/// 是否同时录制 SuperChat
/// </summary>
[JsonProperty("record_danmaku_sc")]
2021-01-01 14:46:27 +08:00
public bool RecordDanmakuSuperChat { get => this._recordDanmakuSuperChat; set => this.SetField(ref this._recordDanmakuSuperChat, value); }
2020-11-24 20:15:21 +08:00
/// <summary>
/// 是否同时录制 礼物
/// </summary>
[JsonProperty("record_danmaku_gift")]
2021-01-01 14:46:27 +08:00
public bool RecordDanmakuGift { get => this._recordDanmakuGift; set => this.SetField(ref this._recordDanmakuGift, value); }
2020-11-24 20:15:21 +08:00
/// <summary>
/// 是否同时录制 上船
/// </summary>
[JsonProperty("record_danmaku_guard")]
2021-01-01 14:46:27 +08:00
public bool RecordDanmakuGuard { get => this._recordDanmakuGuard; set => this.SetField(ref this._recordDanmakuGuard, value); }
2020-11-24 20:15:21 +08:00
2020-12-17 19:32:48 +08:00
/// <summary>
/// 触发 <see cref="System.Xml.XmlWriter.Flush"/> 的弹幕个数
/// </summary>
[JsonProperty("record_danmaku_flush_interval")]
2021-01-01 14:46:27 +08:00
public uint RecordDanmakuFlushInterval { get => this._recordDanmakuFlushInterval; set => this.SetField(ref this._recordDanmakuFlushInterval, value); }
2020-12-17 19:32:48 +08:00
2020-06-21 19:39:07 +08:00
/// <summary>
/// 替换api.live.bilibili.com服务器为其他反代可以支持在云服务器上录制
/// </summary>
[JsonProperty("live_api_host")]
2021-01-01 14:46:27 +08:00
public string LiveApiHost { get => this._liveApiHost; set => this.SetField(ref this._liveApiHost, value); }
[JsonProperty("record_filename_format")]
public string RecordFilenameFormat
{
2021-01-01 14:46:27 +08:00
get => this._record_filename_format;
set => this.SetField(ref this._record_filename_format, value);
}
[JsonProperty("clip_filename_format")]
public string ClipFilenameFormat
{
2021-01-01 14:46:27 +08:00
get => this._clip_filename_format;
set => this.SetField(ref this._clip_filename_format, value);
}
2020-12-20 20:56:40 +08:00
/// <summary>
/// Webhook 地址 每行一个
/// </summary>
[JsonProperty("webhook_urls")]
public string WebHookUrls
{
2021-01-01 14:46:27 +08:00
get => this._webhook_urls;
set => this.SetField(ref this._webhook_urls, value);
2020-12-20 20:56:40 +08:00
}
2018-11-01 23:40:50 +08:00
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = "")
{
2021-02-23 18:03:37 +08:00
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
// logger.Trace("设置 [{0}] 的值已从 [{1}] 修改到 [{2}]", propertyName, field, value);
2021-01-01 14:46:27 +08:00
field = value; this.OnPropertyChanged(propertyName); return true;
2018-11-01 23:40:50 +08:00
}
#endregion
private uint _clipLengthPast = 20;
private uint _clipLengthFuture = 10;
2018-11-07 06:07:49 +08:00
private uint _cuttingNumber = 10;
2021-02-23 18:03:37 +08:00
//private EnabledFeature _enabledFeature = EnabledFeature.RecordOnly;
private V2.CuttingMode _cuttingMode = V2.CuttingMode.Disabled;
2018-12-18 00:16:24 +08:00
2019-10-31 22:05:16 +08:00
private uint _timingWatchdogTimeout = 10 * 1000;
2018-12-18 00:16:24 +08:00
private uint _timingStreamRetry = 6 * 1000;
2020-05-01 07:38:38 +08:00
private uint _timingStreamConnect = 5 * 1000;
private uint _timingDanmakuRetry = 15 * 1000;
2018-12-18 00:16:24 +08:00
private uint _timingCheckInterval = 5 * 60;
2019-10-31 22:02:19 +08:00
private string _cookie = string.Empty;
2020-05-01 08:37:56 +08:00
private string _record_filename_format = @"{roomid}-{name}/录制-{roomid}-{date}-{time}-{title}.flv";
private string _clip_filename_format = @"{roomid}-{name}/剪辑片段-{roomid}-{date}-{time}-{title}.flv";
2020-11-23 17:35:42 +08:00
private bool _recordDanmaku = false;
2020-11-27 18:51:02 +08:00
private bool _recordDanmakuRaw = false;
2020-11-24 20:15:21 +08:00
private bool _recordDanmakuSuperChat = false;
private bool _recordDanmakuGift = false;
private bool _recordDanmakuGuard = false;
2020-12-17 19:32:48 +08:00
private uint _recordDanmakuFlushInterval = 20;
2020-11-24 20:15:21 +08:00
2020-06-21 19:39:07 +08:00
private string _liveApiHost = "https://api.live.bilibili.com";
2020-12-20 20:56:40 +08:00
private string _webhook_urls = "";
2018-11-01 23:40:50 +08:00
}
}