Skip to content

Commit

Permalink
删除房间时会自动删除取消该房间的录制任务;修改录制二级目录日期格式为yy_MM_dd;
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jan 8, 2022
1 parent 6e2e7a5 commit 77c0b67
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
11 changes: 6 additions & 5 deletions DDTV_Core/SystemAssembly/ConfigModule/RoomConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,19 @@ public static void DeleteRoom(List<long> uidLis)
/// <summary>
/// 删除房间
/// </summary>
/// <param name="uidLis"></param>
public static bool DeleteRoom(long uidLis)
/// <param name="UID"></param>
public static bool DeleteRoom(long UID)
{
bool IsOK = false;
if (Rooms.RoomInfo.TryGetValue(uidLis, out RoomInfoClass.RoomInfo roomInfo))
if (Rooms.RoomInfo.TryGetValue(UID, out RoomInfoClass.RoomInfo roomInfo))
{
Rooms.RoomInfo.Remove(uidLis);
DownloadModule.Download.CancelDownload(UID);
Rooms.RoomInfo.Remove(UID);
IsOK = true;
}
else
{
Log.Log.AddLog(nameof(RoomConfig), Log.LogClass.LogType.Warn, $"想要删除的房间不存在于配置中(UID:{uidLis}),删除失败");
Log.Log.AddLog(nameof(RoomConfig), Log.LogClass.LogType.Warn, $"想要删除的房间不存在于配置中(UID:{UID}),删除失败");
IsOK = false;
}
RoomConfigFile.WriteRoomConfigFile();
Expand Down
7 changes: 4 additions & 3 deletions DDTV_Core/SystemAssembly/DownloadModule/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Download
public static bool IsRecSC = bool.Parse(CoreConfig.GetValue(CoreConfigClass.Key.IsRecSC, "true", CoreConfigClass.Group.Download));
public static bool IsFlvSplit = bool.Parse(CoreConfig.GetValue(CoreConfigClass.Key.IsFlvSplit, "false", CoreConfigClass.Group.Download));
public static long FlvSplitSize = long.Parse(CoreConfig.GetValue(CoreConfigClass.Key.FlvSplitSize, "1073741824", CoreConfigClass.Group.Download));

/// <summary>
/// 下载完成事件
/// </summary>
Expand Down Expand Up @@ -92,7 +93,7 @@ internal static void DownloadCompleteTaskd(long uid, bool Split = false, bool Is
} while (roomInfo.IsCliping);
if (DefaultPath.Substring(DefaultPath.Length - 1, 1) != "/")
DefaultPath = DefaultPath + "/";
string OkFileName = Tool.FileOperation.ReplaceKeyword(uid, $"{DefaultPath}" + $"{DefaultDirectoryName}" + $"/{roomInfo.CreationTime.ToString("MM_d")}/" + $"{DefaultFileName}" + "_{R}.flv");
string OkFileName = Tool.FileOperation.ReplaceKeyword(uid, $"{DefaultPath}" + $"{DefaultDirectoryName}" + $"/{roomInfo.CreationTime.ToString("yy_MM_dd")}/" + $"{DefaultFileName}" + "_{R}.flv");

//弹幕录制结束处理
if (bool.Parse(Rooms.GetValue(uid, DataCacheModule.DataCacheClass.CacheType.IsAutoRec)) && roomInfo.roomWebSocket.IsConnect)
Expand Down Expand Up @@ -277,13 +278,13 @@ private static void AddDownLoad(long uid, bool IsNewTask)
downloadClass.FilePath = Path;
downloadClass.FlvSplit = IsFlvSplit;
downloadClass.FlvSplitSize = FlvSplitSize;
Tool.FileOperation.CreateAll(Path+ $"/{roomInfo.CreationTime.ToString("MM_d")}");
Tool.FileOperation.CreateAll(Path+ $"/{roomInfo.CreationTime.ToString("yy_MM_dd")}");
downloadClass.DownFLV_HttpWebRequest(downloadClass, req, Path, FileName, "flv", roomInfo);
//录制弹幕(是否是新任务 && 弹幕录制总开关 && 房间弹幕录制设置)
if (IsNewTask && IsRecDanmu && bool.Parse(Rooms.GetValue(uid, DataCacheModule.DataCacheClass.CacheType.IsRecDanmu)))
{
roomInfo.DanmuFile = new();
roomInfo.DanmuFile.FileName = Path + $"/{roomInfo.CreationTime.ToString("MM_d")}/" + FileName;
roomInfo.DanmuFile.FileName = Path + $"/{roomInfo.CreationTime.ToString("yy_MM_dd")}/" + FileName;
BilibiliModule.API.DanMu.DanMuRec.Rec(uid);
}
}
Expand Down
4 changes: 2 additions & 2 deletions DDTV_Core/SystemAssembly/DownloadModule/DownloadClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ internal void DownFLV_HttpWebRequest(Downloads downloads, HttpWebRequest req, st
int count = 1;
//Path="D:"+Path.Substring(1, Path.Length-1);
Path = Tool.FileOperation.CreateAll(Path);
string _F = Path + $"/{roomInfo.CreationTime.ToString("MM_d")}/" + FileName + "_" + count + "." + format;
string _F = Path + $"/{roomInfo.CreationTime.ToString("yy_MM_dd")}/" + FileName + "_" + count + "." + format;
downloads.FileName = _F;
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
Expand Down Expand Up @@ -246,7 +246,7 @@ internal void DownFLV_HttpWebRequest(Downloads downloads, HttpWebRequest req, st
count++;
fileStream.Close();
fileStream.Dispose();
string _F2 = Path + $"/{roomInfo.CreationTime.ToString("MM_d")}/" + FileName + "_" + count + "." + format;
string _F2 = Path + $"/{roomInfo.CreationTime.ToString("yy_MM_dd")}/" + FileName + "_" + count + "." + format;
fileStream = new FileStream(_F2, FileMode.Create);
byte[] buffer = new byte[9 + 15] { FlvHeader.Signature[0], FlvHeader.Signature[1], FlvHeader.Signature[2], FlvHeader.Version, FlvHeader.Type, FlvHeader.FlvHeaderOffset[0], FlvHeader.FlvHeaderOffset[1], FlvHeader.FlvHeaderOffset[2], FlvHeader.FlvHeaderOffset[3], 0x00, 0x00, 0x00, 0x01, FlvScriptTag.TagType, FlvScriptTag.TagDataSize[0], FlvScriptTag.TagDataSize[1], FlvScriptTag.TagDataSize[2], FlvScriptTag.Timestamp[3], FlvScriptTag.Timestamp[2], FlvScriptTag.Timestamp[1], FlvScriptTag.Timestamp[0], 0x00, 0x00, 0x00 };
fileStream.Write(buffer, 0, buffer.Length);
Expand Down
6 changes: 5 additions & 1 deletion DDTV_Core/SystemAssembly/NetworkRequestModule/Get/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Get
/// </summary>
/// <param name="url">目标网页地址</param>
/// <returns></returns>
public static string GetRequest(string url, bool IsCookie = true, string R = "")
public static string GetRequest(string url, bool IsCookie = true, string R = "", string referer = "")
{
Log.Log.AddLog(nameof(Get), Log.LogClass.LogType.Debug, $"发出网络请求:{url.Split('?')[0]}", false, null, false);
if (string.IsNullOrEmpty(url))
Expand All @@ -32,6 +32,10 @@ public static string GetRequest(string url, bool IsCookie = true, string R = "")
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3";
req.UserAgent = NetClass.UA();
req.Headers.Add(HttpRequestHeader.CacheControl, "max-age=0");
if (!string.IsNullOrEmpty(referer))
{
req.Referer = referer;
}
if (!string.IsNullOrEmpty(R))
{
req.Referer = R;// "https://Update.ddtv.pro/";
Expand Down
1 change: 0 additions & 1 deletion DDTV_WEB_Server/ProcessingControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public override void OnActionExecuting(ActionExecutingContext filterContext)
else
{
//这里应该是进行sig校验的地方

}
}
}
Expand Down
13 changes: 1 addition & 12 deletions DDTV_WEB_Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,12 @@ public static void Main(string[] args)
string Ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "-" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
Console.WriteLine(Ver);
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
var corsPolicyName = "AllowSpecificOrigins";
builder.Host.ConfigureServices(Services =>
{
Services.AddControllers();
Services.AddEndpointsApiExplorer();
Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
options.AddPolicy(name: corsPolicyName,
builder =>
{
builder.WithOrigins("http://*.*.*.*", "https://*.*.*.*")//.SetIsOriginAllowedToAllowWildcardSubdomains()//设置允许访问的域
.AllowAnyHeader()
.AllowAnyMethod();
});
});

Services.AddMvc();
//注册Cookie认证服务
Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
Expand Down Expand Up @@ -78,7 +68,6 @@ public static void Main(string[] args)
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors(corsPolicyName);
app.UseMiddleware<CorsMiddleware.AccessControlAllowOrigin>();
//app.UseHttpsRedirection();
app.UseAuthorization();
Expand Down

0 comments on commit 77c0b67

Please sign in to comment.