public void Initialize()
        {
            var sort = new SearchResultSort(x => x.NutritionFact_Calories, SortOrder.Descending);

            Assert.AreEqual("nf_calories", sort.Field);
            Assert.AreEqual("desc", sort.Order);
        }
        public void Initialize()
        {
            var sort = new SearchResultSort(x => x.NutritionFact_Calories, SortOrder.Descending);

            Assert.AreEqual("nf_calories", sort.Field);
            Assert.AreEqual("desc", sort.Order);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert SearchResultSort value to its URL parameter name
        /// </summary>
        /// <param name="sort">Value to convert</param>
        /// <returns>Converted name in <code>System.String</code></returns>
        public static string ToQueryParameterName(this SearchResultSort sort)
        {
            switch (sort)
            {
            case SearchResultSort.Title:
                return("title");

            case SearchResultSort.Year:
                return("year");

            case SearchResultSort.Rating:
                return("rating");

            case SearchResultSort.Peers:
                return("peers");

            case SearchResultSort.Seeds:
                return("seeds");

            case SearchResultSort.DownloadedCount:
                return("downloaded_count");

            case SearchResultSort.LikeCount:
                return("like_count");

            case SearchResultSort.DateAdded:
                return("date_added");

            default:
                throw new ArgumentException("Cannot find the sort specified");
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Search or list movies in YTS
 /// </summary>
 /// <param name="queryTerm">Term to search</param>
 /// <param name="quality">Quality of the release Ex: 720p, 1080p, 3D</param>
 /// <param name="genre">Genre of the movie (See http://www.imdb.com/genre/ for full list)</param>
 /// <param name="minimumRating">Minimum rating of the movie. Ex: 0 to 9</param>
 /// <param name="limit">The limit of results per page. Ex: 20</param>
 /// <param name="page">Page number to view the movies Ex: Limit 15 and Page 2 will show you movies 15 to 30</param>
 /// <param name="sortBy">Sorts the results by chosen field</param>
 /// <param name="orderBy">Order of the results in Ascending or Descending order</param>
 /// <returns>Collection of ListMovie class objects</returns>
 /// <exception cref="YifyLib.YifyException">If any errors occurred YTS process</exception>
 public List <ListMovie> ListMovies(
     string queryTerm        = "",
     string quality          = "All",
     string genre            = "",
     uint minimumRating      = 0,
     uint limit              = 20,
     uint page               = 1,
     SearchResultSort sortBy = SearchResultSort.DateAdded,
     SortOrder orderBy       = SortOrder.Desc)
 {
     try
     {
         var uri = YifyAPI.GetListMovieURI(queryTerm, quality, genre, minimumRating, limit, page, sortBy, orderBy);
         var res = YifyAPI.SendGetRequest(uri);
         return(_parser.ParseListMovieResponse(res));
     }
     catch (Exception ex)
     {
         throw new YifyException("An error occurred. See inner exception for more details", ex);
     }
 }
Ejemplo n.º 5
0
        public static Uri GetListMovieURI(string queryTerm        = "",
                                          string quality          = "All",
                                          string genre            = "",
                                          uint minimumRating      = 0,
                                          uint limit              = 20,
                                          uint page               = 1,
                                          SearchResultSort sortBy = SearchResultSort.DateAdded,
                                          SortOrder orderBy       = SortOrder.Desc)
        {
            UriBuilderWithQuerySupport u = new UriBuilderWithQuerySupport(RequestUriHelper.ListMovies.ToRequestUri(Base_URI, RESPONSE_TYPE));

            u.AddQueryParameter("query_term", queryTerm.CheckString(""), true);
            u.AddQueryParameter("quality", quality.CheckString("All"), true);
            u.AddQueryParameter("genre", genre.CheckString(""), true);
            u.AddQueryParameter("minimum_rating", minimumRating.CheckMax(9, 0).ToString(), true);
            u.AddQueryParameter("limit", limit.CheckMax(50, 20).ToString(), true);
            u.AddQueryParameter("page", page.ToString(), true);
            u.AddQueryParameter("sort_by", sortBy.ToQueryParameterName(), true);
            u.AddQueryParameter("order_by", orderBy.ToString().ToLower(), true);

            return(u.Uri);
        }
Ejemplo n.º 6
0
 // --------------------------------------------------------------------
 // 検索結果のソート
 // --------------------------------------------------------------------
 private static IQueryable <AvailableSong> SortSearchResult(IQueryable <AvailableSong> result, SearchResultSort sort)
 {
     return(sort switch
     {
         SearchResultSort.SongName => result.OrderBy(x => x.SongName),
         SearchResultSort.ArtistName => result.OrderBy(x => x.ArtistName),
         SearchResultSort.FileSize => result.OrderByDescending(x => x.FileSize),
         _ => result.OrderByDescending(x => x.LastModified),
     });