Skip to content

Commit

Permalink
修复重连时可能导致异步报错崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Nov 26, 2020
1 parent d559301 commit 7ed17e9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions Auxiliary/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static bool 读缓存(string key, double ExTime, out string data)
else
{
InfoLog.InfoPrintf("命中缓存,但数据已过期,返回false:" + key, InfoLog.InfoClass.Debug);
return false;
}
}
return false;
Expand Down
25 changes: 23 additions & 2 deletions Auxiliary/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,11 @@ private void 下载完成事件(object sender, AsyncCompletedEventArgs e)
DownIofo.下载状态 = false;
DownIofo.备注 = "录制任务意外终止,已新建续命任务";

下载结束提醒("录制任务意外终止,已新建续命任务",true);
Downloader 下载对象 = Downloader.新建下载对象(
下载结束提醒("录制任务意外终止,已新建续命任务", true);
Downloader 下载对象 = new Downloader();
try
{
下载对象 = Downloader.新建下载对象(
DownIofo.平台,
DownIofo.房间_频道号,
bilibili.根据房间号获取房间信息.获取标题(DownIofo.房间_频道号),
Expand All @@ -595,6 +598,24 @@ private void 下载完成事件(object sender, AsyncCompletedEventArgs e)
false,
DownIofo.文件保存路径
);
}
catch (Exception)
{
try
{
下载对象.DownIofo.备注 = "新建续下载对象出现异常,放弃新建任务";
下载结束提醒(true);

下载对象.DownIofo.下载状态 = false;
下载对象.DownIofo.结束时间 = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
下载对象.DownIofo.WC.CancelAsync();
MMPU.DownList.Remove(下载对象);
}
catch (Exception)
{

}
}
}
})).Start();
}
Expand Down
4 changes: 2 additions & 2 deletions Auxiliary/MMPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static bool 配置文件初始化(int 模式)
{
InfoLog.InfoInit("./DDTVLiveRecLog.out", new InfoLog.InfoClasslBool()
{
Debug = true,
Debug = false,
下载必要提示 = true,
杂项提示 = false,
系统错误信息 = true,
Expand Down Expand Up @@ -821,7 +821,7 @@ public static void 文件删除委托(string file)
return;
}
i++;
Thread.Sleep(100);
Thread.Sleep(500);
}
}
catch (Exception)
Expand Down
4 changes: 2 additions & 2 deletions Auxiliary/bilibili.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static void 更新VTBS房间数据()
}

JArray JO = (JArray)JsonConvert.DeserializeObject(vtbs房间数据);
InfoLog.InfoPrintf($"获取VTBS房间数据完成:{JO}", InfoLog.InfoClass.Debug);
//InfoLog.InfoPrintf($"获取VTBS房间数据完成:{JO}", InfoLog.InfoClass.Debug);
foreach (var item in JO)
{
if (int.Parse(item["roomid"].ToString()) != 0)
Expand Down Expand Up @@ -497,7 +497,7 @@ public string getDanmaku(string RoomID)
string url = @"http://api.live.bilibili.com/ajax/msg";
List<danmuA> 返回的弹幕数据 = new List<danmuA>();
WebClient webClient = new WebClient();
webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36");
webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36");
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
if (!string.IsNullOrEmpty(MMPU.Cookie))
{
Expand Down
4 changes: 2 additions & 2 deletions DDTV_New/DDTV_New.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.0.2.%2a</ApplicationVersion>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>2.0.4.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down

0 comments on commit 7ed17e9

Please sign in to comment.