Skip to content

Commit

Permalink
Merge pull request #5 from Executor-Cheng/dev/1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Executor-Cheng authored Jul 24, 2023
2 parents 25be7cd + 9090c50 commit 607cf3a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<UseWindowsForms>true</UseWindowsForms>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>

<Version>1.0.4.0</Version>
<AssemblyVersion>1.0.4.0</AssemblyVersion>
<FileVersion>1.0.4.0</FileVersion>
<PackageVersion>1.0.4.0</PackageVersion>
<Version>1.0.5.0</Version>
<AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.5.0</FileVersion>
<PackageVersion>1.0.5.0</PackageVersion>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/BililiveNotification/Apis/BiliApis.GetRoomInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BililiveNotification.Models;
using BililiveNotification.Models;
using Executorlibs.Shared.Exceptions;
using Executorlibs.Shared.Extensions;
using System;
Expand All @@ -24,7 +24,7 @@ public static async Task<RoomInfo> GetRoomInfoAsync(HttpClient client, int roomI
throw new UnknownResponseException(in root);
}
JsonElement data = root.GetProperty("data");
int userId = data.GetProperty("uid").GetInt32();
long userId = data.GetProperty("uid").GetInt64();
UserInfo userInfo = await GetUserInfoAsync(client, userId, token);
string? cover = data.GetProperty("user_cover").GetString();
if (cover == "")
Expand Down
2 changes: 1 addition & 1 deletion src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace BililiveNotification.Apis
{
public static partial class BiliApis
{
public static async Task<UserInfo> GetUserInfoAsync(HttpClient client, int userId, CancellationToken token = default)
public static async Task<UserInfo> GetUserInfoAsync(HttpClient client, long userId, CancellationToken token = default)
{
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"https://api.bilibili.com/x/web-interface/card?mid={userId}");
req.Headers.Accept.ParseAdd("*/*");
Expand Down
1 change: 1 addition & 0 deletions src/BililiveNotification/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</StackPanel>
<DataGrid x:Name="MonitorDG" IsReadOnly="True" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserResizeRows="False" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="主播名" Binding="{Binding MasterName}"/>
<DataGridTextColumn Header="房间号" Binding="{Binding RoomId}"/>
<DataGridTextColumn Header="工作状态" Binding="{Binding StatusDisplay}"/>
<DataGridTextColumn Header="连接状态" Binding="{Binding ConnectionStatusDisplay}"/>
Expand Down
6 changes: 3 additions & 3 deletions src/BililiveNotification/Models/RoomInfo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace BililiveNotification.Models
namespace BililiveNotification.Models
{
public class RoomInfo
{
public string UserName { get; }

public int UserId { get; }
public long UserId { get; }

public string FaceUrl { get; }

public string? CoverUrl { get; }

public RoomInfo(string userName, int userId, string faceUrl, string? coverUrl)
public RoomInfo(string userName, long userId, string faceUrl, string? coverUrl)
{
UserName = userName;
UserId = userId;
Expand Down
6 changes: 3 additions & 3 deletions src/BililiveNotification/Models/UserInfo.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace BililiveNotification.Models
namespace BililiveNotification.Models
{
public class UserInfo
{
public string UserName { get; }

public int UserId { get; }
public long UserId { get; }

public string FaceUrl { get; }

public UserInfo(string userName, int userId, string faceUrl)
public UserInfo(string userName, long userId, string faceUrl)
{
UserName = userName;
UserId = userId;
Expand Down
26 changes: 25 additions & 1 deletion src/BililiveNotification/RoomMonitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BililiveNotification.Apis;
using BililiveNotification.Apis;
using BililiveNotification.Models;
using Executorlibs.Bilibili.Protocol.Clients;
using Executorlibs.Bilibili.Protocol.Handlers;
Expand Down Expand Up @@ -40,6 +40,8 @@ public sealed class RoomMonitor : IDisposable,

public event PropertyChangedEventHandler? PropertyChanged;

private string? _masterName;

private DateTime _lastTime;

private bool _status;
Expand Down Expand Up @@ -67,6 +69,19 @@ public bool LiveStatus
}
}

public string? MasterName
{
get => _masterName;
set
{
if (_masterName != value)
{
_masterName = value;
OnPropertyChanged();
}
}
}

public int RoomId { get; }

public string StatusDisplay => _status ? "启用" : "禁用";
Expand Down Expand Up @@ -159,6 +174,15 @@ public async Task InitializeAsync()
_lastTime = time.Value;
OnPropertyChanged(nameof(LiveStatusDisplay));
}
try
{
var roomInfo = await BiliApis.GetRoomInfoAsync(_httpClient, RoomId);
MasterName = roomInfo.UserName;
}
catch (Exception)
{
MasterName = "<获取失败>";
}
await StartAsync();
}

Expand Down

0 comments on commit 607cf3a

Please sign in to comment.