Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/zyzsdy/biliroku
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzsdy committed Dec 7, 2019
2 parents fedda73 + f854ecc commit 9a194cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 16 additions & 1 deletion BiLiRoku/Bililivelib/PathFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static public Task<RoomInfo> GetRoomInfo(string originalRoomId)
{
return Task.Run(() => {
//InfoLogger.SendInfo(originalRoomId, "DEBUG", "正在刷新信息");

var roominfo_NETERR = new RoomInfo { net_error = true };
var roomWebPageUrl = "https://api.live.bilibili.com/room/v1/Room/get_info?id=" + originalRoomId;
var wc = new WebClient();
wc.Headers.Add("Accept: */*");
Expand All @@ -36,6 +36,11 @@ static public Task<RoomInfo> GetRoomInfo(string originalRoomId)
{
roomHtml = wc.DownloadData(roomWebPageUrl);
}
catch(WebException e0)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "获取房间信息失败<net>:" + e0.Message);
return roominfo_NETERR;
}
catch (Exception e)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "获取房间信息失败:" + e.Message);
Expand All @@ -60,6 +65,11 @@ static public Task<RoomInfo> GetRoomInfo(string originalRoomId)
{
userHtml = uwc.DownloadData(userInfoUrl);
}
catch (WebException e0)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "获取用户信息失败<net>:" + e0.Message);
return roominfo_NETERR;
}
catch (Exception e)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "获取用户信息失败:" + e.Message);
Expand All @@ -79,6 +89,11 @@ static public Task<RoomInfo> GetRoomInfo(string originalRoomId)
};
return roominfo;
}
catch (WebException e0)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "房间信息解析失败<net>:" + e0.Message);
return roominfo_NETERR;
}
catch (Exception e)
{
InfoLogger.SendInfo(originalRoomId, "ERROR", "房间信息解析失败:" + e.Message);
Expand Down
8 changes: 7 additions & 1 deletion BiLiRoku/RoomList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class RoomTask : INotifyPropertyChanged
private bool refreshing = false;
private bool force_stoping = false;
private bool init_ready = false;
private bool net_error = false;

private string realRoomid;
private Downloader downloader;
private CommentProvider commentProvider;
Expand Down Expand Up @@ -86,7 +88,7 @@ public async Task RefreshInfo()
refreshing = true;
PropertyChange("Refreshing");
var RoomInfo = await PathFinder.GetRoomInfo(Roomid);
if(RoomInfo != null)
if(RoomInfo != null && !RoomInfo.net_error)
{
if (RoomInfo.realRoomid == null)
{
Expand Down Expand Up @@ -125,6 +127,10 @@ public async Task RefreshInfo()
PropertyChange("NotLiveStatus");
PropertyChange("Refreshing");
}
else if (RoomInfo != null && RoomInfo.net_error)
{
Stop();
}
}

public async void WaitForStart()
Expand Down

0 comments on commit 9a194cb

Please sign in to comment.