Exemple #1
0
 private void MovieBrowseWorker(TmdbOrderBy orderBy, TmdbOrder order, int perPage = 0, int page = 0, string query = ""
     , int minVotes = 0, float ratingMin = 0, float ratingMax = 0, IEnumerable<int> genres = null, GenresSelector? genresSelector = null,
     DateTime? releaseMin = null, DateTime? releaseMax = null, int year = 0, IEnumerable<string> certifications = null
     , IEnumerable<string> companies = null, IEnumerable<string> countries = null, object userState = null, AsyncOperation asyncOp = null)
 {
     Exception exception = null;
     IEnumerable<TmdbMovie> movies = null;
     try
     {
         movies = MovieBrowse(orderBy, order, perPage, page, query, minVotes, ratingMin, ratingMax, genres, genresSelector, releaseMin, releaseMax, year, certifications, companies, countries);
     }
     catch (Exception ex)
     {
         exception = ex;
     }
     var args = new TmdbMovieSearchCompletedEventArgs(movies, exception, false, userState);
     asyncOp.PostOperationCompleted(
         e => OnMovieBrowseCompleted((TmdbMovieSearchCompletedEventArgs)e),
         args);
 }
Exemple #2
0
 public void MovieBrowseAsync(TmdbOrderBy orderBy, TmdbOrder order, int perPage = 0, int page = 0, string query = ""
     , int minVotes = 0, float ratingMin = 0, float ratingMax = 0, IEnumerable<int> genres = null, GenresSelector? genresSelector = null,
     DateTime? releaseMin = null, DateTime? releaseMax = null, int year = 0, IEnumerable<string> certifications = null
     , IEnumerable<string> companies = null, IEnumerable<string> countries = null)
 {
     MovieBrowseAsync(orderBy, order,perPage,page,query,minVotes,ratingMin,ratingMax,genres,genresSelector,releaseMin,releaseMax,year,certifications,companies,countries, null);
 }
Exemple #3
0
 public void MovieBrowseAsync(TmdbOrderBy orderBy, TmdbOrder order, int perPage = 0, int page = 0, string query = ""
     , int minVotes = 0, float ratingMin = 0, float ratingMax = 0, IEnumerable<int> genres = null, GenresSelector? genresSelector = null,
     DateTime? releaseMin = null, DateTime? releaseMax = null, int year = 0, IEnumerable<string> certifications = null
     , IEnumerable<string> companies = null, IEnumerable<string> countries = null, object userState = null)
 {
     var asyncOp = AsyncOperationManager.CreateOperation(null);
     var worker = new MovieBrowseDelegate(MovieBrowseWorker);
     worker.BeginInvoke(orderBy, order, perPage, page, query, minVotes, ratingMin, ratingMax, genres, genresSelector, releaseMin, releaseMax, year, certifications, companies, countries, userState, asyncOp, null, null);
 }
Exemple #4
0
        /// <summary>
        /// The Movie.browse method is probably the most powerful single method on the entire TMDb API. 
        /// While it might not be used by all apps, it is a great place to start if you're interested in 
        /// building any kind of a top 10 list.
        /// Some examples include getting a list of the top 'drama' movies, or maybe the top science 
        /// fiction movies released since 2000. These are fairly simple examples as you can also add 
        /// any number of extra attributes to your search. These are all passed as URL query parameters 
        /// and are outlined below.
        /// </summary>
        /// <param name="orderBy"></param>
        /// <param name="order"></param>
        /// <param name="perPage">This value sets the number of results to display per page (or request). Without it, the default is 30 results. 'page' is required if you're using per_page.</param>
        /// <param name="page">Results are paginated if you use the page & per_page parameters. You can quickly scan through multiple pages with these options.</param>
        /// <param name="query">The search query parameter is used to search for some specific text from a title</param>
        /// <param name="minVotes">Only return movies with a certain minimum number of votes.</param>
        /// <param name="ratingMin">If you'd only like to see movies with a certain minimum rating, use this. If used, ratingMax is required.</param>
        /// <param name="ratingMax">Used in conjunction with ratingMin. Sets the upper limit of movies to return based on their rating.</param>
        /// <param name="genres">The genres parameter is to be passed the genres id(s) you want to search for. You can get these ids from the Genres.getList method.</param>
        /// <param name="genresSelector">Used when you search for more than 1 genre and useful to combine your genre searches.</param>
        /// <param name="releaseMin">Useful if you'd like to only search for movies from a particular date and on. If used, releaseMax is required.</param>
        /// <param name="releaseMax">Sets the upper date limit to search for. If used, releaseMin is required.</param>
        /// <param name="year">If you'd only like to search for movies from a particular year, this if your option.</param>
        /// <param name="certifications">The values to be used here are the MPAA values like 'R' or 'PG-13'. When more than one value is passed, it is assumed to be an OR search.</param>
        /// <param name="companies">Useful if you'd like to find the movies from a particular studio. When more than one id is passed, it is assumed to be an OR search.</param>
        /// <param name="countries">If you'd like to limit your result set to movies from a particular country you can pass their 2 letter country code. When more than one id is passed, it is assumed to be an OR search.</param>
        /// <returns></returns>
        public IEnumerable<TmdbMovie> MovieBrowse(TmdbOrderBy orderBy, TmdbOrder order, int perPage = 0, int page = 0, string query = ""
            , int minVotes = 0, float ratingMin = 0, float ratingMax = 0, IEnumerable<int> genres = null, GenresSelector? genresSelector = null,
            DateTime? releaseMin = null, DateTime? releaseMax = null, int year = 0, IEnumerable<string> certifications = null
            , IEnumerable<string> companies = null, IEnumerable<string> countries = null)
        {
            var nvc = new NameValueCollection();
            nvc["order_by"] = orderBy.ToString().ToLower();
            nvc["order"] = order.ToString().ToLower();

            if(perPage > 0 && page > 0)
                nvc["per_page"] = perPage.ToString();
            if(page > 0)
                nvc["page"] = page.ToString();

            if(!string.IsNullOrEmpty(query))
                nvc["query"] = query;

            if (minVotes > 0)
                nvc["min_votes"] = minVotes.ToString();

            if (ratingMin > 0 && ratingMax > 0)
            {
                nvc["rating_min"] = ratingMin.ToString();
                nvc["rating_max"] = ratingMax.ToString();
            }

            if(genres != null)
                nvc["genres"] = string.Join(",",genres);

            if (genresSelector.HasValue)
                nvc["genres_selector"] = genresSelector.ToString().ToLower();

            if(releaseMax.HasValue && releaseMin.HasValue)
            {
                var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                nvc["release_min"] = releaseMin.Value.AddTicks(-epoch.Ticks).Ticks.ToString();
                nvc["release_max"] = releaseMax.Value.AddTicks(-epoch.Ticks).Ticks.ToString();
            }

            if (year > 0)
                nvc["year"] = year.ToString();

            if (certifications != null)
                nvc["certifications"] = string.Join(",", certifications);

            if (companies != null)
                nvc["companies"] = string.Join(",", companies);

            if (countries != null)
                nvc["countries"] = string.Join(",", countries);

            var searchQuery = string.Join("&", nvc.AllKeys.Select(k => string.Format("{0}={1}", k, HttpUtility.UrlEncode(nvc[k]))));
            var movies = DownloadData(string.Format(MovieBrowseUrl, ApiKey, Language, searchQuery), typeof(TmdbMovies)) as TmdbMovies;
            return movies;
        }