예제 #1
0
        private static Dictionary <string, string> GetJavCategory()
        {
            Dictionary <string, string> genreDic = new Dictionary <string, string>();

            int times    = 1;
            int maxTimes = 3;

            //最大重试3次
            while (times <= maxTimes && (cc == null || cc.Count < 3))
            {
                GetJavCookie();
                times++;

                if (cc != null && cc.Count >= 3)
                {
                    break;
                }
            }

            if (times < 4 && cc != null)
            {
                //获取分类, 不会过期也不需要多线程
                var htmlRes = HtmlManager.GetHtmlWebClient("http://www.javlibrary.com/cn/", "http://www.javlibrary.com/cn/genres.php", cc, false);

                if (htmlRes.Success)
                {
                    HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
                    htmlDocument.LoadHtml(htmlRes.Content);

                    var genrePath = "//div[@class='genreitem']";

                    var genreNodes = htmlDocument.DocumentNode.SelectNodes(genrePath);

                    foreach (var node in genreNodes)
                    {
                        var aTagHref  = "http://www.javlibrary.com/cn/" + node.ChildNodes[0].Attributes["href"].Value.Trim();
                        var aTagTitle = node.ChildNodes[0].InnerText.Trim();

                        if (!JavDataBaseManager.HasCategoryByName(aTagTitle))
                        {
                            JavDataBaseManager.InsertCategory(new Category
                            {
                                Name = aTagTitle,
                                Url  = aTagHref
                            });
                        }

                        if (!genreDic.ContainsKey(aTagHref))
                        {
                            genreDic.Add(aTagHref, aTagTitle);

                            Console.WriteLine("加入分类 " + aTagHref);
                        }
                    }
                }
            }

            return(genreDic);
        }
예제 #2
0
        public static AV GetCloseLibAVModel(AV javBusRecord, Dictionary <string, string> mapping)
        {
            StringBuilder actSb = new StringBuilder();
            StringBuilder dirSb = new StringBuilder();
            StringBuilder comSb = new StringBuilder();
            StringBuilder pubSb = new StringBuilder();
            StringBuilder catSb = new StringBuilder();

            var actArray = javBusRecord.Actress.Split(',');
            var dirArray = javBusRecord.Director.Split(',');
            var comArray = javBusRecord.Company.Split(',');
            var pubArray = javBusRecord.Publisher.Split(',');
            var catArray = javBusRecord.Category.Split(',');

            foreach (var act in actArray)
            {
                if (!string.IsNullOrEmpty(act))
                {
                    if (act.Contains("("))
                    {
                        var  temp    = act.Replace("(", "、").Replace(")", "");
                        var  tempArr = temp.Split('、');
                        bool find    = false;

                        foreach (var split in tempArr)
                        {
                            if (JavDataBaseManager.HasActressByName(split))
                            {
                                actSb.Append(split + ",");
                                find = true;
                                break;
                            }
                        }

                        if (!find)
                        {
                            actSb.Append("[" + temp + "]");
                        }
                    }
                    else
                    {
                        if (JavDataBaseManager.HasActressByName(act))
                        {
                            actSb.Append(act + ",");
                        }
                        else
                        {
                            actSb.Append("[" + act + "]");
                        }
                    }
                }
            }

            foreach (var dir in dirArray)
            {
                if (!string.IsNullOrEmpty(dir))
                {
                    if (JavDataBaseManager.HasDirectorByName(dir))
                    {
                        dirSb.Append(dir + ",");
                    }
                    else
                    {
                        dirSb.Append("[" + dir + "],");
                    }
                }
            }

            foreach (var com in comArray)
            {
                if (!string.IsNullOrEmpty(com))
                {
                    if (JavDataBaseManager.HasCompanyByName(com))
                    {
                        comSb.Append(com + ",");
                    }
                    else
                    {
                        comSb.Append("[" + com + "],");
                    }
                }
            }

            foreach (var pub in pubArray)
            {
                if (!string.IsNullOrEmpty(pub))
                {
                    if (!string.IsNullOrEmpty(pub))
                    {
                        if (JavDataBaseManager.HasCompanyByName(pub))
                        {
                            pubSb.Append(pub + ",");
                        }
                        else
                        {
                            pubSb.Append("[" + pub + "],");
                        }
                    }
                }
            }

            foreach (var cat in catArray)
            {
                if (!string.IsNullOrEmpty(cat))
                {
                    var jianti = FileUtility.GetJianTiStr(cat);

                    if (mapping.ContainsKey(jianti))
                    {
                        var mapStr = mapping[jianti];

                        if (JavDataBaseManager.HasCategoryByName(mapStr))
                        {
                            catSb.Append(mapStr + ",");
                        }
                    }
                    else
                    {
                        catSb.Append("[" + jianti + "],");
                    }
                }
            }

            javBusRecord.Actress   = actSb.ToString();
            javBusRecord.Director  = dirSb.ToString();
            javBusRecord.Company   = comSb.ToString();
            javBusRecord.Publisher = pubSb.ToString();
            javBusRecord.Category  = catSb.ToString();

            return(javBusRecord);
        }