Ejemplo n.º 1
0
        public ArrayList alys(string content, string path, string vid)
        {
            ArrayList resList = new ArrayList();

            content = content.Replace("<b>", "").Replace("</b>", "");
            string[] contents = content.Split(new string[] { "class=\"idx\"" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in contents)
            {
                His his = new His();
                his.OriginalHtml = s;
                if (s.Contains("DOCTYPE HTML PUBLIC"))
                {
                    continue;
                }
                his.Vid = s.Split(new string[] { "\">", "</a></td></tr></tbody></table><table class=" }, StringSplitOptions.RemoveEmptyEntries)[3];

                MatchCollection match = r.Matches(his.Vid.ToLower());
                if (match.Count != 1)
                {
                    invalid += his.OriginalHtml + "/r/n";
                    continue;
                }
                his.Vid = match[0].Value.Replace(" ", "").Replace("-", "").Replace("_", "");

                MatchCollection sizeMatch = sizeRegexGB.Matches(his.OriginalHtml);
                if (sizeMatch.Count > 0)
                {
                    his.Size = Convert.ToDouble(sizeMatch[0].Value.Replace("&nbsp;GB</span>", "").Replace("大小:</span><span class=\"attr_val\">", "")) * 1024;
                }
                if (sizeMatch.Count == 0)
                {
                    sizeMatch = sizeRegexMB.Matches(his.OriginalHtml);
                    his.Size  = Convert.ToDouble(sizeMatch[0].Value.Replace("&nbsp;MB</span>", "").Replace("大小:</span><span class=\"attr_val\">", ""));
                }
                getHtml(his, his.Size.ToString());
                resList.Add(his);
            }
            Tool.WriteFile(path, invalid);
            return(resList);
        }
Ejemplo n.º 2
0
        public void process(string directoryStr, IAnalysis ana, bool ifCheckHis)
        {
            Thread th = new Thread(curlCheck);

            th.Start();

            string    invalidHtmlHis = "<html><body>";
            string    invalidHTML    = "<html><body>";
            string    invalidHTML44x = "<html><body>";
            string    blackListHTML  = "<html><body>";
            ArrayList hisList        = new ArrayList();
            string    resultHTML     = "<html><body>";

            String[] path = Directory.GetFiles(directoryStr, "*", SearchOption.TopDirectoryOnly);
            foreach (String p in path)
            {
                Console.WriteLine(p);
                StreamReader sr      = new StreamReader(p);
                string       content = sr.ReadToEnd();

                sr.Close();
                string[] strs = Path.GetFileNameWithoutExtension(p).Split('_');
                string   vid  = "";
                if (strs.Length > 4)
                {
                    vid = strs[4];
                }
                ArrayList list = ana.alys(content, p, vid, ifCheckHis);
                foreach (His his in list)
                {
                    his.Vid = his.Vid.Replace("-", "").Replace("_", "");
                    if (his.IsBlack)
                    {
                        DBHelper.insertBLackList(his);
                        blackListHTML += his.Html;
                        continue;
                    }
                    if (filter.CheckBlackList(his))
                    {
                        blackListHTML += his.Html;
                        continue;
                    }
                    if (filter.checkValid(his))
                    {
                        his.Html += BaseAnalysis.getSearchHtml(his.Vid, his.Size, his.Name, true, his);
                        hisList.Add(his);
                    }
                    else
                    {
                        his.Html += BaseAnalysis.getSearchHtml(his.Vid, his.Size, his.Name, false, his);
                        if (his.FailReason == "file")
                        {
                            invalidHTML += his.Html;
                        }
                        else if (his.FailReason == "his")
                        {
                            invalidHtmlHis += his.Html;
                        }
                        else if (his.FailReason == "44x")
                        {
                            invalidHTML44x += his.Html;
                        }
                    }
                }
            }
            SortedDictionary <String, His> dic = new SortedDictionary <string, His>();

            foreach (His his in hisList)
            {
                if (!dic.Keys.Contains(his.Vid) || dic[his.Vid].Size < his.Size)
                {
                    dic.Remove(his.Vid);
                    dic.Add(his.Vid, his);
                }
            }
            foreach (His his in dic.Values)
            {
                resultHTML += his.Html;
                if (his.TorrentPath != "")
                {
                    Tool.MoveFile("result", his.TorrentPath);
                }
                if (his.HtmPath != "")
                {
                    Tool.MoveFile("result", his.HtmPath);
                }
            }
            resultHTML     += "</body></html>";
            invalidHTML    += "</body></html>";
            invalidHtmlHis += "</body></html>";
            blackListHTML  += "</body></html>";
            invalidHTML44x += "</body></html>";
            Tool.WriteFile(Path.Combine(directoryStr, "result.htm"), resultHTML);
            Tool.WriteFile(Path.Combine(directoryStr, "invalid.htm"), invalidHTML);
            Tool.WriteFile(Path.Combine(directoryStr, "invalidHis.htm"), invalidHtmlHis);
            Tool.WriteFile(Path.Combine(directoryStr, "blackList.htm"), blackListHTML);
            Tool.WriteFile(Path.Combine(directoryStr, "44x.htm"), invalidHTML44x);
        }