private string GetPlot(string page) { string _res = BaseCollector.GetItem(page, m_CountryFactory.RE_Plot + "</h2>.*?<p>(?<Plot>[^<]+)", "Plot", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(string.Format("<h5>{0}</h5>.*?info-content\">(.*?)</div>", m_CountryFactory.RE_Plot), RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page.Replace("\n", "")); if (match.Success) { string _result = HttpUtility.HtmlDecode(Regex.Replace(match.Groups[1].Value, "<a class.*?</a>", "")).Trim().TrimEnd(new char[] { '|' }).TrimEnd(new char[0]); _result = Regex.Replace(_result, "<a href=\"/title.*?</a>", ""); int _start = _result.LastIndexOf("."); if (_start >= 0) { try { _result = _result.Substring(0, _start + 1); } catch { } } return(_result); } return(string.Empty); } }
public static BaseCollector GetNewCollectorObject(string collectorName) { // be careful here coz due to obfuscation u can't rely on type name Type t = BaseCollector.GetCollectorType(collectorName); //Create the object, cast it and return it to the caller return((BaseCollector)Activator.CreateInstance(t)); }
public CollectorThreadParams(BaseCollector collector, string keywords, string imdbid, bool skipImages, AutoResetEvent eventDone) { Collector = collector; Keywords = keywords; ImdbId = imdbid; Event = eventDone; SkipImages = skipImages; }
public BaseCollector GetCollectorByParam(CollectorType itemtype, BaseParamter baseParamter) { BaseCollector collector = null; string collectType = EnumExtension.GetCollectorType(itemtype); string collectNameSpace = collectType.Substring(0, collectType.LastIndexOf(".")); collector = CollectorFactory.CreateInstance(collectNameSpace + "," + collectType, baseParamter); return(collector); }
private string GetMetascore(string page) { string _res = BaseCollector.GetItem(page, @"Metascore: <a href=""criticreviews\?ref_=tt_ov_rt"" title=""(?<Metascore>\d+)\s", "Metascore", RegexOptions.Singleline).Trim(); if (!string.IsNullOrEmpty(_res)) { return(_res); } return(string.Empty); }
private string GetTrailerLink(string page) { string _res = BaseCollector.GetItem(page, @"<a href=""(?<Trailer>/video/imdb/vi\d+/\?ref_=tt_ov_vi)"" class=""btn2 btn2_text_on large title-trailer", "Trailer"); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { return(string.Empty); } }
public CollectorNode(List <ResultItemBase> results, bool isSelected, BaseCollector collector) { Results = new ObservableCollection <ResultItemBase>(); if (results != null && results.Count > 0) { Results.AddRange(results); } IsExpanded = true; IsSelected = isSelected; IsEnabled = true; SearchTime = string.Empty; Collector = collector; Name = collector != null ? collector.CollectorName : Name; }
//public bool Insert(BaseCollector collector) //{ // try // { // BaseParamter paramter = collector.Paramter; // //string typeStr =paramter.GetType().ToString(); // using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection()) // { // conn.ConnectionString = ConfigurationManager.AppSettings["MySqlConnectionStr"]; // MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); // cmd.CommandText = "insert into tb_monitoritem(name,ip,note,itemtype,paramter) values(@name,@ip,@note,@itemtype,@paramter)"; // cmd.CommandType = CommandType.Text; // cmd.Parameters.Add("@name", MySql.Data.MySqlClient.MySqlDbType.VarChar); // cmd.Parameters.Add("@ip", MySql.Data.MySqlClient.MySqlDbType.VarChar); // cmd.Parameters.Add("@note", MySql.Data.MySqlClient.MySqlDbType.VarChar); // cmd.Parameters.Add("@itemtype", MySql.Data.MySqlClient.MySqlDbType.Int32); // cmd.Parameters.Add("@paramter", MySql.Data.MySqlClient.MySqlDbType.VarBinary); // cmd.Parameters[0].Value = Guid.NewGuid(); // cmd.Parameters[1].Value = paramter.Host; // cmd.Parameters[2].Value = cmd.Parameters[0].Value; // cmd.Parameters[3].Value = 1; // cmd.Parameters[4].Value = _ser.Serialize(paramter); // cmd.Connection = conn; // conn.Open(); // int affectedrows = cmd.ExecuteNonQuery(); // cmd.Dispose();//此处可以不用调用, // conn.Close();// 离开 using 块, connection 会自行关闭 // } // return true; // } // catch (Exception ex) // { // throw new Exception(ex.Message); // } //} //public List<CollectorInfo> GetList(string condition) //{ // List<CollectorInfo> list = new List<CollectorInfo>(); // using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection()) // { // conn.ConnectionString = ConfigurationManager.AppSettings["MySqlConnectionStr"]; // conn.Open(); // MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(); // cmd.CommandType = CommandType.Text; // cmd.CommandText = "select name,ip,note,itemtype,paramter from tb_monitoritem"; // cmd.Connection = conn; // System.Data.Common.DbDataReader reader = cmd.ExecuteReader(); // byte[] buffer = null; // if (reader.HasRows) // { // while (reader.Read()) // { // CollectorInfo info = new CollectorInfo(); // int itemtype = reader.GetInt32(3); // long len = reader.GetBytes(4, 0, null, 0, 0); // buffer = new byte[len]; // len = reader.GetBytes(4, 0, buffer, 0, (int)len); // info.Collector = GetCollectorByBytes(itemtype, buffer); // info.LastTime = DateTime.MinValue; // list.Add(info); // } // } // } // return list; //} #endregion public BaseCollector GetCollectorByBytes(CollectorType itemtype, byte[] bytes) { BaseCollector collector = null; string collectType = EnumExtension.GetCollectorType(itemtype); string collectNameSpace = collectType.Substring(0, collectType.LastIndexOf(".")); BaseParamter baseParamter = (BaseParamter)Activator.CreateInstance(EnumExtension.GetParamterType((CollectorType)itemtype)); baseParamter = (DBParamter)_ser.Deserialize(bytes); collector = CollectorFactory.CreateInstance(collectNameSpace + "," + collectType, baseParamter); return(collector); }
private List <string> GetCountries(string page) { List <string> list = new List <string>(); list = BaseCollector.GetItems(page, @"<a href=""/country/[^\?]+\?ref_=tt_dt_dt"" itemprop='url'>(?<Country>[^<]+)</a>", "Country"); if (list.Count != 0) { return(list); } else { Regex regex = new Regex(string.Format("<h5>{0}</h5>.*?info-content\">(.*?)</div>", m_CountryFactory.RE_Countries), RegexOptions.Multiline | RegexOptions.IgnoreCase); Match match = regex.Match(page.Replace("\n", "").Replace("\r", "")); if (match.Success) { //regex = new Regex("<a\\shref=\"/Sections/Countries.*?>(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase); regex = new Regex("<a href=\"/country.*?>(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (regex.Matches(match.Groups[1].Value).Count > 0) { foreach (Match match2 in regex.Matches(match.Groups[1].Value)) { list.Add(HttpUtility.HtmlDecode(match2.Groups[1].Value)); } } else { regex = new Regex("<a\\shref=\"/Sections/Countries.*?>(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (regex.Matches(match.Groups[1].Value).Count > 0) { foreach (Match match2 in regex.Matches(match.Groups[1].Value)) { list.Add(HttpUtility.HtmlDecode(match2.Groups[1].Value)); } } else { string[] _s = match.Groups[1].Value.Split('|'); foreach (string _item in _s) { list.Add(HttpUtility.HtmlDecode(_item.Trim().Trim('\r').Trim())); } } } } return(list); } }
private string GetRunTime(string page) { string _res = BaseCollector.GetItem(page, "(?<Runtime>\\d{1,3})\\smin", "Runtime"); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(@"(\d{1,3})\smin", RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(match.Groups[1].Value); } return(string.Empty); } }
private string GetReleaseDateFast(string page) { string _res = BaseCollector.GetItem(page, m_CountryFactory.RE_ReleaseDateFast + @"</h4>.*?(?<ReleaseDate>[^\(]*)", "ReleaseDate"); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(m_CountryFactory.RE_ReleaseDateFast + @"</h5>.*\n.*\n([^\(]*)", RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(match.Groups[1].Value); } return(string.Empty); } }
private string GetMPAA(string page) { string _res = BaseCollector.GetItem(page, "contentRating\">(?<MPAA>[^<]+)<", "MPAA").Trim().Replace("\r", "").Replace("\n", "").Trim(); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex("MPAA</a>:</h5>[\\r\\n]*<div class=\"info-content\">([^<]+)</div", RegexOptions.Singleline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(HttpUtility.HtmlDecode(match.Groups[1].Value.Replace("\r", "").Replace("\n", "").Trim())); } return(string.Empty); } }
private string GetTagline(string page) { string _res = BaseCollector.GetItem(page, "Taglines:</h4>.*?(?<Tagline>[^<]+)<", "Tagline").Trim().Replace("\r", "").Replace("\n", "").Trim(); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex("Tagline:</h5>.*?info-content\">(.*?)<", RegexOptions.Singleline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(HttpUtility.HtmlDecode(match.Groups[1].Value.Replace("\r", "").Replace("\n", "").Trim())); } return(string.Empty); } }
private string GetRating(string page) { string _res = BaseCollector.GetItem(page, @"itemprop=""ratingValue"">(?<Rating>[\d\.]+)</span></strong><span class=""mellow"">/<span itemprop=""bestRating"">10", "Rating"); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(@"<b>(\d.*?)/10</b>", RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(match.Groups[1].Value); } return(string.Empty); } }
private string GetYear(string page) { string _res = BaseCollector.GetItem(page, @"<title>[^\(]+\((?<Year>\d{4})|<title>[^\(]+\(.*?(?<Year>\d{4})", "Year"); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(@"<title>.*?\s\((\d{4})", RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(match.Groups[1].Value); } return(string.Empty); } }
private string GetOriginalTitle(string page) { string _res = BaseCollector.GetItem(page, "class=\"title-extra\">(?<OriginalTitle>[^<^\\(]+)", "OriginalTitle").Trim().Trim(new char[] { '"' }); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex("class=\"title-extra\">(?<OriginalTitle>[^<^\\(]+)", RegexOptions.Singleline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(HttpUtility.HtmlDecode(match.Groups["OriginalTitle"].Value.Trim()).Trim(new char[] { '"' })); } return(string.Empty); } }
private string GetTitle(string page) { string _res = BaseCollector.GetItem(page, @"<title>(?<Title>[^\(]+)", "Title").Trim().Trim(new char[] { '"' }).Replace("IMDb - ", ""); if (!string.IsNullOrEmpty(_res)) { return(_res); } else { Match match = new Regex(@"<title>(.*?)\s\(\d{4}", RegexOptions.Multiline | RegexOptions.IgnoreCase).Match(page); if (match.Success) { return(HttpUtility.HtmlDecode(match.Groups[1].Value.Trim()).Trim(new char[] { '"' })); } return(string.Empty); } }
private List <string> GetActors(string page) { List <string> _res = BaseCollector.GetItems(page, @"href=""/name/nm[0-9]+/\?ref_=tt_cl_t\d+"" itemprop='[^']+'>\s*(<span class=""itemprop"" itemprop=""name"">)?(?<Actor>[^<]+)</", "Actor", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (_res.Count != 0) { return(_res); } else { MatchCollection matchs = new Regex("<td class=\"nm\"><a href=\"(.*?)\">(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase).Matches(page); List <string> list = new List <string>(); foreach (Match match in matchs) { list.Add(HttpUtility.HtmlDecode(match.Groups[2].Value.Trim())); } return(list); } }
public MovieInfo QueryPreferredCollector(string imdbid, string keywords) { MovieInfo _result = null; // find the type of the preferred collector BaseCollector _tmp = BaseCollector.GetMovieCollector(FileManager.Configuration.Options.PreferedInfoCollector); if (_tmp != null) { // create a new collector (to not affect the old one) BaseCollector _prefCollector = GetNewCollectorObject(FileManager.Configuration.Options.PreferedInfoCollector); //BaseCollector.GetMovieCollector(FileManager.Configuration.Options.PreferedInfoCollector); Loggy.Logger.Debug("Detected prefinfocollector: " + _prefCollector.CollectorName); //BaseCollector _prefCollector = BaseCollector.GetMovieCollectorObject(FileManager.Configuration.Options.PreferedInfoCollector); if (_prefCollector != null) { _prefCollector.IMDBID = imdbid; _prefCollector.CurrentMovie = new MovieItem(MoviePath); _result = _prefCollector.QueryMovieInfo(_prefCollector.IMDBID); if ((_result == null) || (string.IsNullOrEmpty(_result.Name))) { // ask user _prefCollector.GetResults(keywords, _prefCollector.IMDBID, true); BindingList <MovieInfo> _candidates = new BindingList <MovieInfo>(); foreach (ResultItemBase _rib in _prefCollector.ResultsList) { if (!string.IsNullOrEmpty(imdbid) && !string.IsNullOrEmpty(_rib.MovieInfo.IMDBID) && imdbid != _rib.MovieInfo.IMDBID) { continue; // IMDBID does not match with ours } if (!_candidates.Contains(_rib.MovieInfo, new MovieInfoComparer())) { _candidates.Add(_rib.MovieInfo); } } ChooseMovieDialogResult _dresult = ChooseMovieFromIMDb.GetCorrectMovie(null, _candidates, "", false); _result = _dresult != null ? _dresult.MovieInfo : null; } } } return(_result); }
private List <string> GetCompanies(string page) { List <string> list = BaseCollector.GetItems(page, @"href=""/company/co\d+\?ref_=tt_dt_co"" itemprop='url'>(<span class=""itemprop"" itemprop=""name"">)?(?<Company>[^<]+)</", "Company", RegexOptions.Singleline); if (list.Count == 0) { // old layout list = new List <string>(); Regex regex = new Regex(string.Format("<h5>{0}</h5>.*?info-content\">(.*?)</div>", m_CountryFactory.RE_Companies), RegexOptions.Multiline | RegexOptions.IgnoreCase); Match match = regex.Match(page.Replace("\n", "")); if (match.Success) { regex = new Regex("<a href=\"/company.*?>(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase); foreach (Match match2 in regex.Matches(match.Groups[1].Value)) { list.Add(HttpUtility.HtmlDecode(match2.Groups[1].Value)); } } } return(list); }
private List <string> GetDirectors(string page) { // new layout List <string> list = new List <string>(); //Regex regex = new Regex(string.Format("{0}(.*?)</div>", m_CountryFactory.RE_Directors), RegexOptions.Singleline | RegexOptions.IgnoreCase); //Match match = regex.Match(page.Replace("\n", "")); //if (match.Success) //{ list = BaseCollector.GetItems(page, @"href=""/name/nm\d+/\?ref_=tt_ov_\wr"" itemprop='url'>(<span class=""itemprop"" itemprop=""name"">)?(?<Director>[^<]+)</", "Director"); //} if (list.Count != 0) { return(list.Take(1).ToList()); } else { list = BaseCollector.GetItems(page, "itemprop=\"director\".*?>(?<Director>[^<]+)</a", "Director", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (list.Count != 0) { return(list); } else { List <string> list2 = new List <string>(); Regex regex2 = new Regex(string.Format("<h5>{0}</h5>.*?info-content\">(.*?)</div>", m_CountryFactory.RE_Directors), RegexOptions.Multiline | RegexOptions.IgnoreCase); Match match2 = regex2.Match(page.Replace("\n", "")); if (match2.Success) { Regex regex3 = new Regex("<a\\shref=\"/name/nm\\d{7}/\".*?\">(.*?)</a>", RegexOptions.Multiline | RegexOptions.IgnoreCase); foreach (Match match22 in regex3.Matches(match2.Groups[2].Value)) { list2.Add(HttpUtility.HtmlDecode(match22.Groups[1].Value)); } } return(list2); } } }
private List <string> GetGenres(string page) { // new layout List <string> _result = BaseCollector.GetItems(page, @"<a href=""/genre/[^\?]+\?ref_=tt_ov_inf"" >(<span class=""itemprop"" itemprop=""genre"">)?(?<Genre>[^<]+)</", "Genre", RegexOptions.Singleline); if (_result.Count != 0) { return(_result); } else { // old layout List <string> list = new List <string>(); MatchCollection matchs = new Regex("<a href=\"/Sections/Genres/[^/]*/\">([^\"]*)</a>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Matches(page); if (matchs.Count != 0) { foreach (Match match in matchs) { list.Add(HttpUtility.HtmlDecode(match.Groups[1].Value.Trim())); } } else { matchs = new Regex(m_CountryFactory.RE_Genres, RegexOptions.Singleline | RegexOptions.IgnoreCase).Matches(page); foreach (Match match in matchs) { string[] _s = match.Groups[1].Value.Split('|'); foreach (string _item in _s) { list.Add(HttpUtility.HtmlDecode(_item.Trim().Trim('\r').Trim())); } } } return(list); } }
public void SetCollector(BaseCollector collector) { Collector = collector; Name = collector != null ? collector.CollectorName : Name; }