BililiveRecorder/BililiveRecorder.WPF/Pages/SettingsPage.xaml.cs

63 lines
12 KiB
C#
Raw Normal View History

using System;
using BililiveRecorder.Core.Templating;
using Newtonsoft.Json.Linq;
using Serilog;
#nullable enable
2020-11-27 18:51:02 +08:00
namespace BililiveRecorder.WPF.Pages
{
/// <summary>
/// Interaction logic for SettingsPage.xaml
/// </summary>
public partial class SettingsPage
{
private static readonly ILogger logger = Log.ForContext<SettingsPage>();
private static readonly FileNameGenerator.FileNameContextData data = new()
2020-11-27 18:51:02 +08:00
{
Name = "3号直播间",
RoomId = 23058,
ShortId = 3,
Title = "哔哩哔哩音悦台",
AreaParent = "电台",
AreaChild = "唱见电台",
Qn = 10000,
Json = JObject.Parse(@"{""room_info"":{""uid"":11153765,""room_id"":23058,""short_id"":3,""title"":""哔哩哔哩音悦台"",""cover"":"""",""tags"":"""",""background"":""https://i0.hdslb.com/bfs/live/2836bb7b84c792e2c6aadfd4d1cce13484775fa3.jpg"",""description"":""\u003cp\u003e这里是哔哩哔哩官方音乐台喔\u003c/p\u003e\u003cp\u003e一起来听音乐吧ε=ε=(ノ≧∇≦)\u003c/p\u003e\u003cp\u003e没想到蒸汽配圣诞下装意外的很暴露呢=3=\u003c/p\u003e\n"",""live_status"":1,""live_start_time"":1642502066,""live_screen_type"":0,""lock_status"":0,""lock_time"":0,""hidden_status"":0,""hidden_time"":0,""area_id"":190,""area_name"":""唱见电台"",""parent_area_id"":5,""parent_area_name"":""电台"",""keyframe"":""http://i0.hdslb.com/bfs/live-key-frame/keyframe05061651000000023058bkekzp.jpg"",""special_type"":0,""up_session"":""204681708782508562"",""pk_status"":0,""is_studio"":false,""pendants"":{""frame"":{""name"":"""",""value"":"""",""desc"":""""}},""on_voice_join"":0,""online"":6697,""room_type"":{""2-3"":0,""3-21"":0}},""anchor_info"":{""base_info"":{""uname"":""3号直播间"",""face"":""http://i2.hdslb.com/bfs/face/5d35da6e93fbfb1a77ad6d1f1004b08413913f9a.jpg"",""gender"":""保密"",""official_info"":{""role"":1,""title"":""哔哩哔哩直播 官方账号"",""desc"":"""",""is_nft"":0,""nft_dmark"":""https://i0.hdslb.com/bfs/live/9f176ff49d28c50e9c53ec1c3297bd1ee539b3d6.gif""}},""live_info"":{""level"":40,""level_color"":16746162,""score"":255237648,""upgrade_score"":0,""current"":[ 25000000, 147013810],""next"":[],""rank"":""\u003e10000""},""relation_info"":{""attention"":248859},""medal_info"":{""medal_name"":""电音"",""medal_id"":123,""fansclub"":1643}},""news_info"":{""uid"":11153765,""ctime"":""2021-09-24 12:49:50"",""content"":""3号大歌厅是音悦台特别推出的测试栏目23日-25日11点-23点为期3天希望大家支持""},""rankdb_info"":{""roomid"":23058,""rank_desc"":""小时总榜"",""color"":""#FB7299"",""h5_url"":""https://live.bilibili.com/p/html/live-app-rankcurrent/index.html?is_live_half_webview=1\u0026hybrid_half_ui=1,5,85p,70p,FFE293,0,30,100,10;2,2,320,100p,FFE293,0,30,100,0;4,2,320,100p,FFE293,0,30,100,0;6,5,65p,60p,FFE293,0,30,100,10;5,5,55p,60p,FFE293,0,30,100,10;3,5,85p,70p,FFE293,0,30,100,10;7,5,65p,60p,FFE293,0,30,100,10;\u0026anchor_uid=11153765\u0026rank_type=master_realtime_hour_room\u0026area_hour=1\u0026area_v2_id=190\u0026area_v2_parent_id=5"",""web_url"":""https://live.bilibili.com/blackboard/room-current-rank.html?rank_type=master_realtime_hour_room\u0026area_hour=1\u0026area_v2_id=190\u0026area_v2_parent_id=5"",""timestamp"":1651234567},""area_rank_info"":{""areaRank"":{""index"":0,""rank"":""\u003e1000""},""liveRank"":{""rank"":""\u003e10000""}},""battle_rank_entry_info"":{""first_rank_img_url"":"""",""rank_name"":""尚无段位"",""show_status"":1},""tab_info"":{""list"":[{""type"":""seven-rank"",""desc"":""高能榜"",""isFirst"":1,""isEvent"":0,""eventType"":"""",""listType"":"""",""apiPrefix"":"""",""rank_name"":""room_7day""},{""type"":""guard"",""desc"":""大航海"",""isFirst"":0,""isEvent"":0,""eventType"":"""",""listType"":""top-list"",""apiPrefix"":"""",""rank_name"":""""}]},""activity_init_info"":{""eventList"":[],""weekInfo"":{""bannerInfo"":null,""giftName"":null},""giftName"":null,""lego"":{""timestamp"":1651234567,""config"":""[{\""name\"":\""frame-mng\"",\""url\"":\""https:\\/\\/live.bilibili.com\\/p\\/html\\/live-web-mng\\/index.html?roomid=#roomid#\u0026arae_id=#area_id#\u0026parent_area_id=#parent_area_id#\u0026ruid=#ruid#\"",\""startTime\"":1559544736,\""endTime\"":1877167950,\""type\"":\""frame-mng\""},{\""name\"":\""s10-fun\"",\""target\"":\""sidebar\"",\""icon\"":\""https:\\/\\/i0.hdslb.com\\/bfs\\/activity-plat\\/static\\/20200908\\/3435f7521efc759ae1f90eae5629a8f0\\/HpxrZ7SOT.png\"",\""text\"":\""\\u7545\\u73a9s10\"",\""url\"":\""https:\\/\\/live.bilibili.com\\/s10\\/fun\\/index.html?room_id=#roomid#\u0026width=376\u0026height=600\u0026source=sidebar\"",\""color\"":\""#2e6fc0\"",\""startTime\
};
private readonly FileNameGenerator? fileNameGenerator;
public SettingsPage() : this((FileNameGenerator?)(RootPage.ServiceProvider?.GetService(typeof(FileNameGenerator))))
{
}
public SettingsPage(FileNameGenerator? fileNameGenerator)
{
this.fileNameGenerator = fileNameGenerator;
2021-01-01 14:46:27 +08:00
this.InitializeComponent();
2020-11-27 18:51:02 +08:00
}
private void TestFileNameTemplate_Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (this.fileNameGenerator is not { } fileNameGenerator)
return;
// TODO 优化这里的交互逻辑,给出更明确的错误提醒
logger.Debug("Test file name template start");
try
{
var (_, relativePath) = fileNameGenerator.CreateFilePath(data);
this.FileNameTestResult.Visibility = System.Windows.Visibility.Visible;
this.FileNameTestResult.Text = relativePath;
}
catch (Exception ex)
{
logger.Debug(ex, "测试文件名模板时发生错误");
}
logger.Debug("Test file name template end");
}
2020-11-27 18:51:02 +08:00
}
}