public ArrayList alys(string content, string path, string path1) { ArrayList resList = new ArrayList(); string[] contents = content.Split(new string[] { "<h3>" }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in contents) { if (!s.Contains("Torrent Name")) { continue; } if (nIn1Reg.IsMatch(s)) { if (!File.Exists(path)) { File.Create(path).Close(); } StreamWriter sw = File.AppendText(path); sw.Write(s); sw.Flush(); sw.Close(); continue; } His his = new His(); his.HisTimeSpan = 1; his.OriginalHtml = s; his.Vid = r.Match(s).Value.Replace("Download <strong>", "").Replace("</strong>", ""); if (!his.Vid.ToLower().Contains("1pond")) { if (his.Vid.Split('-').Length > 2 && Tool.IsNum(his.Vid.Split('-')[1])) //对于xxx-av-1234的修改,只考虑两个-的情况 { his.Vid = his.Vid.Substring(0, his.Vid.LastIndexOf('-')); } } his.Vid = his.Vid.Replace("-", ""); string size = sizeRegex.Match(s).Value.Replace("Size: ", "").Replace(". ", ""); string sizeDigit = size.Replace("Size:", "").Replace(".<br />", "").Replace("<br />", ""); try { if (sizeDigit.EndsWith("GB")) { sizeDigit = sizeDigit.Replace("GB", ""); his.Size = Convert.ToDouble(sizeDigit) * 1024; } else { his.Size = Convert.ToDouble(sizeDigit.Replace("MB", "").Replace("KB", "")); } } catch (Exception e) { Console.WriteLine("CAN NOT FIND SIZE!!"); Console.WriteLine(e.Message); } his.Actress = actressRegex.Match(s).Value.Replace("Actress : ", "").Replace("</p>", ""); getHtml(his, size); resList.Add(his); } return(resList); }
public bool checkValid(His his) { if (!String.IsNullOrEmpty(his.FailReason)) { return(false); } string id = his.Vid; if (id == null || id == "") { return(true); } id = id.ToLower(); bool flag = true; if (Tool.IsNum(id)) { foreach (MyFileInfo info in list) { if (info.FileName.Contains(id) || info.Directory.Contains(id)) { flag = false; break; } } } else { id = reg2.Match(id).Value; string letter = ""; string number = ""; bool isEndofLetter = false; for (int i = 0; i < id.Length; i++) //修改 对于出现KIDM235A KIDM235B { if (reg1.IsMatch(id[i].ToString())) { if (isEndofLetter) { break; } else { letter += id[i]; } } else { number += id[i]; isEndofLetter = true; } } string[] searchStr = { letter, number }; Regex r = new Regex("[^a-z]" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "[^0-9]|^" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "$|[^a-z]" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "$|^" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "[^0-9]"); for (int i = 0; i < list.Count; i++) { flag = true; string fileName = Path.GetFileNameWithoutExtension(list[i].FileName.ToLower()).Replace("_", "-"); string directoryName = list[i].Directory.ToLower(); string extension = list[i].Extension; double len = list[i].Length; if (Config.isCheckSize) { if ((r.IsMatch(fileName) || r.IsMatch(directoryName)) && !fileName.Contains("incomplete")) { his.IfExistSmaller = true; if ((len * 1.7 > his.Size || (extension.ToLower() == ".mds" || extension.ToLower() == ".iso") && his.Size < 3000)) { flag = false; break; } } } else { if ((r.IsMatch(fileName) || r.IsMatch(directoryName)) && !fileName.Contains("incomplete")) { flag = false; break; } } } if (!flag) { his.FailReason = "file"; } } if (flag) { if (!his.IfExistSmaller) //如果有小文件 说明要下载 { flag = checkHis(his); if (!flag) { his.FailReason = "his"; } } } if (flag) { DBHelper.insertHis(his); } return(flag); }