Beispiel #1
0
        public Dictionary <string, BoardInfo> GetAvailableBoards()
        {
            string data = ChanArchiver.Properties.Resources.cached_boards;

            StorageEntry cached_catalog_data = cache.GetText("CatalogData");

            if (cached_catalog_data == null || cached_catalog_data != null && (DateTime.Now - cached_catalog_data.LastModified).Days > 6)
            {
                APIResponse api_r = LoadAPI(string.Format("{0}://a.4cdn.org/boards.json", Common.HttpPrefix));

                if (api_r.Error == APIResponse.ErrorType.NoError)
                {
                    data = api_r.Data;

                    cache.StoreText("CatalogData", api_r.Data, DateTime.Now);
                }
            }
            else
            {
                data = cached_catalog_data.Text;
            }

            JsonObject json = JsonConvert.Import <JsonObject>(data);

            JsonArray boards = (JsonArray)json["boards"];

            var dic = new Dictionary <string, BoardInfo>();

            for (int i = 0; i < boards.Count; i++)
            {
                JsonObject board = (JsonObject)boards[i];

                string letter = Convert.ToString(board["board"]);
                string desc = Convert.ToString(board["title"]);
                int    bl; int iml;
                if (letter == "f")
                {
                    bl = 300; iml = 150;
                }
                else
                {
                    bl  = Convert.ToInt32(board["bump_limit"]);
                    iml = Convert.ToInt32(board["image_limit"]);
                }
                dic.Add(letter, new BoardInfo()
                {
                    Title      = desc,
                    BumpLimit  = bl,
                    ImageLimit = iml
                });
            }

            return(dic);
        }