/// <summary> /// 搜索资料 /// </summary> /// <param name="num">番号</param> /// <returns></returns> private MovieInfo SearchInfoFromNum(string num) { //尝试直接打开番号 HtmlWeb web = new HtmlWeb(); var detailUrl = $"https://www.dmmbus.cloud/{num}"; var type = NumberTools.IsUncensored(num); string searchUrl = $"https://www.dmmbus.cloud/{(type ? "uncensored/" : "")}search/{num}&type=1"; var doc = web.Load(detailUrl); var notFound = doc.DocumentNode.SelectSingleNode("/html/body/div[4]/div/div/h4"); //404 if (notFound != null) { detailUrl = null; //没找到, 搜索一下 doc = web.Load(searchUrl); var nodes = doc.DocumentNode.SelectNodes("//*[@id=\"waterfall\"]/div[@id=\"waterfall\"]/div"); if (nodes == null) { //没搜索到 return(null); } foreach (var item in nodes) { var s_num = item.SelectSingleNode("a/div[2]/span/date[1]").InnerText; if (s_num.Replace("-", "").Replace("_", "").ToLower().Contains(num.Replace("-", "").Replace("_", "").ToLower())) { detailUrl = item.SelectSingleNode("a").Attributes["href"].Value; doc = web.Load(detailUrl); break; } } } if (!string.IsNullOrEmpty(detailUrl)) { var movie = new MovieInfo(); var body = doc.DocumentNode; var node = body.SelectSingleNode("/html/body/div[5]/div[1]/div[1]/a/img"); movie.Backdrop = node.Attributes["src"].Value; movie.Title = node.Attributes["title"].Value; //获取所有P var nodes = body.SelectNodes("/html/body/div[5]/div[1]/div[2]/p"); if (nodes != null) { movie.Year = nodes[1].InnerText.Replace("發行日期:", "").Replace(" ", ""); movie.Length = nodes[2].InnerText.Replace("長度:", "").Replace(" ", ""); if (nodes[3].InnerText.Contains("導演:")) { movie.Direct = nodes[3].InnerText.Replace("導演:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[4].InnerText.Contains("製作商:")) { movie.Studio = nodes[4].InnerText.Replace("製作商:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[5].InnerText.Contains("發行商:")) { movie.Publisher = nodes[5].InnerText.Replace("發行商:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[6].InnerText.Contains("類別:")) { List <string> list = new List <string>(); foreach (var sub in nodes[7].ChildNodes) { var name = sub.InnerText.Replace("\t", "").Replace("\n", "").Replace("\r", "").Replace(" ", ""); if (name != "") { list.Add(name); } } movie.Genre = list; } } } } else { if (nodes[3].InnerText.Contains("製作商:")) { movie.Studio = nodes[3].InnerText.Replace("製作商:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[4].InnerText.Contains("發行商:")) { movie.Publisher = nodes[4].InnerText.Replace("發行商:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[5].InnerText.Contains("類別:")) { List <string> list = new List <string>(); foreach (var sub in nodes[5].ChildNodes) { var name = sub.InnerText.Replace("\t", "").Replace("\n", "").Replace("\r", "").Replace(" ", ""); if (name != "") { list.Add(name); } } movie.Genre = list; } } else { if (!nodes[4].InnerText.Contains("演員:")) { movie.Series = nodes[4].InnerText.Replace("系列:", "").Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", ""); if (nodes[5].InnerText.Contains("類別:")) { List <string> list = new List <string>(); foreach (var sub in nodes[6].ChildNodes) { var name = sub.InnerText.Replace("\t", "").Replace("\n", "").Replace("\r", "").Replace(" ", ""); if (name != "") { list.Add(name); } } movie.Genre = list; } } } } } if (!nodes[nodes.Count - 1].InnerText.Contains("演員:")) { List <string> list1 = new List <string>(); foreach (var sub in nodes[nodes.Count - 1].ChildNodes) { var name = sub.InnerText.Replace("\t", "").Replace("\n", "").Replace("\r", "").Replace(" ", ""); if (name != "") { list1.Add(name); } } movie.Star = list1; } } movie.WebSite = detailUrl; movie.Generate = "javbus"; return(movie); } return(null); }
private void AddCard() { Invoke(new EventHandler((o1, e1) => { tabControlPanel4.Controls.RemoveByKey("cardPanel"); })); var flowLayoutPanel1 = new Panel() { Name = "cardPanel", AutoScroll = true, Location = new Point(55, 44), Size = new Size(tabControlPanel4.Width - 479, tabControlPanel4.Height - 8), BorderStyle = BorderStyle.None, BackColor = Color.White }; var count = 6; var width = (flowLayoutPanel1.Width - 30) / count; for (int i = libPage * 12; i < libPage * 12 + 12; i++) { if (i >= libFiles.Count) { break; } var item = libFiles[i]; try { //加载影片信息 var movieInfo = NfoTools.Load(item); //创建信息卡片 var card = new InfoCard() { Width = width, Height = (int)(width / 0.55), Cursor = Cursors.Hand, Movie = movieInfo, VideoFile = new VideoInfo() { filename = item, name = Path.GetFileNameWithoutExtension(item), num = movieInfo.Number, avtype = NumberTools.IsUncensored(movieInfo.Number) ? "无码" : "" } }; //双击播放事件 card.DoubleClick += (o1, e1) => { Process.Start(item); }; //单击信息查看 card.Click += (o1, e1) => { ShowMovieDetail(card); }; //计算位置 var x = (i % 12) % count * card.Width + ((i % 12) % count) + 4; var y = (i % 12) / count * card.Height + ((i % 12) / count * 20) + 10; card.Location = new Point(x, y); flowLayoutPanel1.Controls.Add(card); } catch (Exception e1) { Console.WriteLine(e1.Message); } } if (flowLayoutPanel1.Controls.Count > 0) { Invoke(new EventHandler((o1, e1) => { tabControlPanel4.Controls.Add(flowLayoutPanel1); })); } else { flowLayoutPanel1.Dispose(); } }
/// <summary> /// 获取影片信息 /// </summary> /// <param name="num">番号</param> /// <param name="config">用户配置</param> /// <returns></returns> private static MovieInfo GetMovieInfo(string num, Config config, SiteTypes userSite = SiteTypes.Auto) { MovieInfo info = null; var site = userSite != SiteTypes.Auto ? userSite : (SiteTypes)Enum.Parse(typeof(SiteTypes), config.Site.ToString()); switch (site) { case SiteTypes.All: Log.Save($"使用系统默认采集顺序"); if (NumberTools.IsUncensored(num)) //无码处理 { if (num.StartsWith("fc2", StringComparison.CurrentCultureIgnoreCase)) { Log.Save($"使用 Fc2Club 影片采集"); //fc2 单独处理 info = new Fc2Club().GetInfoAsync(num); if (info == null) { Log.Save($"Fc2Club 采集失败,使用 Javdb 采集"); //未找到再 Javdb info = new Javdb().GetInfoAsync(num); } } else { // 先 Avsox Log.Save($"使用 Avsox 影片采集"); info = Avsox.Instance.GetInfoAsync(num); if (info == null) { //未找到再 JavBus Log.Save($"Avsox 采集失败,使用 JavBus 采集"); info = JavBus.Instance.GetInfoAsync(num); if (info == null) { Log.Save($"JavBus 采集失败,使用 Javdb 采集"); //未找到再 Javdb info = new Javdb().GetInfoAsync(num); } } } } else { //先 Avmoo Log.Save($"使用 Avmoo 影片采集"); info = new Avmoo().GetInfoAsync(num); if (info == null) { //未找到再 avBus Log.Save($"Avmoo 采集失败,使用 JavBus 采集"); info = JavBus.Instance.GetInfoAsync(num); if (info == null) { //未找到再 Javdb Log.Save($"JavBus 采集失败,使用 Javdb 采集"); info = new Javdb().GetInfoAsync(num); /*if (info == null) * { * //未找到再 JavLibrary * info = new JavLibrary().GetInfoAsync(num); * }*/ } } else { if (info.Star == null) { //未找到再 avBus Log.Save($"Avmoo 未采集到演员,使用 JavBus 采集"); info = JavBus.Instance.GetInfoAsync(num); } } } break; case SiteTypes.javbus: Log.Save($"使用 JavBus 采集"); info = JavBus.Instance.GetInfoAsync(num); break; case SiteTypes.avsox: Log.Save($"使用 Avsox 采集"); info = Avsox.Instance.GetInfoAsync(num); break; case SiteTypes.javlibrary: Log.Save($"使用 JavLibrary 采集"); info = new JavLibrary().GetInfoAsync(num); break; case SiteTypes.fc2club: Log.Save($"使用 Fc2Club 采集"); info = new Fc2Club().GetInfoAsync(num); break; case SiteTypes.avmoo: Log.Save($"使用 Avmoo 采集"); info = new Avmoo().GetInfoAsync(num); break; case SiteTypes.javdb: Log.Save($"使用 Javdb 采集"); info = new Javdb().GetInfoAsync(num); break; } if (info != null) { info.Number = num; Log.Save($"获取影片信息完成 <= [{info.Generate}]"); OnLog?.Invoke($"获取影片信息完成 <= [{info.Generate}]", LogLevels.Success); return(info); } else { Log.Save($"未获取到影片信息"); throw new Exception($"未获取到影片信息 {num}"); } }
private void button_addpath_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { //检查用户添加是否是文件夹 if (Directory.Exists(fbd.SelectedPath)) { //List<VideoInfo> list = new List<VideoInfo>(); //获取目录下面的视频文件 var files = Directory.EnumerateFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories) .Where(f => { var filename = Path.GetFileNameWithoutExtension(f); return((f.EndsWith(".mkv", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".mp4", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".avi", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".asf", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".wmv", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".rmvb", StringComparison.CurrentCultureIgnoreCase) || f.EndsWith(".rm", StringComparison.CurrentCultureIgnoreCase)) && !filename.EndsWith("-cd1", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("-cd2", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("-cd3", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("-cd4", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("-cd5", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("_2", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("_3", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("_4", StringComparison.CurrentCultureIgnoreCase) && !filename.EndsWith("_5", StringComparison.CurrentCultureIgnoreCase)); }).Select(f => { var name = Path.GetFileName(f); return(new VideoInfo() { name = name, filename = f, num = NumberTools.Get(name), avtype = NumberTools.IsUncensored(name) ? "无码" : "" }); }).ToList(); //过滤已经存在nfo的视频 if (checkBox_filternfo.Checked) { for (int i = 0; i < files.Count; i++) { var item = files[i]; var name = $"{Path.GetDirectoryName(item.filename)}{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(item.name).Replace("-cd1", "").Replace("-cd2", "")}.nfo"; if (File.Exists(name)) { files.RemoveAt(i); i--; } } } files.Sort((x1, y1) => { if (x1.num != null && y1.num != null) { return(x1.num.CompareTo(y1.num)); } return(0); }); for (int i = 0; i < files.Count; i++) { files[i].index = i + 1; } VideoFileList.AddRange(files); bs_file.ResetBindings(false); ShowToast($"共搜索到 {VideoFileList.Count} 个视频文件"); } } fbd.Dispose(); }