Exemple #1
0
        public async Task DeleteTagAsync(string workid)
        {
            DerpTag tag = _derpTags.Find(i => i.Id == workid);

            await GetConnection().DeleteAsync(tag);

            _derpTags.Remove(tag);
        }
Exemple #2
0
 public async Task UpdateTagAsync(DerpTag tag)
 {
     using (var releaser = await myLock.LockAsync())
     {
         if (tag != _derpTags.Find(i => i.Id == tag.Id))
         {
             int i = _derpTags.FindIndex(j => j.Id == tag.Id);
             _derpTags[i] = tag;
         }
         await GetConnection().UpdateAsync(tag);
     }
 }
Exemple #3
0
 public SearchBoxLabel(DerpTag model, DerpImagesViewModel viewModel)
 {
     this.Margin    = margin;
     this.model     = model;
     this.viewModel = viewModel;
     this.Text      = (model.Sub ? "-":string.Empty) + model.Name;
     this.GestureRecognizers.Add(new TapGestureRecognizer()
     {
         Command = new Command(() =>
         {
             viewModel.RemoveFilterItem(model);
             ((FlexLayout)Parent).Children.Remove(this);
         }),
         NumberOfTapsRequired = 1
     });
 }
        public List <DerpTag> GetTagInfoFromDerpibooru(List <DerpTag> oldTags, int max, IWebConnection _web, out int newcount)
        {
            newcount = 0;

            List <DerpTag> newTags = new List <DerpTag>();

            using (WebClient webClient = new WebClient())
            {
                int    pageindex = 1;
                string url       = "https://derpibooru.org/tags?page=";
                string infostr;
                string tempstr;
                string tempstr2;

                ProgressBarHeight    = 8;
                ProgressBarIsVisible = true;

                while (true)
                {
                    infostr = webClient.DownloadString(url + pageindex);
                    infostr = Library.extractionString(infostr, "<div class=\"tag-list\">", "</div>");

                    if (infostr.Contains("<span class=\"tag dropdown\" "))
                    {
                        while (infostr.Contains("<span class=\"tag dropdown\" "))
                        {
                            try
                            {
                                Library.extractionString(infostr, out infostr, "<span class=\"tag dropdown\" ", "Filter</a></span></span>", out tempstr);
                                DerpTag tag = new DerpTag();
                                tag.CategoryStrEn = Library.extractionString(tempstr, "data-tag-category=\"", "\"");
                                tag.Id            = Library.extractionString(tempstr, "data-tag-id=\"", "\"");
                                tempstr2          = Library.extractionString(tempstr, "data-tag-name=\"", "\"");
                                tag.NameEn        = tag.NameKr = System.Web.HttpUtility.HtmlDecode(tempstr2).Replace("&#39;", "'");
                                tempstr2          = Library.extractionString(tempstr, "title=\"", "\"");
                                tag.DescriptionEn = tag.DescriptionKr = System.Web.HttpUtility.HtmlDecode(tempstr2);
                                DerpTag temp = oldTags.Find(i => i.Id == tag.Id);
                                if (temp != null)
                                {
                                    tag = temp;
                                }
                                else
                                {
                                    newcount++;
                                }
                                tag.Index = newTags.Count;
                                newTags.Add(tag);

                                Progress = (float)newTags.Count / max;
                                if (newTags.Count >= max)
                                {
                                    goto EndPoint;
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                                goto EndPoint;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                    pageindex++;
                }

EndPoint:
                for (int season = 9; season > 0; season--)
                {
                    int fin  = season == 3 ? 13 : 26;
                    var tags = new DerpTag($"spoiler:s{season.ToString("D2")}")
                    {
                        Category = DerpTagCategory.SPOILER, Index = newTags.Count
                    };
                    newTags.RemoveAll(i => i.NameEn == tags.NameEn);
                    newTags.Add(tags);
                    for (int episod = fin; episod > 0; episod--)
                    {
                        var tage = new DerpTag($"spoiler:s{season.ToString("D2")}e{episod.ToString("D2")}")
                        {
                            Category = DerpTagCategory.SPOILER, Index = newTags.Count
                        };
                        newTags.RemoveAll(i => i.NameEn == tage.NameEn);
                        newTags.Add(tage);
                    }
                }
                newTags.Add(new DerpTag("score.gt:100"));
                newTags.Add(new DerpTag("score.gt:500"));
                newTags.Add(new DerpTag("score.gt:1000"));
                newTags.Add(new DerpTag("score.gte:100"));
                newTags.Add(new DerpTag("score.gte:500"));
                newTags.Add(new DerpTag("score.gte:1000"));
                newTags.Add(new DerpTag("score.lt:100"));
                newTags.Add(new DerpTag("score.lt:500"));
                newTags.Add(new DerpTag("score.lt:1000"));
                newTags.Add(new DerpTag("score.lte:100"));
                newTags.Add(new DerpTag("score.lte:500"));
                newTags.Add(new DerpTag("score.lte:1000"));


                var olds = oldTags.FindAll(i => newTags.Find(j => j.NameEn == i.NameEn) == null);
                newTags.AddRange(olds);

                ProgressBarHeight    = 0;
                ProgressBarIsVisible = false;
            }
            return(newTags);
        }
Exemple #5
0
        public void RemoveFilterItem(DerpTag tag)
        {
            string key = (tag.Sub ? "-" : string.Empty) + tag.NameEn;

            _tempKeys.Remove(key);
        }
Exemple #6
0
 public void AddFilterItem(DerpTag tag)
 {
     _tempKeys.Add((tag.Sub ? "-" : string.Empty) + tag.NameEn);
     Key = "";
 }
Exemple #7
0
        public async Task InsertTagAsync(DerpTag tag)
        {
            await GetConnection().InsertOrReplaceAsync(tag);

            (await GetTagsAsync()).Insert(0, tag);
        }