Esempio n. 1
0
 private async void QuickSave_Click(object sender, RoutedEventArgs e)
 {
     if (tapped == null)
     {
         return;
     }
     await IllustDetail.FromObject(await new PixivAppAPI(OverAll.GlobalBaseAPI).GetIllustDetailAsync(tapped.ItemId.ToString())).AutoDownload();
 }
Esempio n. 2
0
        internal Illust(PixivClient client, IllustDetail api)
        {
            _client = client;
            Id      = api.Id;
            Title   = api.Title;
#pragma warning disable IDE0079 // 请删除不必要的忽略
#pragma warning disable CA1307  // 指定 StringComparison
            Description = api.Caption.Replace("<br/>", string.Empty);
#pragma warning restore CA1307  // 指定 StringComparison
#pragma warning restore IDE0079 // 请删除不必要的忽略
            IsR18          = api.XRestrict > 0;
            Tags           = api.Tags.Select(t => new Tag(client, t)).ToArray();
            Created        = api.CreateDate;
            SizePixels     = new Size(api.Width, api.Height);
            TotalView      = api.TotalView;
            TotalBookmarks = api.TotalBookmarks;
            IsBookmarked   = api.IsBookmarked;

            if (api.PageCount == 1)
            {
                if (api.MetaSinglePage.OriginalImageUrl is null)
                {
                    throw new InvalidOperationException("Corrupt api response");
                }

                Pages = new[] { new IllustPage(this, 0, _client, api.ImageUrls, api.MetaSinglePage.OriginalImageUrl) };
            }
            else
            {
                if (api.MetaPages.IsDefault || api.MetaPages.Length != api.PageCount)
                {
                    throw new InvalidOperationException("Corrupt api response");
                }

                Pages = api.MetaPages.Select((p, i) => new IllustPage(this, i, _client, p.ImageUrls)).ToArray();
            }

            User       = new UserInfo(client, api.User);
            IsAnimated = api.Type == "ugoira";

            SeriesId = api.Series?.Id switch
            {
                0 or null => null,
                var other => other
            };
        }