示例#1
0
        /// <summary>
        ///     <see cref="IllustType" /> を URL クエリパラメータに変換します。
        /// </summary>
        /// <param name="obj">
        ///     <see cref="IllustType" />
        /// </param>
        /// <returns>変換後文字列</returns>
        public static string ToParameter(this IllustType obj)
        {
            switch (obj)
            {
            case IllustType.Illust:
                return("illust");

            case IllustType.Manga:
                return("manga");

            case IllustType.Ugoira:
                return("ugoira");

            default:
                throw new ArgumentOutOfRangeException(nameof(obj), obj, null);
            }
        }
示例#2
0
        /// <summary>
        ///     新着イラストを取得します。
        /// </summary>
        /// <param name="contentType">イラストの種類</param>
        /// <param name="maxIllustId">最大イラスト ID</param>
        /// <param name="filter">フィルター (`for_ios` が有効)</param>
        /// <returns>
        ///     <see cref="IllustCollection" />
        /// </returns>
        public async Task <IllustCollection> NewAsync(IllustType contentType, long maxIllustId = 0, string filter = "")
        {
            Ensure.InvalidEnumValue(contentType == IllustType.Ugoira, nameof(contentType));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("content_type", contentType.ToParameter())
            };

            if (maxIllustId > 0)
            {
                parameters.Add(new KeyValuePair <string, string>("max_illust_id", maxIllustId.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(filter))
            {
                parameters.Add(new KeyValuePair <string, string>("filter", filter));
            }

            return(await PixivClient.GetAsync <IllustCollection>("https://app-api.pixiv.net/v1/illust/new", parameters).Stay());
        }
示例#3
0
        /// <summary>
        /// Gets a list of illusts by the specified user.
        /// </summary>
        /// <param name="UserID">The ID of the user to view illusts of.</param>
        /// <param name="type">The type of illusts to view. Can be: 'illust' or 'manga'</param>
        /// <param name="filter"></param>
        /// <returns><seealso cref="IllustSearchResult"/></returns>
        public async Task <IllustSearchResult> UserIllustsAsync(string UserID, IllustType type, FilterType filter = FilterType.None)
        {
            Stream response;
            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                { "user_id", UserID },
                { "type", type.JsonValue() },
            };

            // Adds filter if required
            if ((filter.JsonValue() ?? Filter.JsonValue()) != null)
            {
                parameters.Add("filter", filter.JsonValue() ?? Filter.JsonValue());
            }

            FormUrlEncodedContent encodedParams = new FormUrlEncodedContent(parameters);

            response = await RequestClient.RequestAsync(PixivUrls.ProfileIllusts, encodedParams).ConfigureAwait(false);

            return(Json.DeserializeJson <IllustSearchResult>(response));
        }
示例#4
0
        /// <summary>
        ///     指定したユーザーが投稿したイラスト・マンガを取得します。
        /// </summary>
        /// <param name="userId">ユーザー ID</param>
        /// <param name="type">イラストもしくはマンガ</param>
        /// <param name="offset">オフセット</param>
        /// <param name="filter">フィルター (`for_ios` が有効)</param>
        /// <returns>
        ///     <see cref="IllustCollection" />
        /// </returns>
        public async Task <IllustCollection> IllustsAsync(long userId, IllustType type, long offset = 0, string filter = "")
        {
            Ensure.GreaterThanZero(userId, nameof(userId));
            Ensure.InvalidEnumValue(type == IllustType.Ugoira, nameof(type));

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("user_id", userId.ToString()),
                new KeyValuePair <string, string>("type", type.ToParameter())
            };

            if (offset > 0)
            {
                parameters.Add(new KeyValuePair <string, string>("offset", offset.ToString()));
            }
            if (!string.IsNullOrWhiteSpace(filter))
            {
                parameters.Add(new KeyValuePair <string, string>("filter", filter));
            }

            return(await PixivClient.GetAsync <IllustCollection>("https://app-api.pixiv.net/v1/user/illusts", parameters).Stay());
        }