修复 新的工作流未能获取到导致NodePackage接口失效问题
This commit is contained in:
parent
a2b3c53898
commit
ea949f0825
|
|
@ -253,7 +253,7 @@ namespace Learn.VideoAnalysis.API.Expand
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now}=>接口规范出现异常");
|
||||
Console.WriteLine($"{DateTime.Now}=>接口出现异常");
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,94 +28,13 @@ namespace Learn.VideoAnalysis
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static void CleanHarFile(string inputPath, string outputPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. 读取原始文件
|
||||
var jsonString = File.ReadAllText(inputPath);
|
||||
var root = JsonNode.Parse(jsonString)!;
|
||||
var entries = root["log"]?["entries"]?.AsArray();
|
||||
|
||||
if (entries == null) return;
|
||||
|
||||
// 过滤关键词
|
||||
var blackList = new[] { "google", "gstatic", "doubleclick", "analytics", "facebook", "recaptcha" };
|
||||
|
||||
// 2. 逻辑清理 (从后往前)
|
||||
for (int i = entries.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var entry = entries[i];
|
||||
string url = entry?["request"]?["url"]?.GetValue<string>().ToLower() ?? "";
|
||||
string resourceType = entry?["_resourceType"]?.GetValue<string>().ToLower() ?? "";
|
||||
|
||||
// 判定是否保留 (必须是 API 且 不在黑名单内)
|
||||
bool isApi = (resourceType == "xhr" || resourceType == "fetch");
|
||||
bool isBlacklisted = blackList.Any(k => url.Contains(k));
|
||||
|
||||
if (!isApi || isBlacklisted)
|
||||
{
|
||||
entries.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. 结构瘦身
|
||||
if (entry?["_initiator"] is JsonObject initiator)
|
||||
{
|
||||
initiator.Remove("stack");
|
||||
initiator.Remove("callFrames");
|
||||
}
|
||||
|
||||
// 移除所有以下划线开头的非标准扩展字段 (Chrome 专用字段)
|
||||
var entryObj = entry.AsObject();
|
||||
var keysToRemove = entryObj.Where(kv => kv.Key.StartsWith("_")).Select(kv => kv.Key).ToList();
|
||||
foreach (var key in keysToRemove) entryObj.Remove(key);
|
||||
}
|
||||
|
||||
// 4. 极限压缩配置
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
// 核心:禁用缩进,输出单行压缩格式
|
||||
WriteIndented = false,
|
||||
// 核心:防止斜杠等字符被转义成 \u002F,保持原始字符减少长度
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
// 忽略值为 null 的字段,进一步减小体积
|
||||
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
|
||||
};
|
||||
|
||||
// 5. 写入文件
|
||||
string compressedJson = root.ToJsonString(options);
|
||||
File.WriteAllText(outputPath, compressedJson);
|
||||
|
||||
long originalSize = new FileInfo(inputPath).Length;
|
||||
long newSize = new FileInfo(outputPath).Length;
|
||||
|
||||
Console.WriteLine("--- 压缩统计 ---");
|
||||
Console.WriteLine($"原始大小: {originalSize / 1024.0:F2} KB");
|
||||
Console.WriteLine($"压缩后大小: {newSize / 1024.0:F2} KB");
|
||||
Console.WriteLine($"压缩率: {(1.0 - (double)newSize / originalSize) * 100:F2}%");
|
||||
Console.WriteLine($"保留请求数: {entries.Count}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"处理失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// 调用方法
|
||||
CleanHarFile("C:\\Users\\Administrator\\Downloads\\kream.co.kr.har", "C:\\Users\\Administrator\\Downloads\\kream.co.kr.API压缩.har");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//交互式环境选择函数
|
||||
AppConfigExpand.SelectEnvironment(ref args);
|
||||
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
//设置接口请求体最大100m
|
||||
builder.WebHost.ConfigureKestrel(serverOptions =>
|
||||
|
|
|
|||
|
|
@ -152,7 +152,14 @@ namespace VideoAnalysisCore.Common
|
|||
Redis = redis;
|
||||
}
|
||||
|
||||
|
||||
public void JoinQueue(string ChannelKey,params long[] taskIds)
|
||||
{
|
||||
if (taskIds is null || taskIds.Length == 0)
|
||||
return;
|
||||
// 直接批量推入,避免循环和事务开销
|
||||
var d = taskIds.Select(s => (object)s).ToArray();
|
||||
Redis.LPush(ChannelKey, d);
|
||||
}
|
||||
/// <summary>
|
||||
/// 缓存GPT任务缓存
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -40,11 +40,10 @@ namespace VideoAnalysisCore.Controllers
|
|||
private readonly Repository<VideoQuestion> videoQuestionDB;
|
||||
private readonly Repository<VideoQuestionKonw> videoQuestionKonwDB;
|
||||
private readonly RedisManager redisManager;
|
||||
readonly VideoSliceWorkflowManager videoSliceWorkflowManager;
|
||||
|
||||
public LJZK_Controller(IMapper mp, Repository<NodeSubscription> nodesubscriptionDB,
|
||||
Repository<VideoTask> videoTaskDB = null, Repository<VideoKonwPoint> videoKonwPointDB = null
|
||||
, Repository<NodePackageInfo> nodePackageInfoDB = null, Repository<VideoQuestion> videoQuestionDB = null, Repository<VideoQuestionKonw> videoQuestionKonwDB = null, Repository<CourseInfo> courseInfoDB = null, RedisManager redisManager = null, Repository<VideoTaskStage> videoTaskStageDB = null, VideoSliceWorkflowManager videoSliceWorkflowManager = null)
|
||||
, Repository<NodePackageInfo> nodePackageInfoDB = null, Repository<VideoQuestion> videoQuestionDB = null, Repository<VideoQuestionKonw> videoQuestionKonwDB = null, Repository<CourseInfo> courseInfoDB = null, RedisManager redisManager = null, Repository<VideoTaskStage> videoTaskStageDB = null)
|
||||
{
|
||||
this.mp = mp;
|
||||
this.nodesubscriptionDB = nodesubscriptionDB;
|
||||
|
|
@ -56,7 +55,6 @@ namespace VideoAnalysisCore.Controllers
|
|||
this.courseInfoDB = courseInfoDB;
|
||||
this.redisManager = redisManager;
|
||||
this.videoTaskStageDB = videoTaskStageDB;
|
||||
this.videoSliceWorkflowManager = videoSliceWorkflowManager;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -69,7 +67,6 @@ namespace VideoAnalysisCore.Controllers
|
|||
[HttpPost(Name = "NodePackage")]
|
||||
public async Task<IActionResult> NodePackage(NodePackageReq[] reqArr)
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now} Îļþ°ü¶©ÔÄÇëÇóÊýÁ¿ req=" + reqArr.Count());
|
||||
if (reqArr is null || reqArr.Count() == 0)
|
||||
return BadRequest("ÎÞЧÊÓÆµÁбíÊý¾Ý");
|
||||
var videos = new List<VideoTask>(reqArr.Count());
|
||||
|
|
@ -160,7 +157,7 @@ namespace VideoAnalysisCore.Controllers
|
|||
if (videos is null || videos.Count == 0)
|
||||
return Ok();
|
||||
var ids = videos.Select(s => s.Id).ToArray();
|
||||
videoSliceWorkflowManager.JoinQueue(ids);
|
||||
redisManager.JoinQueue(RedisExpandKey.ChannelKey, ids);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,9 @@ namespace VideoAnalysisCore.Job
|
|||
else
|
||||
{
|
||||
var res = await responseMessage.Content.ReadAsStringAsync();
|
||||
Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调失败!!! {responseMessage.StatusCode} {res}");
|
||||
Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调失败!!! VideoCode{item.VideoCode}");
|
||||
Console.WriteLine($"{responseMessage.StatusCode} {postUrl}");
|
||||
Console.WriteLine(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -121,7 +123,10 @@ namespace VideoAnalysisCore.Job
|
|||
if (responseMessage != null)
|
||||
{
|
||||
var res = (await responseMessage?.Content?.ReadAsStringAsync()) ?? string.Empty;
|
||||
Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调失败!!! {responseMessage?.StatusCode} {res}");
|
||||
Console.WriteLine($"{DateTime.Now} 执行=>文件包任务 回调失败!!! VideoCode{item.VideoCode}");
|
||||
Console.WriteLine($"{responseMessage.StatusCode} {ex.Message} ");
|
||||
Console.WriteLine($"{ ex.StackTrace}");
|
||||
Console.WriteLine(res);
|
||||
}
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue