Esempio n. 1
0
 public Dictionary <int, IEnumerable <ThreadTemp> > GetCatalog()
 {
     return(FourChan.MakeRequest <IEnumerable <ThreadsPage <ThreadTemp> > >(board + "/catalog.json").ToDictionary(
                p => p.page,
                p => p.threads
                ));
 }
Esempio n. 2
0
 public Dictionary <int, IEnumerable <IListedPostTemp> > GetPages()
 {
     return(FourChan.MakeRequest <IEnumerable <ThreadsPage <IListedPostTemp> > >(board + "/threads.json").ToDictionary(
                p => p.page,
                p => p.threads
                ));
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 // 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>());
     }
 }
Esempio n. 5
0
        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());
        }