public Dictionary <int, IEnumerable <ThreadTemp> > GetCatalog() { return(FourChan.MakeRequest <IEnumerable <ThreadsPage <ThreadTemp> > >(board + "/catalog.json").ToDictionary( p => p.page, p => p.threads )); }
public Dictionary <int, IEnumerable <IListedPostTemp> > GetPages() { return(FourChan.MakeRequest <IEnumerable <ThreadsPage <IListedPostTemp> > >(board + "/threads.json").ToDictionary( p => p.page, p => p.threads )); }
public Post[] GetReplies() { LastUpdated.Stop(); if (LastUpdated.ElapsedMilliseconds == 0) { LastUpdated.Start(); Posts = FourChan.MakeRequest <KeyValuePair <string, PostWithFileTemp[]> >( "b/thread/" + PostID.ToString() + ".json" ).Value.Select( p => new Post(p) ).ToArray(); IfModifiedSince = DateTime.Now.ToString("R"); } else if (LastUpdated.Elapsed.TotalSeconds >= 15.0) { if (FourChan.TryMakeRequest <KeyValuePair <string, PostWithFileTemp[]> >("b/thread" + PostID.ToString() + ".json", IfModifiedSince, out KeyValuePair <string, PostWithFileTemp[]> content)) { Posts = content.Value.Skip(Posts.Length).Select(p => new Post(p)).ToArray(); LastUpdated.Restart(); IfModifiedSince = DateTime.Now.ToString("R"); } else { LastUpdated.Start(); } } else { LastUpdated.Start(); } return(Posts); }
// For /b/, and potentially some other boards, there is no archive. public IEnumerable <long> GetArchived() { try { return(FourChan.MakeRequest <IEnumerable <long> >(board + "/archive.json")); } catch { return(Enumerable.Empty <long>()); } }
public Thread[] GetCatalog() { LastUpdated.Stop(); if (Threads == null) { Threads = FourChan.MakeRequest <CatalogPageTemp[]>(URLName + "/catalog.json").SelectMany( p => p.threads ).ToDictionary( t => t.no, t => new Thread(t) ); LastUpdated.Restart(); } else if (LastUpdated.Elapsed.TotalSeconds >= 60.0) { List <Thread> threadsTemp = new List <Thread>(); var threadids = FourChan.MakeRequest <ThreadsPageTemp[]>(URLName + "/threads.json").SelectMany( p => p.threads.Select(t => t.no) ); Threads = threadids.ToDictionary( i => i, i => Threads.TryGetValue(i, out Thread t) ? t : new Thread( FourChan.MakeRequest <ThreadTemp>( "b/thread/" + i.ToString() + ".json" ), true ) ); LastUpdated.Restart(); } else { LastUpdated.Start(); } return(Threads.Values.ToArray()); }