protected IEnumerable <ISeekItem> GetSeeds(string responseHtml, string regPattern, string series) { List <ISeekItem> searchSeeds = new List <ISeekItem>(); MatchCollection matches = Regex.Matches(responseHtml, regPattern); if (matches.Count == 0) { Console.WriteLine("no seeds match"); return(searchSeeds); } ISeekItem seekItem = null; Dictionary <string, string> dict = new Dictionary <string, string>(); string matchTitle = null; string matchKey = null; foreach (Match match in matches) { matchTitle = match.Groups["title"].ToString(); matchKey = match.Groups["key"].ToString(); if (dict.ContainsKey(matchKey)) { continue; } dict.Add(matchKey, matchTitle); seekItem = new SeekItem(); seekItem.Series = series; seekItem.Title = matchTitle.Replace(" ", ""); seekItem.Key = matchKey; searchSeeds.Add(seekItem); } return(searchSeeds); }
public static void Add(string platform, ISeekItem seekItem) { FieldInfo fieldInfo = typeof(DefaultDb).GetField(platform, BindingFlags.Static | BindingFlags.Public); if (fieldInfo != null) { (fieldInfo.GetValue(null) as List <ISeekItem>).Add(seekItem); } }
protected CountItem GetPlayCount(string targetUrl, string reg, ISeekItem seekItem, Func <string, string> countFormatter, RegexOptions regexOptions = RegexOptions.None) { CountItem countItem = new CountItem(); countItem.Title = seekItem.Title; string responseHtml = GetResponseHtml(targetUrl); if (responseHtml != null) { Match match = Regex.Match(responseHtml, reg, regexOptions); if (match.Groups.Count != 1) { countItem.Count = countFormatter(match.Groups[1].ToString()); countItem.Key = seekItem.Key; return(countItem); } } countItem.Count = "N/A"; countItem.Key = targetUrl; return(countItem); }