public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken) { var list = new List <RemoteSearchResult>(); if (string.IsNullOrWhiteSpace(searchInfo.Name)) { return(list); } var javid = JavIdRecognizer.Parse(searchInfo.Name); _logger?.Info($"{Name}-{nameof(GetSearchResults)} id:{javid?.id} info:{_jsonSerializer.SerializeToString(searchInfo)}"); //自动搜索的时候,Name=文件夹名称,有时候是不对的,需要跳过 if (javid == null && (searchInfo.Name.Length > 12 || !regexNum.IsMatch(searchInfo.Name))) { return(list); } var key = javid?.id ?? searchInfo.Name; var scrapers = this.scrapers; var enableScrapers = Plugin.Instance?.Configuration?.GetEnableScrapers?.Select(o => o.Name).ToList(); if (enableScrapers?.Any() == true) { scrapers = scrapers.Where(o => enableScrapers.Contains(o.Name)).ToList(); } var tasks = scrapers.Select(o => o.Query(key)).ToArray(); await Task.WhenAll(tasks); var all = tasks.Where(o => o.Result?.Any() == true).SelectMany(o => o.Result).ToList(); _logger?.Info($"{Name}-{nameof(GetSearchResults)} name:{searchInfo.Name} id:{javid?.id} count:{all.Count}"); if (all.Any() != true) { return(list); } all = scrapers .Join(all.GroupBy(o => o.Provider), o => o.Name, o => o.Key, (o, v) => v) .SelectMany(o => o) .ToList(); foreach (var m in all) { var result = new RemoteSearchResult { Name = $"{m.Num} {m.Title}", ProductionYear = m.GetYear(), ImageUrl = Plugin.Instance.Configuration.BuildProxyUrl(m.Cover), SearchProviderName = Name, PremiereDate = m.GetDate(), }; result.SetJavVideoIndex(_jsonSerializer, m); list.Add(result); } return(list); }
/// <summary> /// 识别 /// </summary> /// <param name="file">文件路径</param> /// <returns></returns> public static JavId Parse(string file) { var name = Path.GetFileNameWithoutExtension(file); var id = JavIdRecognizer.Parse(name); if (id != null) { id.file = file; } return(id); }