예제 #1
0
        public async Task <List <Episode> > getQueue()
        {
            if (!hasInternet() && queue != null)
            {
                return(queue);
            }
            queue = new List <Episode>();

            Response resp = await getResponse("http://followshows.com/api/queue?from=0", null);

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(resp.page);



            foreach (HtmlNode Episode in doc.DocumentNode.ChildNodes)
            {
                if (Episode.Name != "li")
                {
                    continue;
                }
                Episode ep = new Episode(true, false);

                foreach (HtmlNode item in Episode.DescendantNodes())
                {
                    if (item.Attributes["class"] != null)
                    {
                        switch (item.Attributes["class"].Value)
                        {
                        case "column_date hidden-xs hidden-sm":
                            foreach (HtmlNode item2 in item.DescendantNodes())
                            {
                                if (item2.Attributes["title"] != null)
                                {
                                    ep.airtime = DateTime.Parse(item2.Attributes["title"].Value);
                                }


                                if (item2.Attributes["class"] != null)    //&& item2.Attributes["class"].Value == "network")
                                {
                                    ep.network = item2.InnerHtml;
                                }
                            }
                            break;

                        case "column_poster":
                            foreach (HtmlNode node in item.DescendantNodes().ToArray <HtmlNode>()[0].DescendantNodes())
                            {
                                if (node.Name == "#text")
                                {
                                    continue;
                                }
                                if (node != null && node.Attributes["src"] != null)
                                {
                                    BitmapImage bitmapImage = new BitmapImage();
                                    bitmapImage.UriSource     = new Uri(node.Attributes["src"].Value.Replace("180", "360").Replace("104", "207"));
                                    bitmapImage.CreateOptions = BitmapCreateOptions.None;
                                    //ep.Image = node.Attributes["src"].Value;
                                    ep.Image = bitmapImage;
                                }
                            }
                            break;

                        case "column_infos":
                            helpItem(item, ep);
                            break;
                        }
                    }
                }
                queue.Add(ep);
            }
            return(queue);
        }