public void GetBoard() { try { BoardRootObject board = Chan.GetBoard(); Assert.NotNull(board); } catch (Exception e) { Assert.Fail(e.Message); } }
public void GetBoard() { var board = Chan.GetBoard(); NotNull(board); }
static void Main(string[] args) { System.Net.ServicePointManager.UseNagleAlgorithm = false; var board = Chan.GetBoard().Boards.Single(b => b.BoardName == "b"); Dictionary <int, int> watchedPostNumbers = new Dictionary <int, int>(); List <int> ignoredPostNumbers = File.Exists( FILE_PATH ) ? File.ReadAllLines( FILE_PATH ).Select( l => Convert.ToInt32(l) ).ToList() : new List <int>(); Dictionary <int, int> loggedPostNumbers = new Dictionary <int, int>(); Regex speechPatternsRGX = new Regex( @"(?=.*<3{2,})|(?:(?=.*(?:\.{2,}|friends|thx|luv|y{3,}|o{3,}))(?=.*(?:[:;]-[\)\(]|<3)))", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline ); int counter = 0; while (true) { if (counter == 3) { counter = 0; var loggedThreads = loggedPostNumbers.ToDictionary( n => n.Key, n => { try { return(Chan.GetThread("b", n.Key).Posts.Skip(n.Value)); } catch { return(null); } } ); Console.WriteLine(); foreach (var loggedThread in loggedThreads) { if (loggedThread.Value == null) { loggedThreads.Remove(loggedThread.Key); } else { var posts = loggedThread.Value.Where( p => !String.IsNullOrWhiteSpace(p.Comment) ).Select( p => { p.Comment = HttpUtility.HtmlDecode( ZachRGX.HTML_TAGS.Replace( p.Comment, "" ) ); return(p); } ).Where( p => speechPatternsRGX.IsMatch(p.Comment) ); posts.SaveThreadTo(MAIN_PATH + loggedThread.Key.ToString()); loggedPostNumbers[loggedThread.Key] += loggedThread.Value.Count(); Console.WriteLine(loggedThread.Key.ToString() + " - " + posts.Count().ToString()); if (loggedThread.Value.Last().IsClosed || loggedThread.Value.Last().IsArchived) { loggedThreads.Remove(loggedThread.Key); } } } Console.WriteLine(); } var threadsTEMP = Enumerable.Range(1, 10).SelectMany( i => Chan.GetThreadPage("b", i).Threads ).GroupBy(t => t.Posts.First().PostNumber).Select(t => t.Last()).Where( t => { var post = t.Posts.First(); var comment = HttpUtility.HtmlDecode(ZachRGX.HTML_TAGS.Replace(post.Comment, "")); if (ignoredPostNumbers.Contains(post.PostNumber)) { return(false); } else if (( watchedPostNumbers.ContainsKey(post.PostNumber) || Utils.COMPARE_INFO.IndexOf( comment, "share", Utils.IGNORE_CASE_AND_SYMBOLS ) >= 0 || Utils.COMPARE_INFO.IndexOf( comment, "shouldnt", Utils.IGNORE_CASE_AND_SYMBOLS ) >= 0 || Utils.COMPARE_INFO.IndexOf( comment, "queen", Utils.IGNORE_CASE_AND_SYMBOLS ) >= 0 || Utils.COMPARE_INFO.IndexOf( comment, "save", Utils.IGNORE_CASE_AND_SYMBOLS ) >= 0 || Utils.COMPARE_INFO.IndexOf( comment, "femanon", Utils.IGNORE_CASE_AND_SYMBOLS ) >= 0 )) { return(true); } else { ignoredPostNumbers.Add(post.PostNumber); return(false); } } ).Select( t => { var postnumber = t.Posts.First().PostNumber; t = Chan.GetThread("b", postnumber); int count = t.Posts.Count(); IEnumerable <Post> posts = null; if ( watchedPostNumbers.TryGetValue( t.Posts.First().PostNumber, out int num )) { posts = t.Posts.Skip(num); count -= num; } else { posts = t.Posts.Skip(1); } return(new KeyValuePair <int, KeyValuePair <int, Post[]> >( postnumber, new KeyValuePair <int, Post[]>( count, posts.Where( p => !String.IsNullOrWhiteSpace(p.Comment) ).Select( p => { p.Comment = HttpUtility.HtmlDecode( ZachRGX.HTML_TAGS.Replace( p.Comment, "" ) ); return p; } ).Where( p => speechPatternsRGX.IsMatch(p.Comment) ).ToArray() ) )); } ); var threads = threadsTEMP.ToDictionary(); var threadids = threads.Where( t => !t.Value.Value.Any() ).Select(t => t.Key); foreach (var thread in threadids) { int count = threads[thread].Key; if (watchedPostNumbers.TryGetValue(thread, out int numPosts)) { watchedPostNumbers[thread] = numPosts + count; } else { watchedPostNumbers.Add(thread, count); } } threadids = threads.Keys.Except(threadids); File.AppendAllLines( FILE_PATH, threadids.Select(t => t.ToString()) ); foreach (var id in threadids) { var thread = threads[id]; Console.WriteLine(id.ToString() + " - " + thread.Value.Length.ToString()); if (watchedPostNumbers.TryGetValue(id, out int count)) { watchedPostNumbers.Remove(id); loggedPostNumbers.Add(id, thread.Key + count); } ignoredPostNumbers.Add(id); string path = MAIN_PATH + id.ToString(); Directory.CreateDirectory(path); thread.Value.SaveThreadTo(path); } System.Threading.Thread.Sleep(15000); ++counter; } }