Exemplo n.º 1
0
        protected override void OnRequestDetailSuccess(object param, string requeststr)
        {
            base.OnRequestDetailSuccess(param, requeststr);
            MagnetItem item = param as MagnetItem;

            try
            {
                requeststr = HttpUtility.HtmlDecode(requeststr);

                if (!string.IsNullOrEmpty(requeststr) &&
                    item != null)
                {
                    HtmlDocument document = new HtmlDocument();
                    document.LoadHtml(requeststr);

                    HtmlNode node = document.DocumentNode.SelectSingleNode("//div[@class='content']");

                    if (node != null)
                    {
                        item.ActiveTime   = node.GetInnerText(node.XPath + "/div[1]/div[1]/p[2]/b[8]");
                        item.MagneticLink = node.GetFirstAttrText(node.XPath + "/div[1]/div[1]/p[6]/a[1]", "href");

                        HtmlNodeCollection filelistnodes1 = node.SelectNodes("//div[@class='dd filelist']/p");
                        HtmlNodeCollection filelistnodes2 = document.GetElementbyId("filelist_hidden").ChildNodes;

                        var filelist = filelistnodes1 == null
                                ?
                                       filelistnodes2 == null ? null : filelistnodes2
                                :
                                       filelistnodes2 == null ? filelistnodes1 : filelistnodes1.Concat(filelistnodes2);

                        if (filelist != null &&
                            filelist.Any())
                        {
                            int i = 1;
                            foreach (var filenode in filelist)
                            {
                                string text = filenode.InnerText;
                                string size = null;

                                if (filenode.HasChildNodes)
                                {
                                    HtmlNode sizenode = filenode.ChildNodes[2];
                                    if (sizenode != null)
                                    {
                                        size = sizenode.InnerText;
                                        text = text.RemoveEnd(size);
                                    }
                                }

                                item.AddFileItem(new FileItem
                                {
                                    Index    = i++,
                                    FileName = text,
                                    Size     = size
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                item.IsDetailLoaded = true;
            }
        }