private List <TsCategoryItem> parseCategoryList()
        {
            List <TsCategoryItem> result = new List <TsCategoryItem> ();

            String categoryUrlPath = TsUtils.BaseUrl + "/show";

            String categoryContent = HttpWrapper.getRequestData(categoryUrlPath);

            if (categoryContent != null && categoryContent.Length > 0)
            {
                var doc = CQ.Create(categoryContent);

                if (doc != null)
                {
                    var    categories = doc.Select("select#filter-category option");
                    String catVal;
                    String catName;
                    foreach (var category in categories)
                    {
                        catVal  = category.GetAttribute("value");
                        catName = category.InnerText;

                        /* leave All Categories item */
                        if (catVal == "0")
                        {
                            continue;
                        }

                        result.Add(new TsCategoryItem(catVal, catName));
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        private List <TsSerialListItem> parseSerialsInCategory(String cat)
        {
            List <TsSerialListItem> result = new List <TsSerialListItem>();

            cacheCategoryIndex = cat;

            String categoryUrl     = TsCategoryHelper.makeCategoryUrl(cat);
            String categoryContent = HttpWrapper.getRequestData(categoryUrl);

            do
            {
                if (categoryContent != null && categoryContent.Length > 0)
                {
                    var document = CQ.Create(categoryContent);
                    var serials  = document.Select("div.show a");

                    if (serials.Length == 0)
                    {
                        break;
                    }

                    foreach (var serial in serials)
                    {
                        String url    = TsUtils.BaseUrl + serial.GetAttribute("href");
                        String imgUrl = TsUtils.BaseUrl + serial.FirstElementChild.GetAttribute("src");
                        String capt   = serial.LastElementChild.InnerText;

                        result.Add(new TsSerialListItem(capt, imgUrl, url));
                    }

                    var nextItem = document.Select("li.next a").FirstElement();

                    if (nextItem == null)
                    {
                        break;
                    }

                    String nextUrl = TsUtils.BaseUrl + nextItem.GetAttribute("href");

                    categoryContent = HttpWrapper.getRequestData(nextUrl);
                }
                else
                {
                    break;
                }
            } while(true);

            return(result);
        }