Esempio n. 1
0
        public static MangaCategoryVM GetMangaCategory(MangaCategorySourceType sourceType)
        {
            MangaCategoryVM ret = new MangaCategoryVM();

            ret.Categories = new List <MangaCategoryItem>();

            var model = MangaDatabaseHelper.GetMangaCategoryByType(sourceType);

            if (model != null && model.Count > 0)
            {
                foreach (var m in model)
                {
                    MangaCategoryItem temp = new MangaCategoryItem();

                    temp.Category     = m.Category;
                    temp.IsRoot       = m.Category == "全部";
                    temp.RootCategory = m.RootCategory;
                    temp.Url          = m.Url;

                    ret.Categories.Add(temp);
                }
            }
            else
            {
                ret.MsgCode = VMCode.Error;
                ret.Msg     = "没有找到Type = " + sourceType + " 的漫画分类";
            }

            return(ret);
        }
Esempio n. 2
0
        public MangaCategoryListVM GetMangaCategoryList(MangaCategorySourceType sourceType, string category, int page)
        {
            if (string.IsNullOrEmpty(category))
            {
                category = "";
            }

            var model = MangaService.GetMangaCategoryList(sourceType, category, page);

            return(model);
        }
Esempio n. 3
0
        private static MangaPicturesVM GetMangePicHanhan(MangaCategorySourceType sourceType, string path)
        {
            MangaPicturesVM ret = new MangaPicturesVM();

            ret.PicList = new List <string>();

            var htmlRet = HtmlManager.GetHtmlWebClient("http://www.hanhan.net", path);

            if (htmlRet.Success)
            {
                try
                {
                    HtmlDocument htmlDocument = new HtmlDocument();
                    htmlDocument.LoadHtml(htmlRet.Content);

                    var urlPath = "//link[@rel='miphtml']";

                    var urlNode = htmlDocument.DocumentNode.SelectSingleNode(urlPath);

                    var decrypt = htmlRet.Content.Substring(htmlRet.Content.IndexOf("chapterImages = ") + "chapterImages = ".Length);
                    decrypt = decrypt.Substring(0, decrypt.IndexOf("]") + 1);

                    var urlHeader = htmlRet.Content.Substring(htmlRet.Content.IndexOf("chapterPath = \"") + "chapterPath = \"".Length);
                    urlHeader = urlHeader.Substring(0, urlHeader.IndexOf("\""));

                    var picList = JsonConvert.DeserializeObject <List <string> >(decrypt);

                    foreach (var pic in picList)
                    {
                        if (!pic.StartsWith("http"))
                        {
                            ret.PicList.Add("http://img001.shaque.vip/" + urlHeader + pic);
                        }
                        else
                        {
                            ret.PicList.Add(pic);
                        }
                    }
                }
                catch (Exception e)
                {
                    ret.MsgCode = VMCode.Exception;
                    ret.Msg     = e.ToString();
                }
            }
            else
            {
                ret.MsgCode = VMCode.Error;
                ret.Msg     = "获取网页失败";
            }

            return(ret);
        }
Esempio n. 4
0
        public static MangaDetailVM GetMangaDetail(MangaCategorySourceType sourceType, string path)
        {
            MangaDetailVM ret = new MangaDetailVM();

            switch (sourceType)
            {
            case MangaCategorySourceType.憨憨漫画:
                ret = GetMangaDetailHanhan(sourceType, path);
                break;
            }

            return(ret);
        }
Esempio n. 5
0
        public static MangaCategoryListVM GetMangaCategoryList(MangaCategorySourceType sourceType, string category, int page)
        {
            MangaCategoryListVM ret = new MangaCategoryListVM();

            switch (sourceType)
            {
            case MangaCategorySourceType.憨憨漫画:
                ret = GetManageCategoryListHanhan(category.Split(','), page);
                break;
            }

            return(ret);
        }
Esempio n. 6
0
        public static List <MangaCategory> GetMangaCategoryByType(MangaCategorySourceType type)
        {
            var sql = "SELECT RootCategory, Category, Url FROM MangaCategory WHERE SourceType = @type";

            return(Query <MangaCategory>(ConnectionStrings.Manga, sql, new { type }));
        }
Esempio n. 7
0
        public MangaPicturesVM GetMangaPic(MangaCategorySourceType sourceType, string path)
        {
            var model = MangaService.GetMangaPic(sourceType, path);

            return(model);
        }
Esempio n. 8
0
        public MangaDetailVM GetMangaDetail(MangaCategorySourceType sourceType, string path)
        {
            var model = MangaService.GetMangaDetail(sourceType, path);

            return(model);
        }
Esempio n. 9
0
        public MangaCategoryVM GetManagaCategory(MangaCategorySourceType sourceType)
        {
            var ret = MangaService.GetMangaCategory(sourceType);

            return(ret);
        }
Esempio n. 10
0
        public static List <MangaCategory> GetMangaCategoryByType(MangaCategorySourceType type)
        {
            var sql = string.Format("SELECT RootCategory, Category, Url FROM MangaCategory WHERE SourceType = {0}", (int)type);

            return(SqlHelper.ExecuteDataTable(con, CommandType.Text, sql).ToList <MangaCategory>());
        }
Esempio n. 11
0
        public static MangaDetailVM GetMangaDetailHanhan(MangaCategorySourceType sourceType, string path)
        {
            MangaDetailVM ret = new MangaDetailVM();

            ret.Chapters = new List <MangaChapter>();

            var htmlRet = HtmlManager.GetHtmlWebClient("http://www.hanhan.net", path);

            if (htmlRet.Success)
            {
                try
                {
                    HtmlDocument document = new HtmlDocument();
                    document.LoadHtml(htmlRet.Content);

                    var picPath     = "//img[@class='pic']";
                    var detailPath  = "//ul[@class='detail-list cf']/li";
                    var infoPath    = "//div[@id='intro-all']//p";
                    var chapterPath = "//ul[@id='chapter-list-4']//a";

                    var picNode  = document.DocumentNode.SelectSingleNode(picPath);
                    var infoNode = document.DocumentNode.SelectSingleNode(infoPath);

                    var chapterNodes = document.DocumentNode.SelectNodes(chapterPath);
                    var detailNodes  = document.DocumentNode.SelectNodes(detailPath);

                    if (picNode != null)
                    {
                        ret.PicUrl    = picNode.Attributes["src"].Value.Trim();
                        ret.MangaName = picNode.Attributes["alt"].Value.Trim();
                    }

                    if (detailNodes != null && detailNodes.Count > 0)
                    {
                        foreach (var node in detailNodes)
                        {
                            if (node.Attributes.Count <= 0)
                            {
                                foreach (var subNode in node.ChildNodes)
                                {
                                    if (subNode.InnerText.StartsWith("漫画作者:"))
                                    {
                                        ret.Author = subNode.InnerText.Replace("漫画作者:", "");
                                    }
                                }
                            }
                            else
                            {
                                ret.MangaStatus = node.ChildNodes.FindFirst("a").InnerHtml;

                                ret.UpdateDate = DateTime.Parse(node.ChildNodes[1].ChildNodes[5].InnerText);
                                ret.UpdateInfo = "更新到:" + node.ChildNodes[1].ChildNodes[7].InnerText;
                            }
                        }
                    }

                    if (infoNode != null)
                    {
                        ret.Description = infoNode.InnerText.Trim();
                    }

                    if (chapterNodes != null)
                    {
                        foreach (var node in chapterNodes)
                        {
                            ret.Chapters.Add(new MangaChapter
                            {
                                Url         = "http://www.hanhande.net" + node.Attributes["href"].Value.Trim(),
                                ChapterName = node.ChildNodes.FindFirst("span").InnerText.Trim()
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    ret.MsgCode = VMCode.Exception;
                    ret.Msg     = e.ToString();
                }
            }
            else
            {
                ret.MsgCode = VMCode.Success;
                ret.Msg     = "网页获取失败";
            }

            return(ret);
        }