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");
            }
        }
        public void TestShimmie2Parser()
        {
            var shimmie2Provider = DanbooruProviderDao.GetInstance().Read(sourceProvider).Where <DanbooruProvider>(x => x.BoardType == BoardType.Shimmie2).First <DanbooruProvider>();
            var xml = "";

            using (StreamReader reader = new StreamReader(@"../../../DanbooruDownloader3.test/TestXml/shimmie2.xml"))
            {
                xml = reader.ReadToEnd();
            }

            DanbooruPostDaoOption option = new DanbooruPostDaoOption()
            {
                Provider                  = shimmie2Provider,
                Query                     = "",
                SearchTags                = "",
                BlacklistedTags           = null,
                BlacklistedTagsRegex      = new Regex("$^"),
                BlacklistedTagsUseRegex   = false,
                IsBlacklistOnlyForGeneral = false,
            };

            var list = ShimmieEngine.ParseRSS(xml, option);

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Count == 9);
        }
        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);
        }
示例#4
0
        private void FillProvider()
        {
            if (providerList == null)
            {
                providerList = DanbooruProviderDao.GetInstance().Read();
            }

            foreach (DanbooruProvider p in providerList)
            {
                var controls = pnlProvider.Controls.Find(p.Name, true);
                if (controls.Length == 0)
                {
                    CheckBox chk = new CheckBox();
                    chk.Name     = p.Name;
                    chk.Text     = p.Name;
                    chk.AutoSize = true;
                    chkList.Add(chk);
                }
            }

            foreach (CheckBox c in chkList)
            {
                this.pnlProvider.Controls.Add(c);
            }
        }
 private void FormDownloadTags_Load(object sender, EventArgs e)
 {
     list = DanbooruProviderDao.GetInstance().Read().Where <DanbooruProvider>(x => x.BoardType == Entity.BoardType.Danbooru || x.BoardType == Entity.BoardType.Gelbooru).ToList <DanbooruProvider>();
     cbxProvider.DataSource    = list;
     cbxProvider.DisplayMember = "Name";
     cbxProvider.ValueMember   = "Url";
     cbxProvider.SelectedIndex = -1;
     txtUrl.Text = "";
     isClosing   = false;
 }
        public void TestProviderSave()
        {
            string target = @"../../../DanbooruDownloader3.test/testSave.xml";
            var    list   = DanbooruProviderDao.GetInstance().Read(sourceProvider);

            list[0].Name = "hahaha";
            DanbooruProviderDao.GetInstance().Save(list, target);
            Assert.IsTrue(System.IO.File.Exists(target));
            XDocument doc = XDocument.Load(target);

            list = DanbooruProviderDao.GetInstance().Read(target);
            Assert.IsTrue(list[0].Name == "hahaha");
        }
示例#7
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);
        }
        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);
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     GetValues(cbxProviders.SelectedIndex);
     //IsModified = true;
     DanbooruProviderDao.GetInstance().Save(Providers);
 }