public void AddToHistory(Pixeez.Objects.User user) { if (HistoryItems.Items is ObservableCollection <PixivItem> ) { Application.Current.HistoryAdd(user, HistoryItems.Items); UpdateDetail(); } }
public static async Task <List <Pixeez.Objects.Work> > SearchIllustById(this long id, Pixeez.Tokens tokens = null, bool fuzzy = false) { List <Pixeez.Objects.Work> result = null; if (tokens == null) { tokens = await CommonHelper.ShowLogin(); } if (tokens == null) { return(result); } var url = GetAjaxIllustUrl(id); var json_text = await Application.Current.GetRemoteJsonAsync(url); if (!string.IsNullOrEmpty(json_text)) { try { var work = JToken.Parse(json_text).ToObject <AjaxIllustData>(); if (!work.Error) { var illust = work.Illust; #region Get/Set user var userbase = await illust.UserId.GetUser();// ?? await illust.UserId.GetAjaxUser(); Pixeez.Objects.NewUser new_user = userbase is Pixeez.Objects.NewUser ? userbase as Pixeez.Objects.NewUser : null; Pixeez.Objects.User user = userbase is Pixeez.Objects.User ? user = userbase as Pixeez.Objects.User : null; if (userbase != null) { var avatar = userbase.GetAvatarUrl(); if (new_user == null) { new_user = new Pixeez.Objects.NewUser() { Id = userbase.Id, Account = userbase.Account, Name = userbase.Name, Email = userbase.Email, is_followed = userbase.is_followed, profile_image_urls = new Pixeez.Objects.ImageUrls() { Small = avatar, Medium = avatar }, }; } if (user == null) { user = new Pixeez.Objects.User() { Id = userbase.Id, Account = userbase.Account, Name = userbase.Name, Email = userbase.Email, is_followed = userbase.is_followed, ProfileImageUrls = new Pixeez.Objects.ProfileImageUrls() { medium = avatar }, }; } } #endregion #region Set Image Urls var image_urls = new Pixeez.Objects.ImageUrls(); if (illust.ImageUrls is AjaxIllustImageUrls) { image_urls.Small = illust.ImageUrls.Mini; image_urls.Px128x128 = illust.ImageUrls.Thumbnail; image_urls.SquareMedium = illust.ImageUrls.Thumbnail; image_urls.Medium = illust.ImageUrls.Medium; image_urls.Px480mw = illust.ImageUrls.Medium; image_urls.Large = illust.ImageUrls.Large; image_urls.Original = illust.ImageUrls.Original; } #endregion #region Get MetaPages var pages_url = GetAjaxMetaPageUrl(id); List <Pixeez.Objects.Page> pages = illust.PageCount > 1 ? await GetMetaPages(pages_url, tokens) : null; var meta_pages = pages is List <Pixeez.Objects.Page>?pages.Select(p => new Pixeez.Objects.MetaPages() { ImageUrls = p.ImageUrls }) : null; #endregion #region Get Tags var tags = illust.MoreTags.Select(t => new Pixeez.Objects.Tag() { Name = t.Original, TranslatedName = t.Translated }).ToArray(); #endregion #region Create IllustWork var i = new Pixeez.Objects.IllustWork() { Type = "illust", Id = id, user = userbase == null ? null : new_user, Title = illust.Title, Caption = illust.Caption, Width = illust.Width, Height = illust.Height, ImageUrls = image_urls, PageCount = illust.PageCount, Metadata = new Pixeez.Objects.Metadata() { Pages = pages }, CreatedTime = illust.CreateTime, ReuploadedTime = illust.UploadTime.ToString(), SanityLevel = illust.SanityLevel.ToString(), total_bookmarks = illust.BookmarkCount, total_view = illust.ViewCount, tags = tags, meta_pages = meta_pages is IEnumerable <Pixeez.Objects.MetaPages>?meta_pages.ToArray() : null, meta_single_page = new Pixeez.Objects.MetaSinglePage() { OriginalImageUrl = image_urls.Original }, }; await i.RefreshIllustBookmarkState(); i.Cache(); #endregion result = new List <Pixeez.Objects.Work>() { i }; } else { work.Message.ShowToast("GetIllustById"); } } catch (Exception ex) { ex.ERROR("SearchIllustById"); } } return(result); }