private static void AnalyseFs() { Console.WriteLine($"Starting analysing at '{DateTime.Now}'..."); Stopwatch watch = Stopwatch.StartNew(); Result analyseResult = new AnalyseService().Analyse(); TimeSpan elapsed = watch.Elapsed; Console.WriteLine($"Analysis ended in '{elapsed}' - result:\n{analyseResult.Serialize()}"); Console.WriteLine(); }
public Application(AnalyseService analyseService, DataProcessService dataProcessService) { _analyseService = analyseService; _dataProcessService = dataProcessService; _methods = new List <KeyValuePair <int, MethodInfo> >(); }
public IActionResult AnalyseCore([FromQuery] string rk) { var ckplayerJson = new CKPlayerJsonViewModel() { autoplay = true }; var url = string.Empty; var gkey = string.Empty; var timestamp = string.Empty; var sign = string.Empty; if (!DecodeRequestKey(rk, out url, out gkey, out timestamp, out sign)) { return(Json(new { errorCode = -9998, msg = "参数错误,请求非法!" })); } //url解码 验证签名需要 url = FormatHelper.UrlDecode(url); if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(gkey) | string.IsNullOrEmpty(timestamp) | string.IsNullOrEmpty(sign)) { return(Json(new { errorCode = -9999, msg = "参数错误,请求非法!" })); } long.TryParse(timestamp, out long timestampl); var time = FormatHelper.ConvertToDateTime(timestampl); //不得超过2分钟 if (DateTime.Compare(time.AddMinutes(2), DateTime.Now) < 0) { return(Json(new { errorCode = -10000, msg = "请求已过期" })); } //gkey需要与会话一致 var server_gkey = HttpContext.Session.GetString("gkey"); if (gkey != server_gkey) { return(Json(new { errorCode = -10001, msg = "会话超时,请求非法!" })); } //校验签名 if (!ValidateSign(url, gkey, timestamp, sign)) { return(Json(new { errorCode = -10002, msg = "签名错误,请求非法!" })); } var cacheKey = $"analyse_{url}"; var response = new VideoAnalyseResponse(); if (!_memoryCache.TryGetValue(cacheKey, out response)) { response = AnalyseService.Analyse(_configInfos["ConfigInfos:AnalyseServiceAddress"], url); if (response != null && response.ErrCode == 0 && response.Data.Count > 0) { _memoryCache.Set(cacheKey, response, new DateTimeOffset(DateTime.Now.AddHours(1))); } } //处理数据 var result = new List <string>(); var name = string.Empty; if (response == null || response.ErrCode != 0) { //result.Add("http://movie.ks.js.cn/flv/other/1_0.mp4"); //解析失败 //应该返回错误 todo 这里返回null } else { //可能会有多个视频 这里只取第一个 var video = response.Data.FirstOrDefault(); if (video != null) { var ckvideo = new CKVideo() { type = "mp4", weight = 0, definition = video.Definition }; foreach (var item in video.Part) { if (!string.IsNullOrEmpty(item.Url)) { ckvideo.video.Add(new CKVideoInfo() { file = item.Url, duration = item.Duration }); } } ckplayerJson.video.Add(ckvideo); } } return(Json(ckplayerJson)); }