Exemplo n.º 1
0
 public GaoQingCollection()
 {
     http             = new HttpHelper();
     movie_bll        = new Movie_BLL();
     download_bll     = new Download_BLL();
     subtitle_bll     = new Subtitle_BLL();
     douBanCollection = new DouBanCollection();
 }
Exemplo n.º 2
0
        public void AnalysisMovieDownloadHtml(int movieID, string html)
        {
            try
            {
                HtmlDocument hd = new HtmlDocument();
                hd.LoadHtml(html);
                var node       = hd.DocumentNode.SelectSingleNode("//table[@id='cili']");
                var info_nodes = node == null ? null : node.SelectNodes("./tr");
                if (info_nodes != null)
                {
                    for (int i = 0; i < (info_nodes.Count > 10 ? info_nodes.Count - 2 : info_nodes.Count); i++)
                    {
                        var    item  = info_nodes[i];
                        string clear = item.GetAttributeValue("id", "") == null ? null : item.GetAttributeValue("id", "").Trim();
                        switch (clear)
                        {
                        case "原盘REMUX":
                            clear = "Remux";
                            break;

                        case "左右3D":
                            clear = "3D";
                            break;

                        case "3D原盘中字":
                            clear = "3D Bluray";
                            break;

                        case "WEB-DL":
                            clear = "WEB-DL";
                            break;

                        case "上下3D":
                            clear = "3D";
                            break;

                        case "蓝光原盘":
                            clear = "Bluray";
                            break;

                        case "HDTV":
                            clear = "HDTV";
                            break;

                        case "硬字幕版":
                            clear = "HD";
                            break;

                        case "720P":
                            clear = "720P";
                            break;

                        case "原盘中字":
                            clear = "Bluray";
                            break;

                        case "3D原盘":
                            clear = "3D Bluray";
                            break;

                        case "1080P":
                            clear = "1080P";
                            break;

                        case "非高清或错误":
                            clear = "其它";
                            break;

                        default:
                            clear = "其它";
                            break;
                        }
                        var     name     = item.SelectSingleNode("./td/b") == null ? "" : item.SelectSingleNode("./td/b").InnerText.Trim();
                        string  size_str = item.SelectSingleNode("./td/span/span[1]") == null ? null : item.SelectSingleNode("./td/span/span[1]").InnerText.Trim();
                        decimal?size     = null;
                        if (!string.IsNullOrWhiteSpace(size_str))
                        {
                            if (size_str.Contains("TB"))
                            {
                                size = Convert.ToDecimal(Utils.ToDouble_(size_str.Replace("TB", "").Trim(), 0) * (1024.0 * 1024.0 * 1024.0));
                            }
                            if (size_str.Contains("GB"))
                            {
                                size = Convert.ToDecimal(Utils.ToDouble_(size_str.Replace("GB", "").Trim(), 0) * (1024.0 * 1024.0));
                            }
                            if (size_str.Contains("MB"))
                            {
                                size = Convert.ToDecimal(Utils.ToDouble_(size_str.Replace("MB", "").Trim(), 0) * (1024.0));
                            }
                            if (size_str.Contains("KB"))
                            {
                                size = Convert.ToDecimal(Utils.ToDouble_(size_str.Replace("KB", "").Trim(), 0));
                            }
                            size = size == 0 ? null : size;
                        }
                        //decimal? size = Convert.ToDecimal(string.IsNullOrWhiteSpace(size_str) ? 0 : ((size_str.Contains("GB") ? Utils.StrToDouble(size_str.Replace("GB", "").Trim(), 0) : ((size_str.Contains("MB") ? Utils.StrToDouble(size_str.Replace("MB", "").Trim(), 0) : (size_str.Contains("KB") ? Utils.StrToDouble(size_str.Replace("KB", "").Trim(), 0) : 0)) * 1024.0)) * 1024.0 * 1024.0));
                        var meta   = item.SelectSingleNode("./td/span/span[2]") == null ? null : item.SelectSingleNode("./td/span/span[2]").InnerText.Trim();
                        var bthash = item.SelectSingleNode("./td/span/span[3]/a[1]") == null ? null : item.SelectSingleNode("./td/span/span[3]/a[1]").GetAttributeValue("href", "").Trim();
                        var magnet = item.SelectSingleNode("./td/span/span[3]/a[2]") == null ? null : item.SelectSingleNode("./td/span/span[3]/a[2]").GetAttributeValue("href", "").Trim();

                        if (!string.IsNullOrWhiteSpace(magnet) && clear != "其它")
                        {
                            int did = new Download_BLL().SaveDownload(new Domain.Entity.Download_Repository()
                            {
                                CreateTime = DateTime.Now,
                                Clear      = clear,
                                Size       = size == 0 ? null : size,
                                Guid       = Guid.NewGuid().ToString().ToUpper(),
                                Magnet     = string.IsNullOrWhiteSpace(magnet) ? null : magnet,
                                Meta       = string.IsNullOrWhiteSpace(meta) ? null : meta,
                                MovieID    = movieID,
                                Source     = "gaoqing",
                                Title      = name,
                                BitTorrent = bthash
                            });
                            if (did > 0)
                            {
                                Console.WriteLine(name + "\t" + size_str + "\t写入数据库成功!");
                            }
                            else
                            {
                                Console.WriteLine(name + "\t" + size_str + "\t写入数据库失败!");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }