} //method public void DownloadCover(Av av) { Match match = new Regex(@"<a class=""bigImage"" href=""(?<url>.*?)"">").Match(av.Html); if (match.Success) { string url = match.Groups["url"].Value; Download.HttpDownloadFile(url, av.Path + "\\", "art.jpg"); int fg = url.LastIndexOf("/") + 1; string name = url.Substring(fg, url.Length - fg - 6).Trim(); url = url.Replace("_b", ""); string qb = "<li class=\"active\"><a href=\"" + basePath + "/\">"; if (av.Html.IndexOf(qb) != -1) { url = url.Replace("cover", "thumb"); } else { url = url.Replace("cover", "thumbs"); } Download.HttpDownloadFile(url, av.Path + "\\", "folder.jpg"); //修改文件夹名称 try { StringBuilder sb = new StringBuilder(); MatchCollection startNames = new Regex(@"<div class=""star-name""><a href="".*?"" title="".*?"">(?<name>.*?)</a></div>").Matches(av.Html); int i = 0; int x = 0; int y = 0; foreach (Match m in startNames) { av.stars.Add(m.Groups["name"].Value); sb.Append(m.Groups["name"].Value); i++; if (i < startNames.Count) { sb.Append(","); } if (++x > 20) { y++; x = 0; File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + y + ".txt").Close(); sb.Clear(); } } if (sb.Length > 0) { File.Create(av.Path + "\\" + av.Id + " " + sb.ToString() + ".star" + (y == 0?"":y + 1 + "") + ".txt").Close(); } } catch (Exception e) { _syncContext.Post(OutError, av.Id + " :获取女优失败"); } string newPath = null; newPath = av.Path; try { //match = new Regex(@"<h3>(?<title>.*?)</h3>[\s\S]*?<p><span class=""header"">發行日期:</span>(?<date>.*?)</p>").Match(av.Html); match = new Regex(@"<h3>(?<title>[\s\S]*?)</h3>[\s\S]*?<p><span class=""header"">發行日期:</span>(?<date>.*?)</p>").Match(av.Html); if (match.Success) { av.date = match.Groups["date"].Value.Trim(); av.title = match.Groups["title"].Value.Trim(); string newfolderName = match.Groups["date"].Value.Trim() + " " + match.Groups["title"].Value.Trim(); newfolderName = newfolderName.Replace("\\", "‖"); newfolderName = newfolderName.Replace("/", "‖"); newfolderName = newfolderName.Replace(":", ":"); newfolderName = newfolderName.Replace("*", "※"); newfolderName = newfolderName.Replace("?", "?"); newfolderName = newfolderName.Replace("<", "〈"); newfolderName = newfolderName.Replace(">", "〉"); newfolderName = newfolderName.Replace("\n", " "); newfolderName = newfolderName.Replace("\r", " "); //newfolderName = Regex.Replace(newfolderName, @"[/n/r]", " "); StringBuilder rBuilder = new StringBuilder(newfolderName); foreach (char rInvalidChar in Path.GetInvalidPathChars()) { rBuilder.Replace(rInvalidChar.ToString(), string.Empty); } /*int fg = av.Path.LastIndexOf("\\"); * string basePath = av.Path.Substring(0, fg).Trim(); * System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(av.Path); * folder.MoveTo(basePath+ "\\" + newfolderName); * newPath = basePath + "\\" + newfolderName; * av.Path = newPath;*/ } else { ExeLog.WriteLog("获取AV名称失败:\r\n" + av.Html); _syncContext.Post(OutError, av.Id + " :获取AV名称失败"); return; } //修改视频名称 改为符合 emby的规则 string[] extNames = new string[] { ".avi", ".mov", ".mpg", ".RA", ".RM", ".RMVB", ".WMV", ".mkv", ".mp4", ".asf", ".m4v", ".VOB" }; DirectoryInfo fdir = new DirectoryInfo(newPath); FileInfo[] file = fdir.GetFiles(); if (file.Length != 0) { //当前目录文件或文件夹不为空 for (int i = 0; i < extNames.Length; i++) { int x = 0; foreach (FileInfo f in file) { if (extNames[i].ToLower().Equals(f.Extension.ToLower())) { x++; } } int y = 1; foreach (FileInfo f in file) //显示当前目录所有文件 { if (extNames[i].ToLower().Equals(f.Extension.ToLower())) { string newName = newPath + "\\" + av.Id + (x > 1 ? "-cd" + y : "") + f.Extension; av.CD1 = x > 1; try { //记录文件名称 ChangeNameLogTxt(f.Name, newName); File.Move(f.FullName, newName); //File.Create(folder + "\\"+ (x > 1 ? "-cd" + y : "") + f.Name + ".old.name").Close(); } catch (Exception ex) { _syncContext.Post(OutError, av.Id + "-修改视频文件名称错误 \r\n"); } y++; } //for files } } //for ext } //file } catch (Exception e) { _syncContext.Post(OutError, av.Id + " :修改AV名称失败" + e.Message); } _syncContext.Post(OutLog, av.Id); try { creNfo(av); } catch (Exception e) { _syncContext.Post(OutLog, av.Id + ":nfo 创建失败" + e.Message); } } }
private void textBox5_TextChanged(object sender, EventArgs e) { Download.SetProxy(textBox5.Text); }