public static async Task UnFollowArtist(this PixivClient _, User user)
 {
     user.IsFollowed = false;
     await HttpClientFactory.AppApiService().UnFollowArtist(new UnFollowArtistRequest {
         UserId = user.Id
     });
 }
Ejemplo n.º 2
0
 public static async Task FollowArtist(this PixivClient _, User user, RestrictPolicy policy)
 {
     user.IsFollowed = true;
     await HttpClientFactory.AppApiService().FollowArtist(new FollowArtistRequest {
         Id = user.Id, Restrict = policy == RestrictPolicy.Private ? "private" : "public"
     });
 }
Ejemplo n.º 3
0
 public static async void PostFavoriteAsync(this PixivClient _, Illustration illustration, RestrictPolicy restrictPolicy)
 {
     illustration.IsLiked = true;
     await HttpClientFactory.AppApiService().AddBookmark(new AddBookmarkRequest {
         Id = illustration.Id, Restrict = restrictPolicy == RestrictPolicy.Public ? "public" : "private"
     });
 }
Ejemplo n.º 4
0
 public static async void RemoveFavoriteAsync(this PixivClient _, Illustration illustration)
 {
     illustration.IsLiked = false;
     await HttpClientFactory.AppApiService().DeleteBookmark(new DeleteBookmarkRequest {
         IllustId = illustration.Id
     });
 }
Ejemplo n.º 5
0
 public static async Task FollowArtist(this PixivClient _, User user)
 {
     user.IsFollowed = true;
     await HttpClientFactory.AppApiService().FollowArtist(new FollowArtistRequest {
         Id = user.Id
     });
 }
Ejemplo n.º 6
0
 public static async void PostFavoriteAsync(this PixivClient _, Illustration illustration)
 {
     illustration.IsLiked = true;
     await HttpClientFactory.AppApiService().AddBookmark(new AddBookmarkRequest {
         Id = illustration.Id
     });
 }
Ejemplo n.º 7
0
        public static async Task <IEnumerable <string> > GetArticleWorks(this PixivClient _, string spotlightId)
        {
            var httpClient = new HttpClient();
            var html       = await httpClient.GetStringAsync($"https://www.pixivision.net/en/a/{spotlightId}");

            var doc = await new HtmlParser().ParseDocumentAsync(html);

            return(doc.QuerySelectorAll(".am__body .am__work").Select(element => element.Children[1].Children[0].GetAttribute("href")).Select(url => Regex.Match(url, "https://www.pixiv.net/artworks/(?<Id>\\d+)").Groups["Id"].Value));
        }
Ejemplo n.º 8
0
        public static async Task <List <TrendingTag> > GetTrendingTags(this PixivClient _)
        {
            var result = await HttpClientFactory.AppApiService().GetTrendingTags();

            var list = new List <TrendingTag>();

            if (result is { } res)
            {
                list.AddRange(res.TrendTags.Select(tag => new TrendingTag {
                    Tag = tag.TagStr, TranslatedName = tag.TranslatedName, Thumbnail = tag.Illust.ImageUrls.SquareMedium
                }));
            }
            return(list);
        }
Ejemplo n.º 9
0
        public static async void GetTrendingTags(this PixivClient _)
        {
            var result = await HttpClientFactory.AppApiService().GetTrendingTags();

            foreach (var tag in result.TrendTags)
            {
                AppContext.TrendingTags.Add(new TrendingTag
                {
                    Tag            = tag.TagStr,
                    TranslatedName = tag.TranslatedName,
                    Thumbnail      = tag.Illust.ImageUrls.SquareMedium
                });
            }
        }
Ejemplo n.º 10
0
        public static async ValueTask <bool> ToggleWebApiR18State(this PixivClient _, bool isR18On)
        {
            try
            {
                var html = await HttpClientFactory.WebApiHttpClient().GetStringAsync("https://www.pixiv.net/setting_user.php");

                var doc = await new HtmlParser().ParseDocumentAsync(html);

                var tt = doc.QuerySelectorAll(".settingContent form input")[1].GetAttribute("value");
                await HttpClientFactory.WebApiService().ToggleR18State(new ToggleR18StateRequest {
                    R18 = isR18On ? "show" : "hide", R18G = isR18On ? "2" : "1", Tt = tt
                });

                return(true);
            }
            catch
            {
                return(false);
            }
        }