public static async Task FollowArtist(this PixivClient _, User user) { user.IsFollowed = true; await HttpClientFactory.AppApiService().FollowArtist(new FollowArtistRequest { Id = user.Id }); }
public static async Task UnFollowArtist(this PixivClient _, User user) { user.IsFollowed = false; await HttpClientFactory.AppApiService().UnFollowArtist(new UnFollowArtistRequest { UserId = user.Id }); }
public static async void RemoveFavoriteAsync(this PixivClient _, Illustration illustration) { illustration.IsLiked = false; await HttpClientFactory.AppApiService().DeleteBookmark(new DeleteBookmarkRequest { IllustId = illustration.Id }); }
/// <summary> /// おすすめのイラスト一覧を取得します。 /// </summary> /// <param name="includeRankingIllusts">ランキング上位のイラストをレスポンスに含むか</param> /// <param name="minBookmarkIdForRecentIllust">TODO</param> /// <param name="maxBookmarkIdForRecommend">TODO</param> /// <param name="offset">オフセット</param> /// <param name="filter">フィルター (`for_ios` が有効)</param> /// <returns> /// <see cref="IllustCollection" /> /// </returns> public async Task <IllustCollection> RecommendedAsync(bool includeRankingIllusts = false, long minBookmarkIdForRecentIllust = 0, long maxBookmarkIdForRecommend = 0, long offset = 0, string filter = "") { var parameters = new List <KeyValuePair <string, string> >(); if (includeRankingIllusts) { parameters.Add(new KeyValuePair <string, string>("include_ranking_illusts", "true")); } if (minBookmarkIdForRecentIllust > 0) { parameters.Add(new KeyValuePair <string, string>("min_bookmark_id_for_recent_illusts", minBookmarkIdForRecentIllust.ToString())); } if (maxBookmarkIdForRecommend > 0) { parameters.Add(new KeyValuePair <string, string>("max_bookmark_id_for_recent_illust", maxBookmarkIdForRecommend.ToString())); } if (offset > 0) { parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString())); } if (!string.IsNullOrWhiteSpace(filter)) { parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString())); } return(await PixivClient.GetAsync <IllustCollection>("https://app-api.pixiv.net/v1/illust/recommended", parameters).Stay()); }
public async void Download() { var result = await Tasks <string, Illustration> .Of(await PixivClient.GetArticleWorks(Id.ToString())).Mapping(async i => { var res = await PixivHelper.IllustrationInfo(i); if (res == null) { return(null); } res.SpotlightTitle = Title; res.SpotlightArticleId = Id.ToString(); res.FromSpotlight = true; res.MangaMetadata?.Peek(m => { m.FromSpotlight = true; m.SpotlightTitle = Title; m.SpotlightArticleId = Id.ToString(); }); return(res); }).Construct().WhenAll(); foreach (var illustration in result.Where(i => i != null)) { DownloadManager.EnqueueDownloadItem(illustration); } }
public static async void PostFavoriteAsync(this PixivClient _, Illustration illustration) { illustration.IsLiked = true; await HttpClientFactory.AppApiService().AddBookmark(new AddBookmarkRequest { Id = illustration.Id }); }
/// <summary> /// 指定された条件に従って小説の検索を行います。 /// </summary> /// <param name="word">検索ワード</param> /// <param name="searchTarget">検索対象</param> /// <param name="sort">ソート順</param> /// <param name="startDate">開始日時 (YYYY-MM-DD)</param> /// <param name="endDate">終了日時 (YYYY-MM-DD)</param> /// <param name="bookmarkNumMin">最小ブックマーク数</param> /// <param name="offset">オフセット</param> /// <returns> /// <see cref="NovelCollection" /> /// </returns> public async Task <NovelCollection> NovelAsync(string word, SearchTarget searchTarget, SortOrder sort, string startDate = "", string endDate = "", int bookmarkNumMin = 0, long offset = 0) { Ensure.NotNullOrWhitespace(word, nameof(word)); Ensure.InvalidEnumValue(searchTarget == SearchTarget.Keyword, nameof(searchTarget)); Ensure.InvalidEnumValue(searchTarget == SearchTarget.Text, nameof(searchTarget)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("word", word), new KeyValuePair <string, string>("search_target", searchTarget.ToParameter()), new KeyValuePair <string, string>("sort", sort.ToParameter()) }; if (!string.IsNullOrWhiteSpace(startDate)) { parameters.Add(new KeyValuePair <string, string>("start_date", startDate)); } if (!string.IsNullOrWhiteSpace(endDate)) { parameters.Add(new KeyValuePair <string, string>("end_date", endDate)); } if (bookmarkNumMin > 0) { parameters.Add(new KeyValuePair <string, string>("bookmark_num_min", bookmarkNumMin.ToString())); } if (offset > 0) { parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString())); } return(await PixivClient.GetAsync <NovelCollection>("https://app-api.pixiv.net/v1/search/novel", parameters).Stay()); }
/// <summary> /// TODO /// </summary> /// <param name="word">検索する単語</param> /// <param name="sort">ソート順</param> /// <param name="searchTarget">検索対象</param> /// <param name="bookmarkMinNum">TODO</param> /// <param name="startDate">開始日時</param> /// <param name="endDate">終了日時</param> /// <param name="filter">フィルター (`for_ios` が有効)</param> /// <returns> /// <see cref="IEnumerable{BookmarkRange}" /> /// </returns> public async Task <IEnumerable <BookmarkRange> > NovelAsync(string word, SortOrder sort, SearchTarget searchTarget, string bookmarkMinNum = "", string startDate = "", string endDate = "", string filter = "") { Ensure.NotNullOrWhitespace(word, nameof(word)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("word", word), new KeyValuePair <string, string>("sort", sort.ToParameter()), new KeyValuePair <string, string>("search_target", searchTarget.ToParameter()) }; if (!string.IsNullOrWhiteSpace(bookmarkMinNum)) { parameters.Add(new KeyValuePair <string, string>("bookmark_min_num", bookmarkMinNum)); } if (!string.IsNullOrWhiteSpace(startDate)) { parameters.Add(new KeyValuePair <string, string>("start_date", startDate)); } if (!string.IsNullOrWhiteSpace(endDate)) { parameters.Add(new KeyValuePair <string, string>("end_date", endDate)); } if (!string.IsNullOrWhiteSpace(filter)) { parameters.Add(new KeyValuePair <string, string>("filter", filter)); } var response = await PixivClient.GetAsync("https://app-api.pixiv.net/v1/search/bookmark-ranges/novel", parameters).Stay(); return(response["bookmark_ranges"].ToObject <IEnumerable <BookmarkRange> >()); }
/// <inheritdoc /> internal FileClient(PixivClient pixivClient) : base(pixivClient) { _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Add("App-OS-Version", PixivClient.OsVersion); _httpClient.DefaultRequestHeaders.Add("App-OS", "ios"); _httpClient.DefaultRequestHeaders.Add("App-Version", PixivClient.AppVersion); _httpClient.DefaultRequestHeaders.Add("User-Agent", $"PixivIOSApp/{PixivClient.AppVersion} (iOS {PixivClient.OsVersion}; iPhone7,2)"); _httpClient.DefaultRequestHeaders.Referrer = new Uri("https://app-api.pixiv.net/"); }
/// <summary> /// 指定したユーザーのフォローを解除します。 /// </summary> /// <param name="userId">ユーザー ID</param> public async Task DeleteAsync(long userId) { Ensure.GreaterThanZero(userId, nameof(userId)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("user_id", userId.ToString()) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/user/follow/delete", parameters); }
/// <summary> /// 指定したイラスト ID を閲覧履歴へと追加します。 /// </summary> /// <param name="illustIds">イラスト ID</param> public async Task AddAsync(long[] illustIds) { Ensure.ArraySizeNotZero(illustIds, nameof(illustIds)); var parameters = new List <KeyValuePair <string, string> >(); parameters.AddRange(parameters.Select(w => new KeyValuePair <string, string>("illust_ids[]", w.ToString()))); await PixivClient.PostAsync("https://app-api.pixiv.net/v2/user/browsing-history/illust/add", parameters).Stay(); }
internal UserInfo(PixivClient client, UserSummary api) { Client = client; Id = api.Id; Name = api.Name; Account = api.Account; IsFollowed = api.IsFollowed; Comment = api.Comment; _avatarUri = api.ProfileImageUrls.Medium; }
/// <inheritdoc /> internal UserClient(PixivClient pixivClient) : base(pixivClient) { Bookmarks = new BookmarksClient(pixivClient); BookmarkTags = new BookmarkTagsClient(pixivClient); BrowsingHistory = new BrowsingHistoryClient(pixivClient); Me = new MeClient(pixivClient); Profile = new ProfileClient(pixivClient); Workspace = new WorkspaceClient(pixivClient); Follow = new FollowClient(pixivClient); }
/// <summary> /// 指定した公開制限のブックマークで、小説に対して付けたタグのリストを取得します。 /// </summary> /// <param name="restrict"> /// 公開制限 /// </param> /// <returns> /// <see cref="BookmarkTagCollection" /> /// </returns> public async Task <BookmarkTagCollection> NovelAsync(Restrict restrict = Restrict.Public) { Ensure.InvalidEnumValue(restrict == Restrict.All, nameof(restrict)); Ensure.InvalidEnumValue(restrict == Restrict.Mypixiv, nameof(restrict)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("restrict", restrict.ToParameter()) }; return(await PixivClient.GetAsync <BookmarkTagCollection>("https://app-api.pixiv.net/v1/user/bookmark-tags/novel", parameters).Stay()); }
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)); }
/// <summary> /// マイピクユーザーの新着イラストを取得します。 /// </summary> /// <param name="offset">オフセット</param> /// <returns> /// <see cref="IllustCollection" /> /// </returns> public async Task <IllustCollection> MypixivAsync(long offset = 0) { var parameters = new List <KeyValuePair <string, string> >(); if (offset > 0) { parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString())); } return(await PixivClient.GetAsync <IllustCollection>("https://app-api.pixiv.net/v2/illust/mypixiv", parameters).Stay()); }
/// <summary> /// 全ユーザーの投稿した新着小説を取得します。 /// </summary> /// <param name="maxNovelId">最大小説 ID</param> /// <returns> /// <see cref="NovelCollection" /> /// </returns> public async Task <NovelCollection> NewAsync(long maxNovelId = 0) { var parameters = new List <KeyValuePair <string, string> >(); if (maxNovelId > 0) { parameters.Add(new KeyValuePair <string, string>("max_novel_id", maxNovelId.ToString())); } return(await PixivClient.GetAsync <NovelCollection>("https://app-api.pixiv.net/v1/novel/new", parameters).Stay()); }
/// <summary> /// 小説の本文情報を取得します。 /// </summary> /// <param name="novelId">小説 ID</param> /// <returns> /// <see cref="NovelText" /> /// </returns> public async Task <NovelText> TextAsync(long novelId) { Ensure.GreaterThanZero(novelId, nameof(novelId)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("novel_id", novelId.ToString()) }; return(await PixivClient.GetAsync <NovelText>("https://app-api.pixiv.net/v1/novel/text", parameters).Stay()); }
internal LoginUser(PixivClient client, AuthUser api) { Id = int.Parse(api.Id, NumberFormatInfo.InvariantInfo); Name = api.Name; Account = api.Account; MailAddress = api.MailAddress; IsPremium = api.IsPremium; IsR18Enabled = api.XRestrict > 0; _avatarUri = api.ProfileImageUrls.PixelSize170; _client = client; }
internal IllustPage(Illust illust, int index, PixivClient client, PreviewImageUrls urls, Uri original) { Illust = illust; Index = index; _client = client; _original = original; _medium = urls.Medium; _squareMedium = urls.SquareMedium; _large = urls.Large; }
/// <summary> /// 指定したタグのミュートを解除します。 /// </summary> /// <param name="tags">タグ名</param> public async Task DeleteAsync(string[] tags) { Ensure.ArraySizeNotZero(tags, nameof(tags)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("delete_tags[]", string.Join(",", tags)) }; await PixivClient.PostAsync("https://app-api.pixiv.net/v1/mute/edit", parameters).Stay(); }
internal IllustPage(Illust illust, int index, PixivClient client, MetaPageImageUrls urls) { Illust = illust; Index = index; _client = client; _original = urls.Original; _medium = urls.Medium; _squareMedium = urls.SquareMedium; _large = urls.Large; }
public DownloaderService( ICustomResolver <PixivClient> pixivClientResolver, IDbContextFactoryResolver <EHunterDbContext> eHunterContextResolver, IDbContextFactoryResolver <PixivDbContext> pixivDbContextResolver, IStorageSetting storageSetting) { _client = pixivClientResolver.Resolve(); _eHunterContextResolver = eHunterContextResolver; _pixivDbContextResolver = pixivDbContextResolver; _storageSetting = storageSetting; }
internal IllustSeries(PixivClient client, IllustSeriesDetails api) { _client = client; Id = api.Id; Name = api.Title; Description = api.Caption; _coverUri = api.CoverImageUrls.Medium; Created = api.CreateDate; WorksCount = api.SeriesWorkCount; Height = api.Height; Width = api.Width; }
/// <summary> /// オートコンプリートようの文字列一覧を取得します。 /// </summary> /// <param name="word">キーワード</param> /// <returns> /// <see cref="IEnumerable{String}" /> /// </returns> public async Task <IEnumerable <string> > AutocompleteAsync(string word) { Ensure.NotNullOrWhitespace(word, nameof(word)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("word", word) }; var response = await PixivClient.GetAsync("https://app-api.pixiv.net/v1/search/autocomplete", parameters).Stay(); return(response["search_auto_complete_keywords"].ToObject <IEnumerable <string> >()); }
/// <summary> /// 指定したイラストに対してのブックマーク情報を取得します。 /// </summary> /// <param name="illustId">イラスト ID</param> /// <returns> /// <see cref="BookmarkDetail" /> /// </returns> public async Task <BookmarkDetail> DetailAsync(long illustId) { Ensure.GreaterThanZero(illustId, nameof(illustId)); var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("illust_id", illustId.ToString()) }; var response = await PixivClient.GetAsync("https://app-api.pixiv.net/v2/illust/bookmark/detail", parameters).Stay(); return(response["bookmark_detail"].ToObject <BookmarkDetail>()); }
/// <summary> /// 小説のトレンドタグ一覧を取得します。 /// </summary> /// <param name="filter">フィルター (`for_ios` が有効)</param> /// <returns> /// <see cref="IEnumerable{TrendingTag}" /> /// </returns> public async Task <IEnumerable <TrendingTag> > NovelAsync(string filter = "") { var parameters = new List <KeyValuePair <string, string> >(); if (!string.IsNullOrWhiteSpace(filter)) { parameters.Add(new KeyValuePair <string, string>("filter", filter)); } var response = await PixivClient.GetAsync("https://app-api.pixiv.net/v1/trending-tags/novel", parameters).Stay(); return(response["trending_tags"].ToObject <IEnumerable <TrendingTag> >()); }
/// <summary> /// 生放送の一覧を取得します。 /// </summary> /// <param name="type">取得する配信情報</param> /// <param name="offset">オフセット</param> /// <returns> /// <see cref="LiveCollection" /> /// </returns> public async Task <LiveCollection> ListAsync(ListType type, long offset = 0) { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("list_type", type.ToParameter()) }; if (offset > 0) { parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString())); } return(await PixivClient.GetAsync <LiveCollection>("https://app-api.pixiv.net/v1/live/list", parameters).Stay()); }
[Command("emotes"), Description("lists all customs server emotes")] //same as if u just type emotes, public async Task Emotes(CommandContext ctx) { var pixivClient = new PixivClient("CLIENT_ID", "CLIENT_SECRET"); var imgs = await pixivClient.Search.IllustAsync("kagamine", Sagitta.Enum.SearchTarget.PartialMatchForTags, Sagitta.Enum.SortOrder.PopularDesc); var img = imgs.Illusts.First().ImageUrls.Original; string emotelist = ""; foreach (var emotes in ctx.Guild.Emojis) { emotelist += emotes; } await ctx.RespondAsync(emotelist); }
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 }); } }