Skip to content

Discover

George Kye edited this page Apr 8, 2016 · 8 revisions

Discover methods have been split into three different classes and multiple functions . Discover , DiscoverTV and DiscoverMovie .

Methods in the Discover class can be used to discover either tv shows or movies. Here are some examples.

       //Basic discover query
        DiscoverMDB.discover(apikey, discoverType: "tv", language: nil){
            apiReturn in
            let tvshows = apiReturn.MBDBReturn as! [TVMDB]
            print(tvshows[0].name)
            print(tvshows[0].overview)
            print(tvshows[0].popularity)
        }
//Discover movies sorted by vote average (desc)
      DiscoverMDB.discover(apikey, discoverType: "movie", language: nil, sort_by: DiscoverSortByMovie().vote_average_desc, page: nil){
            apiReturn in
            let discoveredMovies = apiReturn.MBDBReturn as! [MovieMDB]
            print(discoveredMovies[0].title)
            print(discoveredMovies[0].original_title)
            print(discoveredMovies[0].release_date)
            print(discoveredMovies[0].overview)
        }

Discover movies with genres action OR war, ( | (pipe) used to indicate an OR query , used for an AND query.) with Brad Pitt;

    
        DiscoverMovieMDB.discoverMoviesWith(apikey, with_genres: "\(MovieGenres.Action.rawValue),\(MovieGenres.War.rawValue)", 
with_cast: nil, with_crew: nil, with_companies: nil, with_keywords: nil, with_people: "287", with_networks: nil, year: nil, 
sort_by: DiscoverSortByMovie().popularity_desc, page: 1, language: "EN"){
            apiReturn in
            let movie = apiReturn.MBDBReturn as! [MovieMDB]
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }

Discover Animation and War & Politics shows, language French. Genre ids available in TVGenreand MovieGenre enums. Also on http://docs.themoviedb.apiary.io/#reference/genres/genretvlist/get and http://docs.themoviedb.apiary.io/#reference/genres/genremovielist/get

DiscoverMDB.discover(apikey, discoverType: "tv", language: "fr", sort_by: nil, page: nil, with_genres: "\(TVGenres.Animation.rawValue),\(TVGenres.WarPolitics.rawValue)"){
            apiReturn in
            if(apiReturn.error == nil){
                let tvshows = apiReturn.MBDBReturn as! [TVMDB]
                print(tvshows[0].name)
                print(tvshows[0].overview)
                print(tvshows[0].popularity)
            }
        }

Disocver movies with genres Crime 80) OR Drama(18) with vote average greater than 5 and vote count greater than 7, sort by vote count desc (Highest to lowest)

        DiscoverMDB.discover(apikey, discoverType: "movie", language: "en", sort_by: DiscoverSortBy().popularity_desc,
 page: 1, with_genres: "\(MovieGenres.Crime.rawValue)|\(MovieGenres.Drama.rawValue)" , vote_average_gte: 7, vote_count_gte: 7){
            apiReturn in
            let movie = apiReturn.MBDBReturn as! [MovieMDB]
            print(movie[0].title)
            print(movie[0].original_title)
            print(movie[0].release_date)
            print(movie[0].overview)
        }
Clone this wiki locally