コード例 #1
0
        public void TestDanbooruEngineParser()
        {
            DanbooruProviderDao pd = DanbooruProviderDao.GetInstance();
            DanbooruXmlEngine   e  = new DanbooruXmlEngine();

            {
                XDocument doc         = XDocument.Load(sourceDanbooruXml);
                var       searchQuery = new DanbooruSearchParam();
                searchQuery.Provider = pd.Read(sourceProvider).Where <DanbooruProvider>(x => x.BoardType == BoardType.Danbooru && x.Name.Contains("danbooru")).First <DanbooruProvider>();
                BindingList <DanbooruPost> result = e.Parse(doc.ToString(), searchQuery);
                Assert.IsNotNull(result);
                Assert.IsNotNull(e.RawData);
                Assert.IsTrue(e.TotalPost == 1021107);
                Assert.IsTrue(result.Count == 20);
                Assert.IsTrue(result[0].PreviewUrl == "http://danbooru.donmai.us/ssd/data/preview/73531fc4dda535ef87e57df633caf756.jpg");
            }

            {
                XDocument doc         = XDocument.Load(sourceYandereXml);
                var       searchQuery = new DanbooruSearchParam();
                searchQuery.Provider = pd.Read(sourceProvider).Where <DanbooruProvider>(x => x.BoardType == BoardType.Danbooru && x.Name.Contains("yande.re")).First <DanbooruProvider>();
                BindingList <DanbooruPost> result = e.Parse(doc.ToString(), searchQuery);
                Assert.IsNotNull(result);
                Assert.IsNotNull(e.RawData);
                Assert.IsTrue(e.TotalPost == 160753);
                Assert.IsTrue(result.Count == 16);
                Assert.IsTrue(result[0].PreviewUrl == "https://yande.re/data/preview/d3/41/d34184030ee19c6e63051967cf135f65.jpg");
            }
        }
コード例 #2
0
        public void TestSankakuParser()
        {
            DanbooruProviderDao pd = DanbooruProviderDao.GetInstance();
            string target          = @"../../../DanbooruDownloader3.test/TestXml/sankaku_paging.htm";
            var    data            = File.ReadAllText(target);
            var    query           = new DanbooruSearchParam();

            query.Provider = pd.Read(sourceProvider).Where(x => x.Name == "Sankaku Complex").First();
            query.Tag      = "";
            query.OrderBy  = "score";

            var parser = new SankakuComplexParser();

            var result = parser.Parse(data, query);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 20, "Count: " + result.Count);
            Assert.IsTrue(result[0].Id == "1929657", "Id: " + result[0].Id);
            Assert.IsTrue(result[0].Provider.Name == "Sankaku Complex", "Provider: " + result[0].Provider.Name);
            Assert.IsTrue(result[0].SearchTags == "", "SearchTags: " + result[0].SearchTags);
            Assert.IsTrue(result[0].Query == "tags=order:score", "Query: " + result[0].Query);

            Assert.IsTrue(result[0].Tags == "fate_(series) code_geass fate/zero gilgamesh kotomine_kirei 3boys androgynous armlet blonde bracelet brown_hair clamp_(style) cross cross_necklace earrings enkidu_(fate/strange_fake) fate/strange_fake green_eyes green_hair hand_on_own_face jewelry long_hair multiple_boys necklace parody red_eyes ruchi style_parody toga", "Tags: " + result[0].Tags);
            Assert.IsTrue(result[0].PreviewUrl == "http://c2.sankakustatic.com/data/preview/85/f5/85f54efd7fea7ba91b20ca09ad5823c7.jpg", "PreviewUrl: " + result[0].PreviewUrl);
            Assert.IsTrue(result[0].PreviewHeight == 144, "PreviewHeight: " + result[0].PreviewHeight);
            Assert.IsTrue(result[0].PreviewWidth == 150, "PreviewWidth: " + result[0].PreviewWidth);
            Assert.IsTrue(result[0].Score == "0.0", "Score: " + result[0].Score);
            Assert.IsTrue(result[0].Rating == "s", "Rating: " + result[0].Rating);
        }
コード例 #3
0
        public void TestShimmieHtmlParser()
        {
            DanbooruProviderDao pd = DanbooruProviderDao.GetInstance();
            string target          = @"../../../DanbooruDownloader3.test/TestXml/rule34hentai.htm";
            var    data            = File.ReadAllText(target);
            var    query           = new DanbooruSearchParam();

            query.Provider = pd.Read(sourceProvider).Where(x => x.Name == "rule34hentai.net").First();
            query.Tag      = "";
            query.OrderBy  = "score";

            var parser = new ShimmieHtmlParser();

            var result = parser.Parse(data, query);

            Assert.IsNotNull(result);
        }
コード例 #4
0
        public void TestGelbooruParser()
        {
            DanbooruProviderDao pd = DanbooruProviderDao.GetInstance();
            string target          = @"../../../DanbooruDownloader3.test/TestXml/gelbooru_post.htm";
            var    data            = File.ReadAllText(target);
            var    query           = new DanbooruSearchParam();

            query.Provider = pd.Read(sourceProvider).Where(x => x.Name == "gelbooru.com").First();
            query.Tag      = "";
            query.OrderBy  = "score";

            var post = new DanbooruPost();

            post.Provider = query.Provider;
            GelbooruHtmlParser.ParsePost(post, data);

            Assert.IsNotNull(post.FileUrl);
            Assert.IsTrue(post.FileUrl == @"http://cdn2.gelbooru.com//images/1559/303b7ed1fcba0c1d9520f76ee34ec37e.jpg", "Actual: " + post.FileUrl);
        }