示例#1
0
        /// <summary>
        /// List the photos with the most views, comments or favorites.
        /// </summary>
        /// <param name="date">Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will automatically be rounded down to the start of the day. If no date is provided, all time view counts will be returned.</param>
        /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
        /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
        /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
        public PopularPhotoCollection StatsGetPopularPhotos(DateTime date, PopularitySort sort, int page, int perPage)
        {
            CheckRequiresAuthentication();

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.stats.getPopularPhotos");
            if (date != DateTime.MinValue)
            {
                parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            }
            if (sort != PopularitySort.None)
            {
                parameters.Add("sort", UtilityMethods.SortOrderToString(sort));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            return(GetResponseCache <PopularPhotoCollection>(parameters));
        }
示例#2
0
        /// <summary>
        /// List the photos with the most views, comments or favorites.
        /// </summary>
        /// <param name="date">Stats will be returned for this date.
        /// A day according to Flickr Stats starts at midnight GMT for all users,
        /// and timestamps will automatically be rounded down to the start of the day.
        /// If no date is provided, all time view counts will be returned.</param>
        /// <param name="sort">The order in which to sort returned photos.
        /// Defaults to views. The possible values are views, comments and favorites. </param>
        /// <param name="page">The page of results to return.
        /// If this argument is omitted, it defaults to 1.</param>
        /// <param name="perPage">Number of photos to return per page.
        /// If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void StatsGetPopularPhotosAsync(DateTime date, PopularitySort sort, int page, int perPage,
                                               Action <TwentyThreeResult <PopularPhotoCollection> > callback)
        {
            CheckRequiresAuthentication();

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.stats.getPopularPhotos");
            if (date != DateTime.MinValue)
            {
                parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            }
            if (sort != PopularitySort.None)
            {
                parameters.Add("sort", UtilityMethods.SortOrderToString(sort));
            }
            if (page > 0)
            {
                parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (perPage > 0)
            {
                parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }

            GetResponseAsync <PopularPhotoCollection>(parameters, callback);
        }
示例#3
0
        private static string GetSortInfo(PopularitySort sortOption)
        {
            switch (sortOption)
            {
            case PopularitySort.Today: return("&sort=popular-today");

            case PopularitySort.Week: return("&sort=popular-week");

            case PopularitySort.AllTime: return("&sort=popular");

            default: return("");
            }
        }
示例#4
0
        /// <summary>
        /// Converts a <see cref="PopularitySort"/> enum to a string.
        /// </summary>
        /// <param name="sortOrder">The value to convert.</param>
        /// <returns></returns>
        public static string SortOrderToString(PopularitySort sortOrder)
        {
            switch (sortOrder)
            {
            case PopularitySort.Comments:
                return("comments");

            case PopularitySort.Favorites:
                return("favorites");

            case PopularitySort.Views:
                return("views");

            default:
                return(String.Empty);
            }
        }
示例#5
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos.
 /// Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return.
 /// If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page.
 /// If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public void StatsGetPopularPhotosAsync(PopularitySort sort, int page, int perPage, Action <TwentyThreeResult <PopularPhotoCollection> > callback)
 {
     StatsGetPopularPhotosAsync(DateTime.MinValue, sort, page, perPage, callback);
 }
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort, int page, int perPage)
 {
     return StatsGetPopularPhotos(null, sort, page, perPage);
 }
 public PopularPhotoCollection StatsGetPopularPhotos(DateTime date, PopularitySort sort, int page, int perPage);
        /// <summary>
        /// List the photos with the most views, comments or favorites.
        /// </summary>
        /// <param name="date">Stats will be returned for this date. A day according to Flickr Stats starts at midnight GMT for all users, and timestamps will automatically be rounded down to the start of the day. If no date is provided, all time view counts will be returned.</param>
        /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
        /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
        /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void StatsGetPopularPhotosAsync(DateTime date, PopularitySort sort, int page, int perPage, Action<FlickrResult<PopularPhotoCollection>> callback)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.stats.getPopularPhotos");
            if (date != DateTime.MinValue) parameters.Add("date", UtilityMethods.DateToUnixTimestamp(date));
            if (sort != PopularitySort.None) parameters.Add("sort", UtilityMethods.SortOrderToString(sort));
            if (page > 0) parameters.Add("page", page.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            if (perPage > 0) parameters.Add("per_page", perPage.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));

            GetResponseAsync<PopularPhotoCollection>(parameters, callback);
        }
示例#9
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort)
 {
     return StatsGetPopularPhotos(DateTime.MinValue, sort, 0, 0);
 }
示例#10
0
        public static async Task <Search.SearchResult> SearchWithTagsAsync(string[] tags, int page, PopularitySort sortOption = PopularitySort.None)
        {
            string allTags = Uri.EscapeDataString(string.Join(" ", tags));

            if (string.IsNullOrEmpty(allTags))
            {
                throw new Exception.EmptySearchException();
            }
            using (HttpClient hc = new HttpClient())
                return(new Search.SearchResult(JsonConvert.DeserializeObject(await(await hc.GetAsync("https://nhentai.net/api/galleries/search?query=" + allTags + "&page=" + page + GetSortInfo(sortOption))).Content.ReadAsStringAsync())));
        }
示例#11
0
 /// <summary>
 /// Search with a specific tag id
 /// </summary>
 public static async Task <Search.SearchResult> SearchByTagIdAsync(int id, int page = 1, PopularitySort sortOption = PopularitySort.None)
 {
     using (HttpClient hc = new HttpClient())
         return(new Search.SearchResult(JsonConvert.DeserializeObject(await(await hc.GetAsync("https://nhentai.net/api/galleries/tagged?tag_id=" + id + "&page=" + page + GetSortInfo(sortOption))).Content.ReadAsStringAsync())));
 }
示例#12
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public async Task<FlickrResult<PopularPhotoCollection>> StatsGetPopularPhotosAsync(PopularitySort sort, int page, int perPage)
 {
     return await StatsGetPopularPhotosAsync(DateTime.MinValue, sort, page, perPage);
 }
示例#13
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos.
 /// Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public void StatsGetPopularPhotosAsync(PopularitySort sort, Action <FlickrResult <PopularPhotoCollection> > callback)
 {
     StatsGetPopularPhotosAsync(DateTime.MinValue, sort, 0, 0, callback);
 }
示例#14
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public async Task <FlickrResult <PopularPhotoCollection> > StatsGetPopularPhotosAsync(PopularitySort sort, int page, int perPage)
 {
     return(await StatsGetPopularPhotosAsync(DateTime.MinValue, sort, page, perPage));
 }
示例#15
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort)
 {
     return(StatsGetPopularPhotos(DateTime.MinValue, sort, 0, 0));
 }
示例#16
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort, int page, int perPage)
 {
     return StatsGetPopularPhotos(DateTime.MinValue, sort, page, perPage);
 }
示例#17
0
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <returns>A list of <see cref="PopularPhoto"/> instances.</returns>
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort, int page, int perPage)
 {
     return(StatsGetPopularPhotos(DateTime.MinValue, sort, page, perPage));
 }
 public PopularPhotoCollection StatsGetPopularPhotos(DateTime? date, PopularitySort sort, int page, int perPage)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.stats.getPopularPhotos");
     if (date != null) dictionary.Add("date", date.Value.ToUnixTimestamp());
     if (sort != PopularitySort.None) dictionary.Add("sort", sort.ToString().ToLower());
     if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
     if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
     return GetResponse<PopularPhotoCollection>(dictionary);
 }
 /// <summary>
 /// List the photos with the most views, comments or favorites.
 /// </summary>
 /// <param name="sort">The order in which to sort returned photos. Defaults to views. The possible values are views, comments and favorites. </param>
 /// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
 /// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 25. The maximum allowed value is 100.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public void StatsGetPopularPhotosAsync(PopularitySort sort, int page, int perPage, Action<FlickrResult<PopularPhotoCollection>> callback)
 {
     StatsGetPopularPhotosAsync(DateTime.MinValue, sort, page, perPage, callback);
 }
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort)
 {
     return StatsGetPopularPhotos(null, sort, 0, 0);
 }
示例#21
0
 /// <summary>
 /// Converts a <see cref="PopularitySort"/> enum to a string.
 /// </summary>
 /// <param name="sortOrder">The value to convert.</param>
 /// <returns></returns>
 public static string SortOrderToString(PopularitySort sortOrder)
 {
     switch (sortOrder)
     {
         case PopularitySort.Comments:
             return "comments";
         case PopularitySort.Favorites:
             return "favorites";
         case PopularitySort.Views:
             return "views";
         default:
             return String.Empty;
     }
 }
 public PopularPhotoCollection StatsGetPopularPhotos(PopularitySort sort);