Skip to content

Commit

Permalink
修复GUI里HLS的等待时间设置为10无法保存的问题;将HLS的录制输出文件名时间修正为任务开始时间
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Mar 22, 2023
1 parent e0538f7 commit 2976fe3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 30 deletions.
6 changes: 3 additions & 3 deletions DDTV_Core/SystemAssembly/DownloadModule/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ internal static void VideoDownloadCompleteTaskd_HLS(long uid, DownloadClass.Down
Log.Log.AddLog(nameof(Download), Log.LogClass.LogType.Info, $"开始执行[{roomInfo.uname}({roomInfo.room_id})]直播间的下载任务结束处理任务");
if (DownloadPath.Substring(DownloadPath.Length - 1, 1) != "/")
DownloadPath = DownloadPath + "/";
string OkFileName = Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadPath}" + $"{DownloadDirectoryName}" + $"/{DownloadFolderName}/" + $"{DownloadFileName}" + "_{R}.mp4");
string OkFileName = Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadPath}" + $"{DownloadDirectoryName}" + $"/{DownloadFolderName}/" + $"{DownloadFileName}" + "_{R}.mp4",downloadClass.StartTime);

SaveCover(uid);
//弹幕录制结束处理
Expand All @@ -165,7 +165,7 @@ internal static void VideoDownloadCompleteTaskd_HLS(long uid, DownloadClass.Down
roomInfo.roomWebSocket.LiveChatListener.Dispose();
if (RealTimeTitleFileName)
{
roomInfo.DanmuFile.FileName = roomInfo.DanmuFile.FileName.Replace(roomInfo.DanmuFile.FileName.Split('/')[roomInfo.DanmuFile.FileName.Split('/').Length - 1].Split('.')[0], Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadFileName}"));
roomInfo.DanmuFile.FileName = roomInfo.DanmuFile.FileName.Replace(roomInfo.DanmuFile.FileName.Split('/')[roomInfo.DanmuFile.FileName.Split('/').Length - 1].Split('.')[0], Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadFileName}",downloadClass.StartTime));
}
Tool.DanMuKu.DanMuKuRec.SevaDanmuFile(roomInfo);
if (IsRecDanmu && GUIConfig.IsXmlToAss)
Expand Down Expand Up @@ -210,7 +210,7 @@ internal static void VideoDownloadCompleteTaskd_HLS(long uid, DownloadClass.Down
string After = string.Empty;
if(RealTimeTitleFileName)
{
After = item.FilePath.Replace(item.FilePath.Split('/')[item.FilePath.Split('/').Length - 1].Split('.')[0], Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadFileName}_{index}")).Replace(".mp4", "_fix.mp4").Replace(".flv", "_fix.mp4");
After = item.FilePath.Replace(item.FilePath.Split('/')[item.FilePath.Split('/').Length - 1].Split('.')[0], Tool.FileOperation.ReplaceKeyword(uid, $"{DownloadFileName}_{index}",downloadClass.StartTime)).Replace(".mp4", "_fix.mp4").Replace(".flv", "_fix.mp4");
}
else
{
Expand Down
1 change: 1 addition & 0 deletions DDTV_Core/SystemAssembly/DownloadModule/DownloadClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class Downloads
/// 该任务下所有任务的总下载字节数
/// </summary>
public long TotalDownloadCount { get; set; }

/// <summary>
/// 下载状态
/// </summary>
Expand Down
80 changes: 54 additions & 26 deletions DDTV_Core/Tool/FileOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public static string CheckFilenames(string Text)
/// </summary>
/// <param name="Text"></param>
/// <returns></returns>
public static string ReplaceKeyword(long uid, string Text)
{
public static string ReplaceKeyword(long uid, string Text ,DateTime dateTime = default)
{
Rooms.RoomInfo.TryGetValue(uid, out RoomInfoClass.RoomInfo roomInfo);

if (roomInfo.DownloadedFileInfo.AfterRepairFiles != null)
Expand Down Expand Up @@ -151,30 +151,58 @@ public static string ReplaceKeyword(long uid, string Text)

if (roomInfo.DownloadedFileInfo.GiftFile != null)
Text = Text.Replace("{GiftFile}", roomInfo.DownloadedFileInfo.GiftFile.FullName);

Text = Text
.Replace("{ROOMID}", Rooms.GetValue(uid, CacheType.room_id))
.Replace("{YYYY}", DateTime.Now.ToString("yyyy"))
.Replace("{YY}", DateTime.Now.ToString("yy"))
.Replace("{MM}", DateTime.Now.ToString("MM"))
.Replace("{DD}", DateTime.Now.ToString("dd"))
.Replace("{HH}", DateTime.Now.ToString("HH"))
.Replace("{mm}", DateTime.Now.ToString("mm"))
.Replace("{SS}", DateTime.Now.ToString("ss"))
.Replace("{FFFF}", DateTime.Now.ToString("fff"))
.Replace("{yyyy}", DateTime.Now.ToString("yyyy"))
.Replace("{yy}", DateTime.Now.ToString("yy"))
.Replace("{MM}", DateTime.Now.ToString("MM"))
.Replace("{dd}", DateTime.Now.ToString("dd"))
.Replace("{HH}", DateTime.Now.ToString("HH"))
.Replace("{mm}", DateTime.Now.ToString("mm"))
.Replace("{ss}", DateTime.Now.ToString("ss"))
.Replace("{fff}", DateTime.Now.ToString("fff"))
.Replace("{NAME}", Rooms.GetValue(uid, CacheType.uname))
.Replace("{DATE}", DateTime.Now.ToString("yyyy_MM_dd"))
.Replace("{TIME}", DateTime.Now.ToString("HH_mm_ss"))
.Replace("{TITLE}", Rooms.GetValue(uid, CacheType.title))
.Replace("{R}", GetRandomStr(null, 5));
if(dateTime!=default)
{
Text = Text
.Replace("{ROOMID}", Rooms.GetValue(uid, CacheType.room_id))
.Replace("{YYYY}", dateTime.ToString("yyyy"))
.Replace("{YY}", dateTime.ToString("yy"))
.Replace("{MM}", dateTime.ToString("MM"))
.Replace("{DD}", dateTime.ToString("dd"))
.Replace("{HH}", dateTime.ToString("HH"))
.Replace("{mm}", dateTime.ToString("mm"))
.Replace("{SS}", dateTime.ToString("ss"))
.Replace("{FFFF}", dateTime.ToString("fff"))
.Replace("{yyyy}", dateTime.ToString("yyyy"))
.Replace("{yy}", dateTime.ToString("yy"))
.Replace("{MM}", dateTime.ToString("MM"))
.Replace("{dd}", dateTime.ToString("dd"))
.Replace("{HH}", dateTime.ToString("HH"))
.Replace("{mm}", dateTime.ToString("mm"))
.Replace("{ss}", dateTime.ToString("ss"))
.Replace("{fff}", dateTime.ToString("fff"))
.Replace("{NAME}", Rooms.GetValue(uid, CacheType.uname))
.Replace("{DATE}", dateTime.ToString("yyyy_MM_dd"))
.Replace("{TIME}", dateTime.ToString("HH_mm_ss"))
.Replace("{TITLE}", Rooms.GetValue(uid, CacheType.title))
.Replace("{R}", GetRandomStr(null, 5));
}
else
{
Text = Text
.Replace("{ROOMID}", Rooms.GetValue(uid, CacheType.room_id))
.Replace("{YYYY}", DateTime.Now.ToString("yyyy"))
.Replace("{YY}", DateTime.Now.ToString("yy"))
.Replace("{MM}", DateTime.Now.ToString("MM"))
.Replace("{DD}", DateTime.Now.ToString("dd"))
.Replace("{HH}", DateTime.Now.ToString("HH"))
.Replace("{mm}", DateTime.Now.ToString("mm"))
.Replace("{SS}", DateTime.Now.ToString("ss"))
.Replace("{FFFF}", DateTime.Now.ToString("fff"))
.Replace("{yyyy}", DateTime.Now.ToString("yyyy"))
.Replace("{yy}", DateTime.Now.ToString("yy"))
.Replace("{MM}", DateTime.Now.ToString("MM"))
.Replace("{dd}", DateTime.Now.ToString("dd"))
.Replace("{HH}", DateTime.Now.ToString("HH"))
.Replace("{mm}", DateTime.Now.ToString("mm"))
.Replace("{ss}", DateTime.Now.ToString("ss"))
.Replace("{fff}", DateTime.Now.ToString("fff"))
.Replace("{NAME}", Rooms.GetValue(uid, CacheType.uname))
.Replace("{DATE}", DateTime.Now.ToString("yyyy_MM_dd"))
.Replace("{TIME}", DateTime.Now.ToString("HH_mm_ss"))
.Replace("{TITLE}", Rooms.GetValue(uid, CacheType.title))
.Replace("{R}", GetRandomStr(null, 5));
}
return Text;
}

Expand Down
6 changes: 5 additions & 1 deletion DDTV_GUI/DDTV_Window/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1941,14 +1941,18 @@ private void HLSToggle_Click(object sender, RoutedEventArgs e)
private void WaitHLSTime_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs<double> e)
{

if (InitDDTV_Core.WhetherInitializationIsComplet && e.Info > 10)
if (InitDDTV_Core.WhetherInitializationIsComplet && e.Info >= 10)
{
DDTV_Core.SystemAssembly.DownloadModule.Download.WaitHLSTime = (int)e.Info;
CoreConfig.SetValue(CoreConfigClass.Key.WaitHLSTime, ((int)e.Info).ToString(), CoreConfigClass.Group.Download);
Growl.Success($"设置HLS等待时间为{(int)e.Info}秒");
Log.AddLog(nameof(MainWindow), LogClass.LogType.Debug, $"设置HLS等待时间为{(int)e.Info}秒", false, null, false);
CoreConfigFile.WriteConfigFile(true);
}
else
{
Growl.Warning($"设置HLS等待时间最低需要等待10秒");
}
}

private void OpenSeparateDanMuWindow_MenuItem_Click(object sender, RoutedEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions DDTV_GUI/UpdateInterface/LiveListPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal class LiveListPage
Dictionary<long, RoomInfoClass.RoomInfo> keyValuePairs = new Dictionary<long, RoomInfoClass.RoomInfo>();
foreach (var item in NotLive.OrderBy(p => p.Value.uname).ToDictionary(p => p.Key, o => o.Value))
{
//如果该房间的“开播提醒”、“自动录制”、“弹幕录制”任意一个已经打开,这个房间在列表中优先靠前
if (item.Value.IsRemind || item.Value.IsAutoRec || item.Value.IsRecDanmu)
{
IsLive.Add(item.Key, item.Value);
Expand Down

0 comments on commit 2976fe3

Please sign in to comment.